Template Class lexer
Defined in File json.hpp
Inheritance Relationships
Base Type
public nlohmann::detail::lexer_base< BasicJsonType >
(Template Class lexer_base)
Class Documentation
-
template<typename BasicJsonType>
class lexer : public nlohmann::detail::lexer_base<BasicJsonType> lexical analysis
This class organizes the lexical analysis during JSON deserialization.
Public Types
-
enum class token_type
token types for the parser
Values:
-
enumerator uninitialized
indicating the scanner is uninitialized
-
enumerator literal_true
the
true
literal
-
enumerator literal_false
the
false
literal
-
enumerator literal_null
the
null
literal
-
enumerator value_string
a string — use get_string() for actual value
-
enumerator value_unsigned
an unsigned integer — use get_number_unsigned() for actual value
-
enumerator value_integer
a signed integer — use get_number_integer() for actual value
-
enumerator value_float
an floating point number — use get_number_float() for actual value
-
enumerator begin_array
the character for array begin
[
-
enumerator begin_object
the character for object begin
{
-
enumerator end_array
the character for array end
]
-
enumerator end_object
the character for object end
}
-
enumerator name_separator
the name separator
:
-
enumerator value_separator
the value separator
,
-
enumerator parse_error
indicating a parse error
-
enumerator end_of_input
indicating the end of the input buffer
-
enumerator literal_or_value
a literal or the begin of a value (only for diagnostics)
-
enumerator uninitialized
-
using token_type = typename lexer_base<BasicJsonType>::token_type
Public Functions
-
inline explicit lexer(detail::input_adapter_t &&adapter)
-
~lexer() = default
-
inline constexpr number_integer_t get_number_integer() const noexcept
return integer value
-
inline constexpr number_unsigned_t get_number_unsigned() const noexcept
return unsigned integer value
-
inline constexpr number_float_t get_number_float() const noexcept
return floating-point value
-
inline string_t &get_string()
return current string value (implicitly resets the token; useful only once)
-
inline constexpr position_t get_position() const noexcept
return position of last read token
-
inline std::string get_token_string() const
return the last read token (for errors only). Will never contain EOF (an arbitrary value that is not a valid char value, often -1), because 255 may legitimately occur. May contain NUL, which should be escaped.
- inline JSON_HEDLEY_RETURNS_NON_NULL constexpr const char * get_error_message () const noexcept
return syntax error message
-
inline bool skip_bom()
skip the UTF-8 byte order mark
- Returns:
true iff there is no BOM or the correct BOM has been skipped
-
inline token_type scan()
-
inline explicit lexer(InputAdapterType &&adapter, bool ignore_comments_ = false)
-
lexer(const lexer&) = delete
-
lexer(lexer&&) = default
-
~lexer() = default
-
inline constexpr number_integer_t get_number_integer() const noexcept
return integer value
-
inline constexpr number_unsigned_t get_number_unsigned() const noexcept
return unsigned integer value
-
inline constexpr number_float_t get_number_float() const noexcept
return floating-point value
-
inline string_t &get_string()
return current string value (implicitly resets the token; useful only once)
-
inline constexpr position_t get_position() const noexcept
return position of last read token
-
inline std::string get_token_string() const
return the last read token (for errors only). Will never contain EOF (an arbitrary value that is not a valid char value, often -1), because 255 may legitimately occur. May contain NUL, which should be escaped.
- inline JSON_HEDLEY_RETURNS_NON_NULL constexpr const char * get_error_message () const noexcept
return syntax error message
-
inline bool skip_bom()
skip the UTF-8 byte order mark
- Returns:
true iff there is no BOM or the correct BOM has been skipped
-
inline void skip_whitespace()
-
inline token_type scan()
Public Static Functions
- static inline JSON_HEDLEY_RETURNS_NON_NULL JSON_HEDLEY_CONST const char * token_type_name (const token_type t) noexcept
return name of values of type token_type (only used for errors)
-
enum class token_type