diff options
author | Stefan Radomski <sradomski@mintwerk.de> | 2016-01-06 11:10:10 (GMT) |
---|---|---|
committer | Stefan Radomski <sradomski@mintwerk.de> | 2016-01-06 11:10:10 (GMT) |
commit | f9eb54fc9c17116954846133b33f7a241e662cbc (patch) | |
tree | 7b6eede00cd3c088f0f652acccc89d4471f9cfa6 /src/uscxml/Convenience.h | |
parent | b8ba0e7c31f397a66f9d509ff20a85b33619475a (diff) | |
download | uscxml-f9eb54fc9c17116954846133b33f7a241e662cbc.zip uscxml-f9eb54fc9c17116954846133b33f7a241e662cbc.tar.gz uscxml-f9eb54fc9c17116954846133b33f7a241e662cbc.tar.bz2 |
Prepared ChartToC transformation
Diffstat (limited to 'src/uscxml/Convenience.h')
-rw-r--r-- | src/uscxml/Convenience.h | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/uscxml/Convenience.h b/src/uscxml/Convenience.h index cbc38d9..88afa8d 100644 --- a/src/uscxml/Convenience.h +++ b/src/uscxml/Convenience.h @@ -20,6 +20,7 @@ #ifndef CONVENIENCE_H_LU7GZ6CB #define CONVENIENCE_H_LU7GZ6CB +#include "uscxml/Common.h" #include <inttypes.h> #include <stdlib.h> #include <boost/detail/endian.hpp> @@ -43,6 +44,31 @@ template <typename T> T strTo(std::string tmp) { return output; } +class USCXML_API NumAttr { +public: + NumAttr(const std::string& str) { + size_t valueStart = str.find_first_of("0123456789."); + if (valueStart != std::string::npos) { + size_t valueEnd = str.find_last_of("0123456789."); + if (valueEnd != std::string::npos) { + value = str.substr(valueStart, (valueEnd - valueStart) + 1); + size_t unitStart = str.find_first_not_of(" \t", valueEnd + 1); + if (unitStart != std::string::npos) { + size_t unitEnd = str.find_last_of(" \t"); + if (unitEnd != std::string::npos && unitEnd > unitStart) { + unit = str.substr(unitStart, unitEnd - unitStart); + } else { + unit = str.substr(unitStart, str.length() - unitStart); + } + } + } + } + } + + std::string value; + std::string unit; +}; + bool isNumeric(const char* pszInput, int nNumberBase); bool isInteger( const char* pszInput, int nNumberBase); bool iequals(const std::string& a, const std::string& b); @@ -51,6 +77,7 @@ bool stringIsTrue(const std::string& value); bool envVarIsTrue(const char* name); bool envVarIEquals(const char* name, const char* value); +std::string escape(const std::string& a); std::string unescape(const std::string& a); // see http://www.cplusplus.com/forum/general/27544/ |