13 static bool json_isdigit(
int ch)
15 return ((ch >=
'0') && (ch <=
'9'));
19 static const char *hatoui(
const char *first,
const char *last,
22 unsigned int result = 0;
23 for (; first != last; ++first)
26 if (json_isdigit(*first))
29 else if (*first >=
'a' && *first <=
'f')
30 digit = *first -
'a' + 10;
32 else if (*first >=
'A' && *first <=
'F')
33 digit = *first -
'A' + 10;
38 result = 16 * result + digit;
46 const char *raw,
const char *end)
51 const char *rawStart = raw;
53 while (raw < end && (json_isspace(*raw)))
63 consumed = (raw - rawStart);
67 consumed = (raw - rawStart);
71 consumed = (raw - rawStart);
75 consumed = (raw - rawStart);
80 consumed = (raw - rawStart);
84 consumed = (raw - rawStart);
90 if (!strncmp(raw,
"null", 4)) {
92 consumed = (raw - rawStart);
94 }
else if (!strncmp(raw,
"true", 4)) {
96 consumed = (raw - rawStart);
98 }
else if (!strncmp(raw,
"false", 5)) {
100 consumed = (raw - rawStart);
119 const char *first = raw;
121 const char *firstDigit = first;
122 if (!json_isdigit(*firstDigit))
124 if ((*firstDigit ==
'0') && json_isdigit(firstDigit[1]))
130 if ((*first ==
'-') && (raw < end) && (!json_isdigit(*raw)))
133 while (raw < end && json_isdigit(*raw)) {
139 if (raw < end && *raw ==
'.') {
143 if (raw >= end || !json_isdigit(*raw))
145 while (raw < end && json_isdigit(*raw)) {
152 if (raw < end && (*raw ==
'e' || *raw ==
'E')) {
156 if (raw < end && (*raw ==
'-' || *raw ==
'+')) {
161 if (raw >= end || !json_isdigit(*raw))
163 while (raw < end && json_isdigit(*raw)) {
170 consumed = (raw - rawStart);
181 if (raw >= end || (
unsigned char)*raw < 0x20)
184 else if (*raw ==
'\\') {
192 case '\\': writer.
push_back(
'\\');
break;
201 unsigned int codepoint;
202 if (raw + 1 + 4 >= end ||
203 hatoui(raw + 1, raw + 1 + 4, codepoint) !=
218 else if (*raw ==
'"') {
232 consumed = (raw - rawStart);
249 #define expect(bit) (expectMask & (EXP_##bit)) 250 #define setExpect(bit) (expectMask |= EXP_##bit) 251 #define clearExpect(bit) (expectMask &= ~EXP_##bit) 257 uint32_t expectMask = 0;
258 vector<UniValue*> stack;
261 unsigned int consumed;
264 const char* end = raw +
size;
273 bool isValueOpen = jsonTokenIsValue(tok) ||
281 }
else if (
expect(ARR_VALUE)) {
288 }
else if (
expect(OBJ_NAME)) {
293 }
else if (
expect(COLON)) {
318 stack.push_back(
this);
322 top->
values.push_back(tmpVal);
337 if (!stack.size() || (last_tok ==
JTOK_COMMA))
399 top->
values.push_back(tmpVal);
413 top->
values.push_back(tmpVal);
422 top->
keys.push_back(tokenVal);
432 top->
values.push_back(tmpVal);
442 }
while (!stack.empty ());
bool read(const char *raw, size_t len)
std::hash for asio::adress
std::vector< UniValue > values
void push_back(unsigned char ch)
enum jtokentype getJsonToken(string &tokenVal, unsigned int &consumed, const char *raw, const char *end)
enum VType getType() const
Filter that generates and validates UTF-8, as well as collates UTF-16 surrogate pairs as specified in...
bool push_back(const UniValue &val)
uint8_t const size_t const size
std::vector< std::string > keys
uint32_t ch(uint32_t x, uint32_t y, uint32_t z)
void push_back_u(unsigned int codepoint_)