TrinityCore
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
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)",
exit(EXIT_FAILURE);
}
See also
GenericReader::Parse, GenericDocument::Parse

Constructor & Destructor Documentation

ParseResult::ParseResult ( )
inline

Default constructor, no error.

104 : code_(kParseErrorNone), offset_(0) {}
No error.
Definition: error.h:60
ParseErrorCode code_
Definition: error.h:128
size_t offset_
Definition: error.h:129
ParseResult::ParseResult ( ParseErrorCode  code,
size_t  offset 
)
inline

Constructor to set an error.

106 : code_(code), offset_(offset) {}
ParseErrorCode code_
Definition: error.h:128
Definition: inftrees.h:24
size_t offset_
Definition: error.h:129

Member Function Documentation

void ParseResult::Clear ( )
inline

Reset error code.

123 { Set(kParseErrorNone); }
No error.
Definition: error.h:60
void Set(ParseErrorCode code, size_t offset=0)
Update error code and offset.
Definition: error.h:125

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

ParseErrorCode ParseResult::Code ( ) const
inline

Get the error code.

109 { return code_; }
ParseErrorCode code_
Definition: error.h:128

+ Here is the caller graph for this function:

bool ParseResult::IsError ( ) const
inline

Whether the result is an error.

116 { return code_ != kParseErrorNone; }
No error.
Definition: error.h:60
ParseErrorCode code_
Definition: error.h:128

+ Here is the caller graph for this function:

size_t ParseResult::Offset ( ) const
inline

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

111 { return offset_; }
size_t offset_
Definition: error.h:129

+ Here is the caller graph for this function:

ParseResult::operator bool ( ) const
inline

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

114 { return !IsError(); }
bool IsError() const
Whether the result is an error.
Definition: error.h:116

+ Here is the call graph for this function:

bool ParseResult::operator== ( const ParseResult that) const
inline
118 { return code_ == that.code_; }
ParseErrorCode code_
Definition: error.h:128
bool ParseResult::operator== ( ParseErrorCode  code) const
inline
119 { return code_ == code; }
ParseErrorCode code_
Definition: error.h:128
Definition: inftrees.h:24
void ParseResult::Set ( ParseErrorCode  code,
size_t  offset = 0 
)
inline

Update error code and offset.

125 { code_ = code; offset_ = offset; }
ParseErrorCode code_
Definition: error.h:128
Definition: inftrees.h:24
size_t offset_
Definition: error.h:129

+ Here is the caller graph for this function:

Friends And Related Function Documentation

bool operator== ( ParseErrorCode  code,
const ParseResult err 
)
friend
120 { return code == err.code_; }
ParseErrorCode code_
Definition: error.h:128
Definition: inftrees.h:24

Member Data Documentation

ParseErrorCode ParseResult::code_
private
size_t ParseResult::offset_
private

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