patrick
/
plasp
Archived
1
0
Fork 0
This repository has been archived on 2023-07-19. You can view files and clone it, but cannot push or open issues or pull requests.
plasp/include/plasp/utils/IO.h

58 lines
1.3 KiB
C++

#ifndef __PLASP__UTILS__IO_H
#define __PLASP__UTILS__IO_H
#include <boost/algorithm/string/replace.hpp>
namespace plasp
{
namespace utils
{
////////////////////////////////////////////////////////////////////////////////////////////////////
//
// IO
//
////////////////////////////////////////////////////////////////////////////////////////////////////
inline std::string escapeASP(const std::string &string)
{
auto escaped = string;
boost::replace_all(escaped, "_", "__");
boost::replace_all(escaped, "-", "_h");
boost::replace_all(escaped, "@", "_a");
return escaped;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
inline std::string unescapeASP(const std::string &string)
{
auto unescaped = string;
boost::replace_all(unescaped, "_a", "@");
boost::replace_all(unescaped, "_h", "-");
boost::replace_all(unescaped, "__", "_");
return unescaped;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
inline std::string escapeASPVariable(const std::string &string)
{
auto escaped = escapeASP(string);
escaped.front() = std::toupper(escaped.front());
return escaped;
}
////////////////////////////////////////////////////////////////////////////////////////////////////
}
}
#endif