diff options
author | Stefan Radomski <github@mintwerk.de> | 2016-11-23 10:06:21 (GMT) |
---|---|---|
committer | Stefan Radomski <github@mintwerk.de> | 2016-11-23 10:06:21 (GMT) |
commit | 514fc8e12d2fc798450772a8ceb5d40dc123fb5a (patch) | |
tree | 95b59a5200560c10d5feb9f901d195081be918b7 /src/uscxml/util | |
parent | 032f9fcfb389ee4a6f8f23ad20f7f5b4c3da1e47 (diff) | |
download | uscxml-514fc8e12d2fc798450772a8ceb5d40dc123fb5a.zip uscxml-514fc8e12d2fc798450772a8ceb5d40dc123fb5a.tar.gz uscxml-514fc8e12d2fc798450772a8ceb5d40dc123fb5a.tar.bz2 |
Beautified Code again
Diffstat (limited to 'src/uscxml/util')
-rw-r--r-- | src/uscxml/util/String.cpp | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/uscxml/util/String.cpp b/src/uscxml/util/String.cpp index ae1aa68..6a80756 100644 --- a/src/uscxml/util/String.cpp +++ b/src/uscxml/util/String.cpp @@ -26,26 +26,25 @@ namespace uscxml { #define ISWHITESPACE(char) (isspace(char)) std::string escapeMacro(std::string const &s) { - // inspired by http://stackoverflow.com/questions/2417588/escaping-a-c-string - std::string returnValue=""; + // inspired by http://stackoverflow.com/questions/2417588/escaping-a-c-string + std::string returnValue=""; std::string specialChars=""; - for (std::string::const_iterator iter = s.begin(), end = s.end(); iter != end; ++iter) { - char c = *iter; - if (('0' <= c && c <= '9') || ('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z') || c == '_') { - returnValue += c; - } - else { - specialChars += c; - } - } - if (!specialChars.empty()){ + for (std::string::const_iterator iter = s.begin(), end = s.end(); iter != end; ++iter) { + char c = *iter; + if (('0' <= c && c <= '9') || ('A' <= c && c <= 'Z') || ('a' <= c && c <= 'z') || c == '_') { + returnValue += c; + } else { + specialChars += c; + } + } + if (!specialChars.empty()) { // http://www.cplusplus.com/reference/functional/hash/ // returns the same result for a given string within one execution std::hash<std::string> strHash; returnValue += "_"; returnValue += strHash(specialChars); } - return returnValue; + return returnValue; } std::list<std::string> tokenize(const std::string& line, const char sep, bool trimWhiteSpace) { |