#include <sajson.h>
Public Member Functions | |
document (document &&rhs) | |
size_t | get_error_column () const |
If not is_valid(), returns the one-based column number where the parse failed. More... | |
size_t | get_error_line () const |
If not is_valid(), returns the one-based line number where the parse failed. More... | |
const char * | get_error_message_as_cstring () const |
If not is_valid(), returns a null-terminated C string indicating why the parse failed. More... | |
std::string | get_error_message_as_string () const |
If not is_valid(), returns a std::string indicating why the parse failed. More... | |
value | get_root () const |
If is_valid(), returns the document's root value. More... | |
bool | is_valid () const |
Private Types | |
enum | { ERROR_BUFFER_LENGTH = 128 } |
Private Member Functions | |
document (const document &)=delete | |
document (const mutable_string_view &input_, internal::ownership &&structure_, type root_type_, const size_t *root_) | |
document (const mutable_string_view &input_, size_t error_line_, size_t error_column_, const error error_code_, int error_arg_) | |
bool | has_significant_error_arg () const |
void | operator= (const document &)=delete |
Private Attributes | |
const int | error_arg |
const error | error_code |
const size_t | error_column |
const size_t | error_line |
char | formatted_error_message [ERROR_BUFFER_LENGTH] |
mutable_string_view | input |
const size_t *const | root |
const type | root_type |
internal::ownership | structure |
Friends | |
template<typename AllocationStrategy , typename StringType > | |
document | parse (const AllocationStrategy &strategy, const StringType &string) |
template<typename Allocator > | |
class | parser |
Represents the result of a JSON parse: either is_valid() and the document contains a root value or parse error information is available.
Note that the document holds a strong reference to any memory allocated: any mutable copy of the input text and any memory allocated for the AST data structure. Thus, the document must not be deallocated while any value is in use.
|
privatedelete |
|
inlineexplicitprivate |
|
inlineexplicitprivate |
|
inline |
If not is_valid(), returns the one-based column number where the parse failed.
|
inline |
If not is_valid(), returns the one-based line number where the parse failed.
|
inline |
If not is_valid(), returns a null-terminated C string indicating why the parse failed.
|
inline |
If not is_valid(), returns a std::string indicating why the parse failed.
|
inline |
If is_valid(), returns the document's root value.
|
inlineprivate |
|
inline |
Returns true if the document was parsed successfully. If true, call get_root() to access the document's root value. If false, call get_error_line(), get_error_column(), and get_error_message_as_cstring() to see why the parse failed.
|
friend |
Parses a string of JSON bytes into a document, given an allocation strategy instance. Any kind of string type is valid as long as a mutable_string_view can be constructed from it.
Valid allocation strategies are single_allocation, dynamic_allocation, and bounded_allocation.
A document is returned whether or not the parse succeeds: success state is available by calling document::is_valid().
|
private |
|
private |
|
private |