Add unescapedValue() for String objects
This commit is contained in:
parent
224267f360
commit
8c49c53dde
|
@ -26,6 +26,22 @@
|
|||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
||||
static std::string strReplace(const std::string& orig, const std::string& pattern, const std::string subst)
|
||||
{
|
||||
std::string res = orig;
|
||||
std::size_t pos;
|
||||
|
||||
do
|
||||
{
|
||||
pos = res.find(pattern);
|
||||
|
||||
if (pos != std::string::npos)
|
||||
res.replace(pos, pattern.size(), subst);
|
||||
} while (pos != std::string::npos);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
namespace uPDFParser
|
||||
{
|
||||
/**
|
||||
|
@ -151,6 +167,18 @@ namespace uPDFParser
|
|||
return res;
|
||||
}
|
||||
|
||||
// Remove escape character '\'
|
||||
virtual std::string unescapedValue() {
|
||||
// Unescape '\n', \r', '\', '(' and ')'
|
||||
std::string res = strReplace(_value, "\\\\", "\\");
|
||||
res = strReplace(res, "\\(", "(");
|
||||
res = strReplace(res, "\\)", ")");
|
||||
res = strReplace(res, "\\n", "\n");
|
||||
res = strReplace(res, "\\r", "\r");
|
||||
|
||||
return res;
|
||||
}
|
||||
|
||||
private:
|
||||
std::string _value;
|
||||
};
|
||||
|
|
Loading…
Reference in New Issue
Block a user