Template Class parser
Defined in File json.hpp
Class Documentation
-
template<typename BasicJsonType>
class parser syntax analysis
This class implements a recursive decent parser.
This class implements a recursive descent parser.
Public Types
-
enum class parse_event_t : uint8_t
Values:
-
enumerator object_start
the parser read
{
and started to process a JSON object
-
enumerator object_end
the parser read
}
and finished processing a JSON object
-
enumerator array_start
the parser read
[
and started to process a JSON array
-
enumerator array_end
the parser read
]
and finished processing a JSON array
-
enumerator key
the parser read a key of a value in an object
-
enumerator value
the parser finished reading a JSON value
-
enumerator object_start
-
using parser_callback_t = std::function<bool(int depth, parse_event_t event, BasicJsonType &parsed)>
Public Functions
-
inline explicit parser(detail::input_adapter_t &&adapter, const parser_callback_t cb = nullptr, const bool allow_exceptions_ = true)
a parser reading from an input adapter
-
inline void parse(const bool strict, BasicJsonType &result)
public parser interface
- Parameters:
strict – [in] whether to expect the last token to be EOF
result – [inout] parsed JSON value
- Throws:
parse_error.101 – in case of an unexpected token
parse_error.102 – if to_unicode fails or surrogate error
parse_error.103 – if to_unicode fails
-
inline bool accept(const bool strict = true)
public accept interface
- Parameters:
strict – [in] whether to expect the last token to be EOF
- Returns:
whether the input is a proper JSON text
-
inline explicit parser(InputAdapterType &&adapter, const parser_callback_t<BasicJsonType> cb = nullptr, const bool allow_exceptions_ = true, const bool skip_comments = false)
a parser reading from an input adapter
-
inline void parse(const bool strict, BasicJsonType &result)
public parser interface
- Parameters:
strict – [in] whether to expect the last token to be EOF
result – [inout] parsed JSON value
- Throws:
parse_error.101 – in case of an unexpected token
parse_error.102 – if to_unicode fails or surrogate error
parse_error.103 – if to_unicode fails
-
inline bool accept(const bool strict = true)
public accept interface
- Parameters:
strict – [in] whether to expect the last token to be EOF
- Returns:
whether the input is a proper JSON text
-
template<typename SAX>
inline bool sax_parse(SAX *sax, const bool strict = true)
-
enum class parse_event_t : uint8_t