| 20 | } |
| 21 | |
| 22 | std::string parse_string(const std::string & text, size_t & pos) { |
| 23 | skip_ws(text, pos); |
| 24 | if (pos >= text.size() || text[pos] != '"') { |
| 25 | throw std::runtime_error("expected json string"); |
| 26 | } |
| 27 | ++pos; |
| 28 | std::string out; |
| 29 | while (pos < text.size()) { |
| 30 | const char ch = text[pos++]; |
| 31 | if (ch == '\\') { |
| 32 | if (pos >= text.size()) { |
| 33 | throw std::runtime_error("invalid string escape"); |
| 34 | } |
| 35 | out.push_back(text[pos++]); |
| 36 | continue; |
| 37 | } |
| 38 | if (ch == '"') { |
| 39 | return out; |
| 40 | } |
| 41 | out.push_back(ch); |
| 42 | } |
| 43 | throw std::runtime_error("unterminated json string"); |
| 44 | } |
| 45 | |
| 46 | int64_t parse_int64(const std::string & text, size_t & pos) { |
| 47 | skip_ws(text, pos); |
no test coverage detected