summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/uscxml/util/String.cpp27
-rw-r--r--src/uscxml/util/String.h1
2 files changed, 28 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;
diff --git a/src/uscxml/util/String.h b/src/uscxml/util/String.h
index 5344245..b0832c8 100644
--- a/src/uscxml/util/String.h
+++ b/src/uscxml/util/String.h
@@ -25,6 +25,7 @@
namespace uscxml {
+std::string macro_escaped(std::string const& s);
std::list<std::string> tokenize(const std::string& line, const char seperator = ' ', bool trimWhiteSpace = true);
std::string spaceNormalize(const std::string& text);
bool nameMatch(const std::string& eventDescs, const std::string& event);