Escaping predicates containing hyphens for ASP output.
This commit is contained in:
@@ -1,12 +1,15 @@
|
||||
#ifndef __UTILS__PARSING_H
|
||||
#define __UTILS__PARSING_H
|
||||
|
||||
#include <algorithm>
|
||||
#include <exception>
|
||||
#include <iosfwd>
|
||||
#include <sstream>
|
||||
#include <string>
|
||||
#include <typeinfo>
|
||||
|
||||
#include <boost/algorithm/string/replace.hpp>
|
||||
|
||||
#include <plasp/utils/ParserException.h>
|
||||
|
||||
namespace plasp
|
||||
@@ -56,6 +59,30 @@ void parseExpected(std::istream &istream, const T &expectedValue)
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline std::string escapeASP(const std::string &string)
|
||||
{
|
||||
auto escaped = string;
|
||||
|
||||
boost::replace_all(escaped, "_", "__");
|
||||
boost::replace_all(escaped, "-", "_h");
|
||||
|
||||
return escaped;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
inline std::string unescapeASP(const std::string &string)
|
||||
{
|
||||
auto unescaped = string;
|
||||
|
||||
boost::replace_all(unescaped, "_h", "-");
|
||||
boost::replace_all(unescaped, "__", "_");
|
||||
|
||||
return unescaped;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user