MCPcopy Create free account
hub / github.com/cppcheck-opensource/cppcheck / _parse

Function _parse

externals/picojson/picojson.h:876–928  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

874}
875
876template <typename Context, typename Iter> inline bool _parse(Context &ctx, input<Iter> &in) {
877 in.skip_ws();
878 int ch = in.getc();
879 switch (ch) {
880#define IS(ch, text, op) \
881 case ch: \
882 if (in.match(text) && op) { \
883 return true; \
884 } else { \
885 return false; \
886 }
887 IS('n', "ull", ctx.set_null());
888 IS('f', "alse", ctx.set_bool(false));
889 IS('t', "rue", ctx.set_bool(true));
890#undef IS
891 case '"':
892 return ctx.parse_string(in);
893 case '[':
894 return _parse_array(ctx, in);
895 case '{':
896 return _parse_object(ctx, in);
897 default:
898 if (('0' <= ch && ch <= '9') || ch == '-') {
899 double f;
900 char *endp;
901 in.ungetc();
902 std::string num_str(_parse_number(in));
903 if (num_str.empty()) {
904 return false;
905 }
906#ifdef PICOJSON_USE_INT64
907 {
908 errno = 0;
909 intmax_t ival = strtoimax(num_str.c_str(), &endp, 10);
910 if (errno == 0 && std::numeric_limits<int64_t>::min() <= ival && ival <= std::numeric_limits<int64_t>::max() &&
911 endp == num_str.c_str() + num_str.size()) {
912 ctx.set_int64(ival);
913 return true;
914 }
915 }
916#endif
917 f = strtod(num_str.c_str(), &endp);
918 if (endp == num_str.c_str() + num_str.size()) {
919 ctx.set_number(f);
920 return true;
921 }
922 return false;
923 }
924 break;
925 }
926 in.ungetc();
927 return false;
928}
929
930class deny_parse_context {
931public:

Callers 5

parse_array_itemMethod · 0.85
parse_object_itemMethod · 0.85
parse_array_itemMethod · 0.85
parse_object_itemMethod · 0.85
parseFunction · 0.85

Calls 15

_parse_arrayFunction · 0.85
_parse_objectFunction · 0.85
_parse_numberFunction · 0.85
skip_wsMethod · 0.80
getcMethod · 0.80
ungetcMethod · 0.80
curMethod · 0.80
set_nullMethod · 0.45
set_boolMethod · 0.45
parse_stringMethod · 0.45
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected