summaryrefslogtreecommitdiff
path: root/lib/jsonParse.impl.cpp
diff options
context:
space:
mode:
authorDan Goodliffe <dan@randomdan.homeip.net>2021-04-17 21:41:26 +0100
committerDan Goodliffe <dan@randomdan.homeip.net>2021-11-07 16:41:37 +0000
commit71c5280bc6393669777147b5036dc510e74d93c4 (patch)
tree4efcc41b8d87f2c4a0dff3b6ad852bdaf809f514 /lib/jsonParse.impl.cpp
parentInitial commit of basis persistence (diff)
downloadilt-71c5280bc6393669777147b5036dc510e74d93c4.tar.bz2
ilt-71c5280bc6393669777147b5036dc510e74d93c4.tar.xz
ilt-71c5280bc6393669777147b5036dc510e74d93c4.zip
Second swing persistance
Mostly functional JSON deserialising for most types.
Diffstat (limited to 'lib/jsonParse.impl.cpp')
-rw-r--r--lib/jsonParse.impl.cpp23
1 files changed, 13 insertions, 10 deletions
diff --git a/lib/jsonParse.impl.cpp b/lib/jsonParse.impl.cpp
index 27e73b4..3ed8e62 100644
--- a/lib/jsonParse.impl.cpp
+++ b/lib/jsonParse.impl.cpp
@@ -1,4 +1,7 @@
#include "jsonParse.h"
+#include <cstdlib>
+#include <stdexcept>
+#include <string>
void
json::jsonParser::LexerError(const char * msg)
@@ -16,24 +19,24 @@ void
json::jsonParser::appendEscape(unsigned long cp, std::string & str)
{
if (cp <= 0x7F) {
- str += cp;
+ str += (char)cp;
}
else if (cp <= 0x7FF) {
- str += (cp >> 6) + 192;
- str += (cp & 63) + 128;
+ str += char((cp >> 6) + 192);
+ str += char((cp & 63) + 128);
}
else if (0xd800 <= cp && cp <= 0xdfff) {
throw std::range_error("Invalid UTF-8 sequence");
}
else if (cp <= 0xFFFF) {
- str += (cp >> 12) + 224;
- str += ((cp >> 6) & 63) + 128;
- str += (cp & 63) + 128;
+ str += char((cp >> 12) + 224);
+ str += char(((cp >> 6) & 63) + 128);
+ str += char((cp & 63) + 128);
}
else if (cp <= 0x10FFFF) {
- str += (cp >> 18) + 240;
- str += ((cp >> 12) & 63) + 128;
- str += ((cp >> 6) & 63) + 128;
- str += (cp & 63) + 128;
+ str += char((cp >> 18) + 240);
+ str += char(((cp >> 12) & 63) + 128);
+ str += char(((cp >> 6) & 63) + 128);
+ str += char((cp & 63) + 128);
}
}