summaryrefslogtreecommitdiffstats
path: root/src/uscxml/Convenience.h
diff options
context:
space:
mode:
authorStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2014-01-14 16:15:09 (GMT)
committerStefan Radomski <radomski@tk.informatik.tu-darmstadt.de>2014-01-14 16:15:09 (GMT)
commit836927aa902696297febc95132e2c82147c08c03 (patch)
tree64bcbaa67c6f70acdb5f4cc9184f600fad46b826 /src/uscxml/Convenience.h
parentf7ca1ebaa5a527f817892bc3794452df1a6c20c6 (diff)
downloaduscxml-836927aa902696297febc95132e2c82147c08c03.zip
uscxml-836927aa902696297febc95132e2c82147c08c03.tar.gz
uscxml-836927aa902696297febc95132e2c82147c08c03.tar.bz2
Expect Invoker and Fedora build fixes
Diffstat (limited to 'src/uscxml/Convenience.h')
-rw-r--r--src/uscxml/Convenience.h27
1 files changed, 27 insertions, 0 deletions
diff --git a/src/uscxml/Convenience.h b/src/uscxml/Convenience.h
index 0177476..cfaf617 100644
--- a/src/uscxml/Convenience.h
+++ b/src/uscxml/Convenience.h
@@ -20,6 +20,7 @@
#ifndef CONVENIENCE_H_LU7GZ6CB
#define CONVENIENCE_H_LU7GZ6CB
+#include <inttypes.h>
#include <boost/detail/endian.hpp>
namespace uscxml {
@@ -69,6 +70,32 @@ inline bool equals(const std::string& a, const std::string& b) {
return true;
}
+inline std::string unescape(const std::string& a) {
+ std::stringstream b;
+ // see http://en.cppreference.com/w/cpp/language/escape
+
+ std::string::const_iterator it = a.begin();
+ while (it != a.end()) {
+ char c = *it++;
+ if (c == '\\' && it != a.end()) {
+ switch (*it++) {
+ case '\\': c = '\\'; break;
+ case '0': c = '\0'; break;
+ case 'a': c = '\a'; break;
+ case 'b': c = '\b'; break;
+ case 'f': c = '\f'; break;
+ case 'n': c = '\n'; break;
+ case 'r': c = '\r'; break;
+ case 't': c = '\t'; break;
+ case 'v': c = '\v'; break;
+ }
+ }
+ b << c;
+ }
+
+ return b.str();
+}
+
// see http://www.cplusplus.com/forum/general/27544/
// Little-endian operating systems: