Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
ParseResult Struct Reference

Result of parsing (wraps ParseErrorCode) More...

#include <error.h>

Public Types

typedef bool(ParseResult::*) BooleanType() const
 ! Unspecified boolean type
 

Public Member Functions

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

Friends

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

Detailed Description

ParseResult ok = doc.Parse("[42]");
if (!ok) {
fprintf(stderr, "JSON parse error: %s (%u)",
GetParseError_En(ok.Code()), ok.Offset());
exit(EXIT_FAILURE);
}
GenericDocument & Parse(const typename SourceEncoding::Ch *str)
Parse JSON text from a read-only string (with Encoding conversion)
Definition document.h:2325
RAPIDJSON_NAMESPACE_BEGIN const RAPIDJSON_ERROR_CHARTYPE * GetParseError_En(ParseErrorCode parseErrorCode)
Maps error code of parsing into error message.
Definition en.h:36
Result of parsing (wraps ParseErrorCode)
Definition error.h:106
See also
GenericReader::Parse, GenericDocument::Parse

Definition at line 106 of file error.h.

Member Typedef Documentation

◆ BooleanType

bool(ParseResult::*) ParseResult::BooleanType() const

Definition at line 108 of file error.h.

Constructor & Destructor Documentation

◆ ParseResult() [1/2]

ParseResult::ParseResult ( )
inline

Definition at line 111 of file error.h.

111: code_(kParseErrorNone), offset_(0) {}
@ kParseErrorNone
No error.
Definition error.h:65

◆ ParseResult() [2/2]

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

Definition at line 113 of file error.h.

113: code_(code), offset_(offset) {}

Member Function Documentation

◆ Clear()

void ParseResult::Clear ( )
inline

Definition at line 134 of file error.h.

void Set(ParseErrorCode code, size_t offset=0)
Update error code and offset.
Definition error.h:136
Here is the call graph for this function:
Here is the caller graph for this function:

◆ Code()

ParseErrorCode ParseResult::Code ( ) const
inline

Definition at line 116 of file error.h.

116{ return code_; }
Here is the caller graph for this function:

◆ IsError()

bool ParseResult::IsError ( ) const
inline

Definition at line 123 of file error.h.

123{ return code_ != kParseErrorNone; }
Here is the caller graph for this function:

◆ Offset()

size_t ParseResult::Offset ( ) const
inline

Definition at line 118 of file error.h.

118{ return offset_; }
Here is the caller graph for this function:

◆ operator BooleanType()

ParseResult::operator BooleanType ( ) const
inline

Definition at line 121 of file error.h.

121{ return !IsError() ? &ParseResult::IsError : NULL; }
bool IsError() const
Whether the result is an error.
Definition error.h:123
Here is the call graph for this function:

◆ operator!=() [1/2]

bool ParseResult::operator!= ( const ParseResult & that) const
inline

Definition at line 129 of file error.h.

129{ return !(*this == that); }

◆ operator!=() [2/2]

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

Definition at line 130 of file error.h.

130{ return !(*this == code); }

◆ operator==() [1/2]

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

Definition at line 125 of file error.h.

125{ return code_ == that.code_; }

◆ operator==() [2/2]

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

Definition at line 126 of file error.h.

126{ return code_ == code; }

◆ Set()

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

Definition at line 136 of file error.h.

136{ code_ = code; offset_ = offset; }
Here is the caller graph for this function:

Friends And Related Symbol Documentation

◆ operator!=

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

Definition at line 131 of file error.h.

131{ return err != code; }

◆ operator==

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

Definition at line 127 of file error.h.

127{ return code == err.code_; }

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