Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
sajson::document Class Reference

#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
 

Detailed Description

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.

Definition at line 737 of file sajson.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
private
Enumerator
ERROR_BUFFER_LENGTH 

Definition at line 874 of file sajson.h.

Constructor & Destructor Documentation

◆ document() [1/4]

sajson::document::document ( document &&  rhs)
inline

Definition at line 739 of file sajson.h.

◆ document() [2/4]

sajson::document::document ( const document )
privatedelete

◆ document() [3/4]

sajson::document::document ( const mutable_string_view input_,
internal::ownership &&  structure_,
type  root_type_,
const size_t *  root_ 
)
inlineexplicitprivate

Definition at line 830 of file sajson.h.

◆ document() [4/4]

sajson::document::document ( const mutable_string_view input_,
size_t  error_line_,
size_t  error_column_,
const error  error_code_,
int  error_arg_ 
)
inlineexplicitprivate

Definition at line 843 of file sajson.h.

Member Function Documentation

◆ get_error_column()

size_t sajson::document::get_error_column ( ) const
inline

If not is_valid(), returns the one-based column number where the parse failed.

Definition at line 776 of file sajson.h.

◆ get_error_line()

size_t sajson::document::get_error_line ( ) const
inline

If not is_valid(), returns the one-based line number where the parse failed.

Definition at line 771 of file sajson.h.

◆ get_error_message_as_cstring()

const char* sajson::document::get_error_message_as_cstring ( ) const
inline

If not is_valid(), returns a null-terminated C string indicating why the parse failed.

Definition at line 788 of file sajson.h.

◆ get_error_message_as_string()

std::string sajson::document::get_error_message_as_string ( ) const
inline

If not is_valid(), returns a std::string indicating why the parse failed.

Definition at line 782 of file sajson.h.

◆ get_root()

value sajson::document::get_root ( ) const
inline

If is_valid(), returns the document's root value.

Definition at line 766 of file sajson.h.

◆ has_significant_error_arg()

bool sajson::document::has_significant_error_arg ( ) const
inlineprivate

Definition at line 861 of file sajson.h.

◆ is_valid()

bool sajson::document::is_valid ( ) const
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.

Definition at line 761 of file sajson.h.

◆ operator=()

void sajson::document::operator= ( const document )
privatedelete

Friends And Related Function Documentation

◆ parse

template<typename AllocationStrategy , typename StringType >
document parse ( const AllocationStrategy &  strategy,
const StringType &  string 
)
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().

Definition at line 2479 of file sajson.h.

◆ parser

template<typename Allocator >
friend class parser
friend

Definition at line 880 of file sajson.h.

Member Data Documentation

◆ error_arg

const int sajson::document::error_arg
private

Definition at line 872 of file sajson.h.

◆ error_code

const error sajson::document::error_code
private

Definition at line 871 of file sajson.h.

◆ error_column

const size_t sajson::document::error_column
private

Definition at line 870 of file sajson.h.

◆ error_line

const size_t sajson::document::error_line
private

Definition at line 869 of file sajson.h.

◆ formatted_error_message

char sajson::document::formatted_error_message[ERROR_BUFFER_LENGTH]
private

Definition at line 875 of file sajson.h.

◆ input

mutable_string_view sajson::document::input
private

Definition at line 865 of file sajson.h.

◆ root

const size_t* const sajson::document::root
private

Definition at line 868 of file sajson.h.

◆ root_type

const type sajson::document::root_type
private

Definition at line 867 of file sajson.h.

◆ structure

internal::ownership sajson::document::structure
private

Definition at line 866 of file sajson.h.


The documentation for this class was generated from the following file:


mvsim
Author(s):
autogenerated on Tue Jul 4 2023 03:08:23