mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2024-11-21 23:20:20 +00:00
b62a12c687
- Return more specific types from parse_array() and parse_object(). - Don't create a throwaway String in extract_while(). - Use a StringView in parse_number() to avoid a throwaway String.
47 lines
861 B
C++
47 lines
861 B
C++
#pragma once
|
|
|
|
#include <AK/JsonValue.h>
|
|
|
|
namespace AK {
|
|
|
|
class JsonParser {
|
|
public:
|
|
explicit JsonParser(const StringView& input)
|
|
: m_input(input)
|
|
{
|
|
}
|
|
~JsonParser()
|
|
{
|
|
}
|
|
|
|
JsonValue parse();
|
|
|
|
private:
|
|
char peek() const;
|
|
char consume();
|
|
void consume_whitespace();
|
|
void consume_specific(char expected_ch);
|
|
void consume_string(const char*);
|
|
String consume_quoted_string();
|
|
JsonArray parse_array();
|
|
JsonObject parse_object();
|
|
JsonValue parse_number();
|
|
JsonValue parse_string();
|
|
JsonValue parse_false();
|
|
JsonValue parse_true();
|
|
JsonValue parse_null();
|
|
JsonValue parse_undefined();
|
|
|
|
template<typename C>
|
|
void consume_while(C);
|
|
|
|
template<typename C>
|
|
Vector<char, 128> extract_while(C);
|
|
|
|
StringView m_input;
|
|
int m_index { 0 };
|
|
};
|
|
|
|
}
|
|
|
|
using AK::JsonParser;
|