All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Public Member Functions | Private Attributes | Friends | List of all members
rapidjson::ParseResult Struct Reference

Result of parsing (wraps ParseErrorCode) More...

#include <error.h>

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());
exit(EXIT_FAILURE);
}
See also
GenericReader::Parse, GenericDocument::Parse

Definition at line 105 of file error.h.

Constructor & Destructor Documentation

rapidjson::ParseResult::ParseResult ( )
inline

Default constructor, no error.

Definition at line 108 of file error.h.

108 : code_(kParseErrorNone), offset_(0) {}
ParseErrorCode code_
Definition: error.h:132
rapidjson::ParseResult::ParseResult ( ParseErrorCode  code,
size_t  offset 
)
inline

Constructor to set an error.

Definition at line 110 of file error.h.

110 : code_(code), offset_(offset) {}
ParseErrorCode code_
Definition: error.h:132

Member Function Documentation

void rapidjson::ParseResult::Clear ( )
inline

Reset error code.

Definition at line 127 of file error.h.

127 { Set(kParseErrorNone); }
void Set(ParseErrorCode code, size_t offset=0)
Update error code and offset.
Definition: error.h:129
ParseErrorCode rapidjson::ParseResult::Code ( ) const
inline

Get the error code.

Definition at line 113 of file error.h.

113 { return code_; }
ParseErrorCode code_
Definition: error.h:132
bool rapidjson::ParseResult::IsError ( ) const
inline

Whether the result is an error.

Definition at line 120 of file error.h.

120 { return code_ != kParseErrorNone; }
ParseErrorCode code_
Definition: error.h:132
size_t rapidjson::ParseResult::Offset ( ) const
inline

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

Definition at line 115 of file error.h.

115 { return offset_; }
rapidjson::ParseResult::operator bool ( ) const
inline

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

Definition at line 118 of file error.h.

118 { return !IsError(); }
bool IsError() const
Whether the result is an error.
Definition: error.h:120
bool rapidjson::ParseResult::operator== ( const ParseResult that) const
inline

Definition at line 122 of file error.h.

122 { return code_ == that.code_; }
ParseErrorCode code_
Definition: error.h:132
bool rapidjson::ParseResult::operator== ( ParseErrorCode  code) const
inline

Definition at line 123 of file error.h.

123 { return code_ == code; }
ParseErrorCode code_
Definition: error.h:132
void rapidjson::ParseResult::Set ( ParseErrorCode  code,
size_t  offset = 0 
)
inline

Update error code and offset.

Definition at line 129 of file error.h.

129 { code_ = code; offset_ = offset; }
ParseErrorCode code_
Definition: error.h:132

Friends And Related Function Documentation

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

Definition at line 124 of file error.h.

124 { return code == err.code_; }

Member Data Documentation

ParseErrorCode rapidjson::ParseResult::code_
private

Definition at line 132 of file error.h.

size_t rapidjson::ParseResult::offset_
private

Definition at line 133 of file error.h.


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