• Home
  • Raw
  • Download

Lines Matching refs:str

47 static const char* parse_value(const char *str, const char *end, pa_json_object **obj, unsigned int…
79 static const char* consume_string(const char *str, const char *expect) { in consume_string() argument
81 if (*str != *expect) in consume_string()
84 str++; in consume_string()
88 return str; in consume_string()
91 static const char* parse_null(const char *str, pa_json_object *obj) { in parse_null() argument
92 str = consume_string(str, "null"); in parse_null()
94 if (str) in parse_null()
97 return str; in parse_null()
100 static const char* parse_boolean(const char *str, pa_json_object *obj) { in parse_boolean() argument
103 tmp = consume_string(str, "true"); in parse_boolean()
109 tmp = consume_string(str, "false"); in parse_boolean()
111 if (str) { in parse_boolean()
120 static const char* parse_string(const char *str, pa_json_object *obj) { in parse_string() argument
123 str++; /* Consume leading '"' */ in parse_string()
125 while (*str && *str != '"') { in parse_string()
126 if (*str != '\\') { in parse_string()
128 if (*str < 0x20 || *str > 0x7E) { in parse_string()
129 pa_log("Invalid non-ASCII character: 0x%x", (unsigned int) *str); in parse_string()
134 pa_strbuf_putc(buf, *str); in parse_string()
137 str++; in parse_string()
139 switch (*str) { in parse_string()
143 pa_strbuf_putc(buf, *str); in parse_string()
171 pa_log("Unexepcted escape value: %c", *str); in parse_string()
176 str++; in parse_string()
179 if (*str != '"') { in parse_string()
180 pa_log("Failed to parse remainder of string: %s", str); in parse_string()
184 str++; in parse_string()
189 return str; in parse_string()
196 static const char* parse_number(const char *str, pa_json_object *obj) { in parse_number() argument
203 if (*str == '-') { in parse_number()
205 str++; in parse_number()
208 if (*str == '0') { in parse_number()
210 str++; in parse_number()
214 while (is_digit(*str)) { in parse_number()
222 integer = (integer * 10) + (*str - '0'); in parse_number()
223 str++; in parse_number()
233 if (*str == '.') { in parse_number()
235 str++; in parse_number()
238 while (is_digit(*str)) { in parse_number()
246 fraction = (fraction * 10) + (*str - '0'); in parse_number()
248 str++; in parse_number()
257 if (*str == 'e' || *str == 'E') { in parse_number()
261 str++; in parse_number()
264 if (*str == '-') { in parse_number()
266 str++; in parse_number()
267 } else if (*str == '+') in parse_number()
268 str++; in parse_number()
270 while (is_digit(*str)) { in parse_number()
278 exponent = (exponent * 10) + (*str - '0'); in parse_number()
279 str++; in parse_number()
300 return str; in parse_number()
306 static const char *parse_object(const char *str, pa_json_object *obj, unsigned int depth) { in parse_object() argument
312 while (*str != '}') { in parse_object()
313 str++; /* Consume leading '{' or ',' */ in parse_object()
315 str = parse_value(str, ":", &name, depth + 1); in parse_object()
316 if (!str || pa_json_object_get_type(name) != PA_JSON_TYPE_STRING) { in parse_object()
322 str++; in parse_object()
324 str = parse_value(str, ",}", &value, depth + 1); in parse_object()
325 if (!str) { in parse_object()
338 str++; in parse_object()
343 return str; in parse_object()
357 static const char *parse_array(const char *str, pa_json_object *obj, unsigned int depth) { in parse_array() argument
362 while (*str != ']') { in parse_array()
363 str++; /* Consume leading '[' or ',' */ in parse_array()
367 while (is_whitespace(*str)) in parse_array()
368 str++; in parse_array()
370 if (*str == ']') in parse_array()
373 str = parse_value(str, ",]", &value, depth + 1); in parse_array()
374 if (!str) { in parse_array()
383 str++; in parse_array()
388 return str; in parse_array()
401 static const char* parse_value(const char *str, const char *end, pa_json_object **obj, unsigned int… in parse_value() argument
405 pa_assert(str != NULL); in parse_value()
414 while (!is_end(*str, end)) { in parse_value()
417 if (is_whitespace(*str)) { in parse_value()
418 str++; in parse_value()
419 } else if (*str == 'n') { in parse_value()
420 str = parse_null(str, o); in parse_value()
422 } else if (*str == 't' || *str == 'f') { in parse_value()
423 str = parse_boolean(str, o); in parse_value()
425 } else if (*str == '"') { in parse_value()
426 str = parse_string(str, o); in parse_value()
428 } else if (is_digit(*str) || *str == '-') { in parse_value()
429 str = parse_number(str, o); in parse_value()
431 } else if (*str == '{') { in parse_value()
432 str = parse_object(str, o, depth); in parse_value()
434 } else if (*str == '[') { in parse_value()
435 str = parse_array(str, o, depth); in parse_value()
438 pa_log("Invalid JSON string: %s", str); in parse_value()
442 if (!str) in parse_value()
449 if (is_whitespace(*str)) { in parse_value()
450 str++; in parse_value()
459 pa_log("No data while parsing json string: '%s' till '%s'", str, pa_strnull(end)); in parse_value()
465 return str; in parse_value()
473 pa_json_object* pa_json_parse(const char *str) { in pa_json_parse() argument
476 str = parse_value(str, NULL, &obj, 0); in pa_json_parse()
478 if (!str) { in pa_json_parse()
483 if (*str != '\0') { in pa_json_parse()
484 pa_log("Unable to parse complete JSON string, remainder is: %s", str); in pa_json_parse()