cphot 0.1
A C++ tool for computing photometry from spectra.
GenericSchemaValidator< SchemaDocumentType, OutputHandler, StateAllocator > Class Template Reference

JSON Schema Validator. More...

#include <fwd.h>

Public Types

typedef SchemaDocumentType::SchemaType SchemaType
 
typedef SchemaDocumentType::PointerType PointerType
 
typedef SchemaType::EncodingType EncodingType
 
typedef EncodingType::Ch Ch
 

Public Member Functions

 GenericSchemaValidator (const SchemaDocumentType &schemaDocument, StateAllocator *allocator=0, size_t schemaStackCapacity=kDefaultSchemaStackCapacity, size_t documentStackCapacity=kDefaultDocumentStackCapacity)
 Constructor without output handler. More...
 
 GenericSchemaValidator (const SchemaDocumentType &schemaDocument, OutputHandler &outputHandler, StateAllocator *allocator=0, size_t schemaStackCapacity=kDefaultSchemaStackCapacity, size_t documentStackCapacity=kDefaultDocumentStackCapacity)
 Constructor with output handler. More...
 
 ~GenericSchemaValidator ()
 Destructor. More...
 
void Reset ()
 Reset the internal states. More...
 
virtual bool IsValid () const
 Checks whether the current state is valid. More...
 
PointerType GetInvalidSchemaPointer () const
 Gets the JSON pointer pointed to the invalid schema. More...
 
const ChGetInvalidSchemaKeyword () const
 Gets the keyword of invalid schema. More...
 
PointerType GetInvalidDocumentPointer () const
 Gets the JSON pointer pointed to the invalid value. More...
 
bool Null ()
 
bool Bool (bool b)
 
bool Int (int i)
 
bool Uint (unsigned u)
 
bool Int64 (int64_t i)
 
bool Uint64 (uint64_t u)
 
bool Double (double d)
 
bool RawNumber (const Ch *str, SizeType length, bool copy)
 
bool String (const Ch *str, SizeType length, bool copy)
 
bool StartObject ()
 
bool Key (const Ch *str, SizeType len, bool copy)
 
bool EndObject (SizeType memberCount)
 
bool StartArray ()
 
bool EndArray (SizeType elementCount)
 
virtual ISchemaValidator * CreateSchemaValidator (const SchemaType &root)
 
virtual void DestroySchemaValidator (ISchemaValidator *validator)
 
virtual void * CreateHasher ()
 
virtual uint64_t GetHashCode (void *hasher)
 
virtual void DestroryHasher (void *hasher)
 
virtual void * MallocState (size_t size)
 
virtual void FreeState (void *p)
 

Detailed Description

template<typename SchemaDocumentType, typename OutputHandler = BaseReaderHandler<typename SchemaDocumentType::SchemaType::EncodingType>, typename StateAllocator = CrtAllocator>
class GenericSchemaValidator< SchemaDocumentType, OutputHandler, StateAllocator >

JSON Schema Validator.

A SAX style JSON schema validator. It uses a GenericSchemaDocument to validate SAX events. It delegates the incoming SAX events to an output handler. The default output handler does nothing. It can be reused multiple times by calling Reset().

Template Parameters
SchemaDocumentTypeType of schema document.
OutputHandlerType of output handler. Default handler does nothing.
StateAllocatorAllocator for storing the internal validation states.

Definition at line 145 of file fwd.h.

Member Typedef Documentation

◆ Ch

template<typename SchemaDocumentType , typename OutputHandler = BaseReaderHandler<typename SchemaDocumentType::SchemaType::EncodingType>, typename StateAllocator = CrtAllocator>
typedef EncodingType::Ch GenericSchemaValidator< SchemaDocumentType, OutputHandler, StateAllocator >::Ch

Definition at line 1561 of file schema.h.

◆ EncodingType

template<typename SchemaDocumentType , typename OutputHandler = BaseReaderHandler<typename SchemaDocumentType::SchemaType::EncodingType>, typename StateAllocator = CrtAllocator>
typedef SchemaType::EncodingType GenericSchemaValidator< SchemaDocumentType, OutputHandler, StateAllocator >::EncodingType

Definition at line 1560 of file schema.h.

◆ PointerType

template<typename SchemaDocumentType , typename OutputHandler = BaseReaderHandler<typename SchemaDocumentType::SchemaType::EncodingType>, typename StateAllocator = CrtAllocator>
typedef SchemaDocumentType::PointerType GenericSchemaValidator< SchemaDocumentType, OutputHandler, StateAllocator >::PointerType

Definition at line 1559 of file schema.h.

◆ SchemaType

template<typename SchemaDocumentType , typename OutputHandler = BaseReaderHandler<typename SchemaDocumentType::SchemaType::EncodingType>, typename StateAllocator = CrtAllocator>
typedef SchemaDocumentType::SchemaType GenericSchemaValidator< SchemaDocumentType, OutputHandler, StateAllocator >::SchemaType

Definition at line 1558 of file schema.h.

Constructor & Destructor Documentation

◆ GenericSchemaValidator() [1/2]

template<typename SchemaDocumentType , typename OutputHandler = BaseReaderHandler<typename SchemaDocumentType::SchemaType::EncodingType>, typename StateAllocator = CrtAllocator>
GenericSchemaValidator< SchemaDocumentType, OutputHandler, StateAllocator >::GenericSchemaValidator ( const SchemaDocumentType &  schemaDocument,
StateAllocator *  allocator = 0,
size_t  schemaStackCapacity = kDefaultSchemaStackCapacity,
size_t  documentStackCapacity = kDefaultDocumentStackCapacity 
)
inline

Constructor without output handler.

Parameters
schemaDocumentThe schema document to conform to.
allocatorOptional allocator for storing internal validation states.
schemaStackCapacityOptional initial capacity of schema path stack.
documentStackCapacityOptional initial capacity of document path stack.

Definition at line 1570 of file schema.h.

◆ GenericSchemaValidator() [2/2]

template<typename SchemaDocumentType , typename OutputHandler = BaseReaderHandler<typename SchemaDocumentType::SchemaType::EncodingType>, typename StateAllocator = CrtAllocator>
GenericSchemaValidator< SchemaDocumentType, OutputHandler, StateAllocator >::GenericSchemaValidator ( const SchemaDocumentType &  schemaDocument,
OutputHandler &  outputHandler,
StateAllocator *  allocator = 0,
size_t  schemaStackCapacity = kDefaultSchemaStackCapacity,
size_t  documentStackCapacity = kDefaultDocumentStackCapacity 
)
inline

Constructor with output handler.

Parameters
schemaDocumentThe schema document to conform to.
allocatorOptional allocator for storing internal validation states.
schemaStackCapacityOptional initial capacity of schema path stack.
documentStackCapacityOptional initial capacity of document path stack.

Definition at line 1597 of file schema.h.

◆ ~GenericSchemaValidator()

template<typename SchemaDocumentType , typename OutputHandler = BaseReaderHandler<typename SchemaDocumentType::SchemaType::EncodingType>, typename StateAllocator = CrtAllocator>
GenericSchemaValidator< SchemaDocumentType, OutputHandler, StateAllocator >::~GenericSchemaValidator ( )
inline

Destructor.

Definition at line 1619 of file schema.h.

Member Function Documentation

◆ Bool()

template<typename SchemaDocumentType , typename OutputHandler = BaseReaderHandler<typename SchemaDocumentType::SchemaType::EncodingType>, typename StateAllocator = CrtAllocator>
bool GenericSchemaValidator< SchemaDocumentType, OutputHandler, StateAllocator >::Bool ( bool  b)
inline

Definition at line 1690 of file schema.h.

◆ CreateHasher()

template<typename SchemaDocumentType , typename OutputHandler = BaseReaderHandler<typename SchemaDocumentType::SchemaType::EncodingType>, typename StateAllocator = CrtAllocator>
virtual void* GenericSchemaValidator< SchemaDocumentType, OutputHandler, StateAllocator >::CreateHasher ( )
inlinevirtual

Definition at line 1755 of file schema.h.

◆ CreateSchemaValidator()

template<typename SchemaDocumentType , typename OutputHandler = BaseReaderHandler<typename SchemaDocumentType::SchemaType::EncodingType>, typename StateAllocator = CrtAllocator>
virtual ISchemaValidator* GenericSchemaValidator< SchemaDocumentType, OutputHandler, StateAllocator >::CreateSchemaValidator ( const SchemaType root)
inlinevirtual

Definition at line 1741 of file schema.h.

◆ DestroryHasher()

template<typename SchemaDocumentType , typename OutputHandler = BaseReaderHandler<typename SchemaDocumentType::SchemaType::EncodingType>, typename StateAllocator = CrtAllocator>
virtual void GenericSchemaValidator< SchemaDocumentType, OutputHandler, StateAllocator >::DestroryHasher ( void *  hasher)
inlinevirtual

Definition at line 1763 of file schema.h.

◆ DestroySchemaValidator()

template<typename SchemaDocumentType , typename OutputHandler = BaseReaderHandler<typename SchemaDocumentType::SchemaType::EncodingType>, typename StateAllocator = CrtAllocator>
virtual void GenericSchemaValidator< SchemaDocumentType, OutputHandler, StateAllocator >::DestroySchemaValidator ( ISchemaValidator *  validator)
inlinevirtual

Definition at line 1749 of file schema.h.

◆ Double()

template<typename SchemaDocumentType , typename OutputHandler = BaseReaderHandler<typename SchemaDocumentType::SchemaType::EncodingType>, typename StateAllocator = CrtAllocator>
bool GenericSchemaValidator< SchemaDocumentType, OutputHandler, StateAllocator >::Double ( double  d)
inline

Definition at line 1695 of file schema.h.

◆ EndArray()

template<typename SchemaDocumentType , typename OutputHandler = BaseReaderHandler<typename SchemaDocumentType::SchemaType::EncodingType>, typename StateAllocator = CrtAllocator>
bool GenericSchemaValidator< SchemaDocumentType, OutputHandler, StateAllocator >::EndArray ( SizeType  elementCount)
inline

Definition at line 1728 of file schema.h.

◆ EndObject()

template<typename SchemaDocumentType , typename OutputHandler = BaseReaderHandler<typename SchemaDocumentType::SchemaType::EncodingType>, typename StateAllocator = CrtAllocator>
bool GenericSchemaValidator< SchemaDocumentType, OutputHandler, StateAllocator >::EndObject ( SizeType  memberCount)
inline

Definition at line 1715 of file schema.h.

◆ FreeState()

template<typename SchemaDocumentType , typename OutputHandler = BaseReaderHandler<typename SchemaDocumentType::SchemaType::EncodingType>, typename StateAllocator = CrtAllocator>
virtual void GenericSchemaValidator< SchemaDocumentType, OutputHandler, StateAllocator >::FreeState ( void *  p)
inlinevirtual

Definition at line 1773 of file schema.h.

◆ GetHashCode()

template<typename SchemaDocumentType , typename OutputHandler = BaseReaderHandler<typename SchemaDocumentType::SchemaType::EncodingType>, typename StateAllocator = CrtAllocator>
virtual uint64_t GenericSchemaValidator< SchemaDocumentType, OutputHandler, StateAllocator >::GetHashCode ( void *  hasher)
inlinevirtual

Definition at line 1759 of file schema.h.

◆ GetInvalidDocumentPointer()

template<typename SchemaDocumentType , typename OutputHandler = BaseReaderHandler<typename SchemaDocumentType::SchemaType::EncodingType>, typename StateAllocator = CrtAllocator>
PointerType GenericSchemaValidator< SchemaDocumentType, OutputHandler, StateAllocator >::GetInvalidDocumentPointer ( ) const
inline

Gets the JSON pointer pointed to the invalid value.

Definition at line 1647 of file schema.h.

◆ GetInvalidSchemaKeyword()

template<typename SchemaDocumentType , typename OutputHandler = BaseReaderHandler<typename SchemaDocumentType::SchemaType::EncodingType>, typename StateAllocator = CrtAllocator>
const Ch* GenericSchemaValidator< SchemaDocumentType, OutputHandler, StateAllocator >::GetInvalidSchemaKeyword ( ) const
inline

Gets the keyword of invalid schema.

Definition at line 1642 of file schema.h.

◆ GetInvalidSchemaPointer()

template<typename SchemaDocumentType , typename OutputHandler = BaseReaderHandler<typename SchemaDocumentType::SchemaType::EncodingType>, typename StateAllocator = CrtAllocator>
PointerType GenericSchemaValidator< SchemaDocumentType, OutputHandler, StateAllocator >::GetInvalidSchemaPointer ( ) const
inline

Gets the JSON pointer pointed to the invalid schema.

Definition at line 1637 of file schema.h.

◆ Int()

template<typename SchemaDocumentType , typename OutputHandler = BaseReaderHandler<typename SchemaDocumentType::SchemaType::EncodingType>, typename StateAllocator = CrtAllocator>
bool GenericSchemaValidator< SchemaDocumentType, OutputHandler, StateAllocator >::Int ( int  i)
inline

Definition at line 1691 of file schema.h.

◆ Int64()

template<typename SchemaDocumentType , typename OutputHandler = BaseReaderHandler<typename SchemaDocumentType::SchemaType::EncodingType>, typename StateAllocator = CrtAllocator>
bool GenericSchemaValidator< SchemaDocumentType, OutputHandler, StateAllocator >::Int64 ( int64_t  i)
inline

Definition at line 1693 of file schema.h.

◆ IsValid()

template<typename SchemaDocumentType , typename OutputHandler = BaseReaderHandler<typename SchemaDocumentType::SchemaType::EncodingType>, typename StateAllocator = CrtAllocator>
virtual bool GenericSchemaValidator< SchemaDocumentType, OutputHandler, StateAllocator >::IsValid ( ) const
inlinevirtual

Checks whether the current state is valid.

Definition at line 1634 of file schema.h.

◆ Key()

template<typename SchemaDocumentType , typename OutputHandler = BaseReaderHandler<typename SchemaDocumentType::SchemaType::EncodingType>, typename StateAllocator = CrtAllocator>
bool GenericSchemaValidator< SchemaDocumentType, OutputHandler, StateAllocator >::Key ( const Ch str,
SizeType  len,
bool  copy 
)
inline

Definition at line 1707 of file schema.h.

◆ MallocState()

template<typename SchemaDocumentType , typename OutputHandler = BaseReaderHandler<typename SchemaDocumentType::SchemaType::EncodingType>, typename StateAllocator = CrtAllocator>
virtual void* GenericSchemaValidator< SchemaDocumentType, OutputHandler, StateAllocator >::MallocState ( size_t  size)
inlinevirtual

Definition at line 1769 of file schema.h.

◆ Null()

template<typename SchemaDocumentType , typename OutputHandler = BaseReaderHandler<typename SchemaDocumentType::SchemaType::EncodingType>, typename StateAllocator = CrtAllocator>
bool GenericSchemaValidator< SchemaDocumentType, OutputHandler, StateAllocator >::Null ( )
inline

Definition at line 1689 of file schema.h.

◆ RawNumber()

template<typename SchemaDocumentType , typename OutputHandler = BaseReaderHandler<typename SchemaDocumentType::SchemaType::EncodingType>, typename StateAllocator = CrtAllocator>
bool GenericSchemaValidator< SchemaDocumentType, OutputHandler, StateAllocator >::RawNumber ( const Ch str,
SizeType  length,
bool  copy 
)
inline

Definition at line 1696 of file schema.h.

◆ Reset()

template<typename SchemaDocumentType , typename OutputHandler = BaseReaderHandler<typename SchemaDocumentType::SchemaType::EncodingType>, typename StateAllocator = CrtAllocator>
void GenericSchemaValidator< SchemaDocumentType, OutputHandler, StateAllocator >::Reset ( )
inline

Reset the internal states.

Definition at line 1625 of file schema.h.

◆ StartArray()

template<typename SchemaDocumentType , typename OutputHandler = BaseReaderHandler<typename SchemaDocumentType::SchemaType::EncodingType>, typename StateAllocator = CrtAllocator>
bool GenericSchemaValidator< SchemaDocumentType, OutputHandler, StateAllocator >::StartArray ( )
inline

Definition at line 1722 of file schema.h.

◆ StartObject()

template<typename SchemaDocumentType , typename OutputHandler = BaseReaderHandler<typename SchemaDocumentType::SchemaType::EncodingType>, typename StateAllocator = CrtAllocator>
bool GenericSchemaValidator< SchemaDocumentType, OutputHandler, StateAllocator >::StartObject ( )
inline

Definition at line 1701 of file schema.h.

◆ String()

template<typename SchemaDocumentType , typename OutputHandler = BaseReaderHandler<typename SchemaDocumentType::SchemaType::EncodingType>, typename StateAllocator = CrtAllocator>
bool GenericSchemaValidator< SchemaDocumentType, OutputHandler, StateAllocator >::String ( const Ch str,
SizeType  length,
bool  copy 
)
inline

Definition at line 1698 of file schema.h.

◆ Uint()

template<typename SchemaDocumentType , typename OutputHandler = BaseReaderHandler<typename SchemaDocumentType::SchemaType::EncodingType>, typename StateAllocator = CrtAllocator>
bool GenericSchemaValidator< SchemaDocumentType, OutputHandler, StateAllocator >::Uint ( unsigned  u)
inline

Definition at line 1692 of file schema.h.

◆ Uint64()

template<typename SchemaDocumentType , typename OutputHandler = BaseReaderHandler<typename SchemaDocumentType::SchemaType::EncodingType>, typename StateAllocator = CrtAllocator>
bool GenericSchemaValidator< SchemaDocumentType, OutputHandler, StateAllocator >::Uint64 ( uint64_t  u)
inline

Definition at line 1694 of file schema.h.


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