NCBI C++ ToolKit
Public Member Functions | Private Attributes | Friends | List of all members
rapidjson::ParseResult Struct Reference

Search Toolkit Book for rapidjson::ParseResult

Result of parsing (wraps ParseErrorCode) More...

#include <misc/jsonwrapp/rapidjson11/error/error.h>

+ Collaboration diagram for rapidjson::ParseResult:

Public Member Functions

 ParseResult ()
 Default constructor, no error. More...
 
 ParseResult (ParseErrorCode code, size_t offset)
 Constructor to set an error. More...
 
ParseErrorCode Code () const
 Get the error code. More...
 
size_t Offset () const
 Get the error offset, if IsError(), 0 otherwise. More...
 
 operator bool () const
 Conversion to bool, returns true, iff !IsError(). More...
 
bool IsError () const
 Whether the result is an error. More...
 
bool operator== (const ParseResult &that) const
 
bool operator== (ParseErrorCode code) const
 
void Clear ()
 Reset error code. More...
 
void Set (ParseErrorCode code, size_t offset=0)
 Update error code and offset. More...
 

Private Attributes

ParseErrorCode code_
 
size_t offset_
 

Friends

bool operator== (ParseErrorCode code, const ParseResult &err)
 

Detailed Description

Result of parsing (wraps ParseErrorCode)

ParseResult ok = doc.Parse("[42]");
if (!ok) {
fprintf(stderr, "JSON parse error: %s (%u)",
GetParseError_En(ok.Code()), ok.Offset());
}
#define EXIT_FAILURE
Definition: fastme.h:73
const char * GetParseError_En(ParseErrorCode parseErrorCode)
Maps error code of parsing into error message.
Definition: en.h:36
exit(2)
GenericDocument< UTF8<> > Document
GenericDocument with UTF8 encoding.
Definition: document.h:2547
ParseResult()
Default constructor, no error.
Definition: error.h:109
See also
GenericReader::Parse, GenericDocument::Parse

Definition at line 106 of file error.h.

Constructor & Destructor Documentation

◆ ParseResult() [1/2]

rapidjson::ParseResult::ParseResult ( )
inline

Default constructor, no error.

Definition at line 109 of file error.h.

◆ ParseResult() [2/2]

rapidjson::ParseResult::ParseResult ( ParseErrorCode  code,
size_t  offset 
)
inline

Constructor to set an error.

Definition at line 111 of file error.h.

Member Function Documentation

◆ Clear()

void rapidjson::ParseResult::Clear ( void  )
inline

◆ Code()

ParseErrorCode rapidjson::ParseResult::Code ( void  ) const
inline

Get the error code.

Definition at line 114 of file error.h.

◆ IsError()

bool rapidjson::ParseResult::IsError ( void  ) const
inline

Whether the result is an error.

Definition at line 121 of file error.h.

References rapidjson::kParseErrorNone.

◆ Offset()

size_t rapidjson::ParseResult::Offset ( ) const
inline

Get the error offset, if IsError(), 0 otherwise.

Definition at line 116 of file error.h.

◆ operator bool()

rapidjson::ParseResult::operator bool ( void  ) const
inline

Conversion to bool, returns true, iff !IsError().

Definition at line 119 of file error.h.

◆ operator==() [1/2]

bool rapidjson::ParseResult::operator== ( const ParseResult that) const
inline

Definition at line 123 of file error.h.

References code_.

◆ operator==() [2/2]

bool rapidjson::ParseResult::operator== ( ParseErrorCode  code) const
inline

Definition at line 124 of file error.h.

◆ Set()

void rapidjson::ParseResult::Set ( ParseErrorCode  code,
size_t  offset = 0 
)
inline

Update error code and offset.

Definition at line 130 of file error.h.

References offset.

Friends And Related Function Documentation

◆ operator==

bool operator== ( ParseErrorCode  code,
const ParseResult err 
)
friend

Definition at line 125 of file error.h.

Member Data Documentation

◆ code_

ParseErrorCode rapidjson::ParseResult::code_
private

Definition at line 133 of file error.h.

Referenced by operator==().

◆ offset_

size_t rapidjson::ParseResult::offset_
private

Definition at line 134 of file error.h.


The documentation for this struct was generated from the following file:
Modified on Thu May 23 12:26:04 2024 by modify_doxy.py rev. 669887