diff options
Diffstat (limited to 'src/cppvalue.cpp')
-rw-r--r-- | src/cppvalue.cpp | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/src/cppvalue.cpp b/src/cppvalue.cpp index 77677d9..8cd7c5c 100644 --- a/src/cppvalue.cpp +++ b/src/cppvalue.cpp @@ -51,6 +51,16 @@ CPPValue parseHexadecimal(const std::string& token) return CPPValue(val); } +CPPValue parseBinary(const std::string& token) +{ + long val = 0; + for (const char *p = token.c_str(); *p != 0; p++) + { + if (*p >= '0' && *p <= '1') val = val * 2 + *p - '0'; + } + return CPPValue(val); +} + CPPValue parseCharacter(const std::string& token) // does not work for '\n' and the alike { if (token[1]=='\\') |