summaryrefslogtreecommitdiffstats
path: root/src/uscxml/util/String.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/uscxml/util/String.cpp')
-rw-r--r--src/uscxml/util/String.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/uscxml/util/String.cpp b/src/uscxml/util/String.cpp
index 6d43301..894148d 100644
--- a/src/uscxml/util/String.cpp
+++ b/src/uscxml/util/String.cpp
@@ -25,6 +25,33 @@ namespace uscxml {
#define ISWHITESPACE(char) (isspace(char))
+std::string macro_escaped(std::string const& s) {
+ std::string returnValue="";
+ for (std::string::const_iterator iter = s.begin(), end = s.end(); iter != end; ++iter) {
+ char c = *iter;
+ if (' ' <= c and c <= '~' and c != '\\' and c != '"') {
+ returnValue += c;
+ }
+ else {
+ returnValue += '__';
+ switch(c) {
+ case '"': returnValue += 'COLON'; break;
+ case '\\': returnValue += 'BACHSLASH'; break;
+ case '\t': returnValue += 'TAB'; break;
+ case '\r': returnValue += 'RETURN'; break;
+ case '\n': returnValue += 'NEWLINE'; break;
+ default:
+ char const* const hexdig = "0123456789ABCDEF";
+ returnValue += 'x';
+ returnValue += hexdig[c >> 4];
+ returnValue += hexdig[c & 0xF];
+ }
+ returnValue += '__';
+ }
+ }
+ return returnValue;
+}
+
std::list<std::string> tokenize(const std::string& line, const char sep, bool trimWhiteSpace) {
std::list<std::string> tokens;