Open Lighting Architecture 0.10.9
Loading...
Searching...
No Matches
ola::web::SchemaParser Class Reference

Detailed Description

Build the tree of validators and a SchemaDefinitions object from a JSON Schema.

The SchemaParser is an implementation of JsonParserInterface. As the JsonLexer encounters each token, it calls the appropriate method on the SchemaParser. The SchemaParser maintains a stack of contexts, each of which corresponds to a different part of the JSON schema. As objects / arrays are opened / closed, new contexts are added / removed from the context stack.

Inheritance diagram for ola::web::SchemaParser:
ola::web::JsonParserInterface

Public Member Functions

 SchemaParser ()
 Create a new SchemaParser.
 
 ~SchemaParser ()
 Clean up.
 
void Begin ()
 Called when parsing begins.
 
void End ()
 Called when parsing completes.
 
void String (const std::string &value)
 Called when a string is encountered.
 
void Number (uint32_t value)
 Called when a uint32_t is encountered.
 
void Number (int32_t value)
 Called when a int32_t is encountered.
 
void Number (uint64_t value)
 Called when a uint64_t is encountered.
 
void Number (int64_t value)
 Called when a int64_t is encountered.
 
void Number (const JsonDouble::DoubleRepresentation &rep)
 Called when a double value is encountered.
 
void Number (double value)
 Called when a double value is encountered.
 
void Bool (bool value)
 Called when a bool is encountered.
 
void Null ()
 Called when a null token is encountered.
 
void OpenArray ()
 Called when an array starts.
 
void CloseArray ()
 Called when an array completes.
 
void OpenObject ()
 Called when an object starts.
 
void ObjectKey (const std::string &key)
 Called when a new key is encountered.
 
void CloseObject ()
 Called when an object completes.
 
void SetError (const std::string &error)
 Can be called at any time to indicate an error with the input data.
 
bool IsValidSchema ()
 Check if the schema was valid.
 
std::string Error () const
 Get the error message.
 
ValidatorInterfaceClaimRootValidator ()
 Claim the RootValidator that was created by parsing the schema.
 
SchemaDefinitionsClaimSchemaDefs ()
 Claim the SchemaDefinitions that were created by parsing the schema.
 
- Public Member Functions inherited from ola::web::JsonParserInterface

Member Function Documentation

◆ Begin()

void ola::web::SchemaParser::Begin ( )
virtual

Called when parsing begins.

Implements ola::web::JsonParserInterface.

◆ Bool()

void ola::web::SchemaParser::Bool ( bool value)
virtual

Called when a bool is encountered.

Implements ola::web::JsonParserInterface.

◆ ClaimRootValidator()

ValidatorInterface * ola::web::SchemaParser::ClaimRootValidator ( )

Claim the RootValidator that was created by parsing the schema.

Returns
A new Validator, or NULL if the schema wasn't valid. Ownership of the validtor is transferred to the caller.

◆ ClaimSchemaDefs()

SchemaDefinitions * ola::web::SchemaParser::ClaimSchemaDefs ( )

Claim the SchemaDefinitions that were created by parsing the schema.

Returns
A SchemaDefinitions object, or NULL if the schema wasn't valid. Ownership of the SchemaDefinitions is transferred to the caller.

◆ CloseArray()

void ola::web::SchemaParser::CloseArray ( )
virtual

Called when an array completes.

Implements ola::web::JsonParserInterface.

◆ CloseObject()

void ola::web::SchemaParser::CloseObject ( )
virtual

Called when an object completes.

Implements ola::web::JsonParserInterface.

◆ End()

void ola::web::SchemaParser::End ( )
virtual

Called when parsing completes.

Implements ola::web::JsonParserInterface.

◆ IsValidSchema()

bool ola::web::SchemaParser::IsValidSchema ( )

Check if the schema was valid.

Returns
true if the schema was valid, false otherwise.

◆ Null()

void ola::web::SchemaParser::Null ( )
virtual

Called when a null token is encountered.

Implements ola::web::JsonParserInterface.

◆ Number() [1/6]

void ola::web::SchemaParser::Number ( const JsonDouble::DoubleRepresentation & rep)
virtual

Called when a double value is encountered.

MinGW struggles with long doubles http://mingw.5.n7.nabble.com/Strange-behaviour-of-gcc-4-8-1-with-long-double-td32949.html To avoid this, and to keep as many significant bits as possible we keep the components of a double separate. See JsonDouble for details.

Implements ola::web::JsonParserInterface.

◆ Number() [2/6]

void ola::web::SchemaParser::Number ( double d)
virtual

Called when a double value is encountered.

Implements ola::web::JsonParserInterface.

◆ Number() [3/6]

void ola::web::SchemaParser::Number ( int32_t value)
virtual

Called when a int32_t is encountered.

Implements ola::web::JsonParserInterface.

◆ Number() [4/6]

void ola::web::SchemaParser::Number ( int64_t value)
virtual

Called when a int64_t is encountered.

Implements ola::web::JsonParserInterface.

◆ Number() [5/6]

void ola::web::SchemaParser::Number ( uint32_t value)
virtual

Called when a uint32_t is encountered.

Implements ola::web::JsonParserInterface.

◆ Number() [6/6]

void ola::web::SchemaParser::Number ( uint64_t value)
virtual

Called when a uint64_t is encountered.

Implements ola::web::JsonParserInterface.

◆ ObjectKey()

void ola::web::SchemaParser::ObjectKey ( const std::string & key)
virtual

Called when a new key is encountered.

This may be called multiple times for the same object. The standard doesn't specify how to handle duplicate keys, so I generally use the last one.

Implements ola::web::JsonParserInterface.

◆ OpenArray()

void ola::web::SchemaParser::OpenArray ( )
virtual

Called when an array starts.

Implements ola::web::JsonParserInterface.

◆ OpenObject()

void ola::web::SchemaParser::OpenObject ( )
virtual

Called when an object starts.

Implements ola::web::JsonParserInterface.

◆ SetError()

void ola::web::SchemaParser::SetError ( const std::string & error)
virtual

Can be called at any time to indicate an error with the input data.

Implements ola::web::JsonParserInterface.

◆ String()

void ola::web::SchemaParser::String ( const std::string & value)
virtual

Called when a string is encountered.

This is not called for object keys, see ObjectKey() below.

Implements ola::web::JsonParserInterface.


The documentation for this class was generated from the following files: