DeepCover Embedded Security in IoT: Public-key Secured Data Paths

Dependencies:   MaximInterface

Embed: (wiki syntax)

« Back to documentation index

ParseResult Struct Reference

ParseResult Struct Reference
[RapidJSON error handling]

Result of parsing (wraps ParseErrorCode) More...

#include <error.h>

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 bool () const
 Conversion to bool, returns true, iff !IsError().
bool IsError () const
 Whether the result is an error.
void Clear ()
 Reset error code.
void Set (ParseErrorCode code, size_t offset=0)
 Update error code and offset.

Detailed Description

Result of parsing (wraps ParseErrorCode)

        Document doc;
        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 106 of file error.h.


Constructor & Destructor Documentation

ParseResult (  )

Default constructor, no error.

Definition at line 109 of file error.h.

ParseResult ( ParseErrorCode  code,
size_t  offset 
)

Constructor to set an error.

Definition at line 111 of file error.h.


Member Function Documentation

void Clear (  )

Reset error code.

Definition at line 128 of file error.h.

ParseErrorCode Code (  ) const

Get the error code.

Definition at line 114 of file error.h.

bool IsError (  ) const

Whether the result is an error.

Definition at line 121 of file error.h.

size_t Offset (  ) const

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

Definition at line 116 of file error.h.

operator bool (  ) const

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

Definition at line 119 of file error.h.

void Set ( ParseErrorCode  code,
size_t  offset = 0 
)

Update error code and offset.

Definition at line 130 of file error.h.