MCPcopy Create free account
hub / github.com/ArduPilot/ardupilot / _parse

Function _parse

libraries/AP_JSON/AP_JSON.cpp:582–624  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

580}
581
582template <typename Context, typename Iter> bool _parse(Context &ctx, input<Iter> &in)
583{
584 in.skip_ws();
585 int ch = in.getc();
586 switch (ch) {
587#define IS(ch, text, op) \
588 case ch: \
589 if (in.match(text) && op) { \
590 return true; \
591 } else { \
592 return false; \
593 }
594 IS('n', "ull", ctx.set_null());
595 IS('f', "alse", ctx.set_bool(false));
596 IS('t', "rue", ctx.set_bool(true));
597#undef IS
598 case '"':
599 return ctx.parse_string(in);
600 case '[':
601 return _parse_array(ctx, in);
602 case '{':
603 return _parse_object(ctx, in);
604 default:
605 if (('0' <= ch && ch <= '9') || ch == '-') {
606 double f;
607 char *endp;
608 in.ungetc();
609 std::string num_str(_parse_number(in));
610 if (num_str.empty()) {
611 return false;
612 }
613 f = strtod(num_str.c_str(), &endp);
614 if (endp == num_str.c_str() + num_str.size()) {
615 ctx.set_number(f);
616 return true;
617 }
618 return false;
619 }
620 break;
621 }
622 in.ungetc();
623 return false;
624}
625
626class default_parse_context
627{

Callers 3

parse_array_itemMethod · 0.85
parse_object_itemMethod · 0.85
parseFunction · 0.85

Calls 14

_parse_arrayFunction · 0.85
_parse_objectFunction · 0.85
_parse_numberFunction · 0.85
skip_wsMethod · 0.80
getcMethod · 0.80
set_nullMethod · 0.80
set_boolMethod · 0.80
parse_stringMethod · 0.80
ungetcMethod · 0.80
emptyMethod · 0.80
set_numberMethod · 0.80
lineMethod · 0.80

Tested by

no test coverage detected