JSON Schema Validator. More...
#include <fwd.h>
Public Types | |
typedef SchemaDocumentType::SchemaType | SchemaType |
typedef SchemaDocumentType::PointerType | PointerType |
typedef SchemaType::EncodingType | EncodingType |
typedef SchemaType::SValue | SValue |
typedef EncodingType::Ch | Ch |
typedef GenericStringRef< Ch > | StringRefType |
typedef GenericValue< EncodingType, StateAllocator > | ValueType |
Public Types inherited from internal::IValidationErrorHandler< SchemaDocumentType::SchemaType > | |
typedef SchemaDocumentType::SchemaType::Ch | Ch |
typedef SchemaDocumentType::SchemaType::SValue | SValue |
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... | |
ValueType & | GetError () |
Gets the error object. More... | |
const ValueType & | GetError () const |
PointerType | GetInvalidSchemaPointer () const |
Gets the JSON pointer pointed to the invalid schema. More... | |
const Ch * | GetInvalidSchemaKeyword () const |
Gets the keyword of invalid schema. More... | |
PointerType | GetInvalidDocumentPointer () const |
Gets the JSON pointer pointed to the invalid value. More... | |
void | NotMultipleOf (int64_t actual, const SValue &expected) |
void | NotMultipleOf (uint64_t actual, const SValue &expected) |
void | NotMultipleOf (double actual, const SValue &expected) |
void | AboveMaximum (int64_t actual, const SValue &expected, bool exclusive) |
void | AboveMaximum (uint64_t actual, const SValue &expected, bool exclusive) |
void | AboveMaximum (double actual, const SValue &expected, bool exclusive) |
void | BelowMinimum (int64_t actual, const SValue &expected, bool exclusive) |
void | BelowMinimum (uint64_t actual, const SValue &expected, bool exclusive) |
void | BelowMinimum (double actual, const SValue &expected, bool exclusive) |
void | TooLong (const Ch *str, SizeType length, SizeType expected) |
void | TooShort (const Ch *str, SizeType length, SizeType expected) |
void | DoesNotMatch (const Ch *str, SizeType length) |
void | DisallowedItem (SizeType index) |
void | TooFewItems (SizeType actualCount, SizeType expectedCount) |
void | TooManyItems (SizeType actualCount, SizeType expectedCount) |
void | DuplicateItems (SizeType index1, SizeType index2) |
void | TooManyProperties (SizeType actualCount, SizeType expectedCount) |
void | TooFewProperties (SizeType actualCount, SizeType expectedCount) |
void | StartMissingProperties () |
void | AddMissingProperty (const SValue &name) |
bool | EndMissingProperties () |
void | PropertyViolations (ISchemaValidator **subvalidators, SizeType count) |
void | DisallowedProperty (const Ch *name, SizeType length) |
void | StartDependencyErrors () |
void | StartMissingDependentProperties () |
void | AddMissingDependentProperty (const SValue &targetName) |
void | EndMissingDependentProperties (const SValue &sourceName) |
void | AddDependencySchemaError (const SValue &sourceName, ISchemaValidator *subvalidator) |
bool | EndDependencyErrors () |
void | DisallowedValue () |
void | StartDisallowedType () |
void | AddExpectedType (const typename SchemaType::ValueType &expectedType) |
void | EndDisallowedType (const typename SchemaType::ValueType &actualType) |
void | NotAllOf (ISchemaValidator **subvalidators, SizeType count) |
void | NoneOf (ISchemaValidator **subvalidators, SizeType count) |
void | NotOneOf (ISchemaValidator **subvalidators, SizeType count) |
void | Disallowed () |
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) |
Public Member Functions inherited from internal::ISchemaStateFactory< SchemaDocumentType::SchemaType > | |
virtual | ~ISchemaStateFactory () |
virtual void | DestroySchemaValidator (ISchemaValidator *validator)=0 |
Public Member Functions inherited from internal::ISchemaValidator | |
virtual | ~ISchemaValidator () |
Public Member Functions inherited from internal::IValidationErrorHandler< SchemaDocumentType::SchemaType > | |
virtual | ~IValidationErrorHandler () |
virtual void | NotMultipleOf (int64_t actual, const SValue &expected)=0 |
virtual void | NotMultipleOf (uint64_t actual, const SValue &expected)=0 |
virtual void | NotMultipleOf (double actual, const SValue &expected)=0 |
virtual void | AboveMaximum (int64_t actual, const SValue &expected, bool exclusive)=0 |
virtual void | AboveMaximum (uint64_t actual, const SValue &expected, bool exclusive)=0 |
virtual void | AboveMaximum (double actual, const SValue &expected, bool exclusive)=0 |
virtual void | BelowMinimum (int64_t actual, const SValue &expected, bool exclusive)=0 |
virtual void | BelowMinimum (uint64_t actual, const SValue &expected, bool exclusive)=0 |
virtual void | BelowMinimum (double actual, const SValue &expected, bool exclusive)=0 |
virtual void | TooLong (const Ch *str, SizeType length, SizeType expected)=0 |
virtual void | TooShort (const Ch *str, SizeType length, SizeType expected)=0 |
virtual void | DoesNotMatch (const Ch *str, SizeType length)=0 |
virtual void | AddMissingProperty (const SValue &name)=0 |
virtual void | PropertyViolations (ISchemaValidator **subvalidators, SizeType count)=0 |
virtual void | DisallowedProperty (const Ch *name, SizeType length)=0 |
virtual void | AddMissingDependentProperty (const SValue &targetName)=0 |
virtual void | EndMissingDependentProperties (const SValue &sourceName)=0 |
virtual void | AddDependencySchemaError (const SValue &souceName, ISchemaValidator *subvalidator)=0 |
virtual void | AddExpectedType (const typename SchemaDocumentType::SchemaType::ValueType &expectedType)=0 |
virtual void | EndDisallowedType (const typename SchemaDocumentType::SchemaType::ValueType &actualType)=0 |
virtual void | NotAllOf (ISchemaValidator **subvalidators, SizeType count)=0 |
virtual void | NoneOf (ISchemaValidator **subvalidators, SizeType count)=0 |
virtual void | NotOneOf (ISchemaValidator **subvalidators, SizeType count)=0 |
Private Types | |
typedef SchemaType::Context | Context |
typedef GenericValue< UTF8<>, StateAllocator > | HashCodeArray |
typedef internal::Hasher< EncodingType, StateAllocator > | HasherType |
Private Member Functions | |
GenericSchemaValidator (const SchemaDocumentType &schemaDocument, const SchemaType &root, const char *basePath, size_t basePathSize, StateAllocator *allocator=0, size_t schemaStackCapacity=kDefaultSchemaStackCapacity, size_t documentStackCapacity=kDefaultDocumentStackCapacity) | |
StateAllocator & | GetStateAllocator () |
bool | BeginValue () |
bool | EndValue () |
void | AppendToken (const Ch *str, SizeType len) |
RAPIDJSON_FORCEINLINE void | PushSchema (const SchemaType &schema) |
RAPIDJSON_FORCEINLINE void | PopSchema () |
void | AddErrorLocation (ValueType &result, bool parent) |
void | AddError (ValueType &keyword, ValueType &error) |
void | AddCurrentError (const typename SchemaType::ValueType &keyword, bool parent=false) |
void | MergeError (ValueType &other) |
void | AddNumberError (const typename SchemaType::ValueType &keyword, ValueType &actual, const SValue &expected, const typename SchemaType::ValueType &(*exclusive)()=0) |
void | AddErrorArray (const typename SchemaType::ValueType &keyword, ISchemaValidator **subvalidators, SizeType count) |
const SchemaType & | CurrentSchema () const |
Context & | CurrentContext () |
const Context & | CurrentContext () const |
Private Attributes | |
const SchemaDocumentType * | schemaDocument_ |
const SchemaType & | root_ |
StateAllocator * | stateAllocator_ |
StateAllocator * | ownStateAllocator_ |
internal::Stack< StateAllocator > | schemaStack_ |
stack to store the current path of schema (BaseSchemaType *) More... | |
internal::Stack< StateAllocator > | documentStack_ |
stack to store the current path of validating document (Ch) More... | |
OutputHandler * | outputHandler_ |
ValueType | error_ |
ValueType | currentError_ |
ValueType | missingDependents_ |
bool | valid_ |
Static Private Attributes | |
static const size_t | kDefaultSchemaStackCapacity = 1024 |
static const size_t | kDefaultDocumentStackCapacity = 256 |
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()
.
SchemaDocumentType | Type of schema document. |
OutputHandler | Type of output handler. Default handler does nothing. |
StateAllocator | Allocator for storing the internal validation states. |
typedef EncodingType::Ch GenericSchemaValidator< SchemaDocumentType, OutputHandler, StateAllocator >::Ch |
|
private |
typedef SchemaType::EncodingType GenericSchemaValidator< SchemaDocumentType, OutputHandler, StateAllocator >::EncodingType |
|
private |
|
private |
typedef SchemaDocumentType::PointerType GenericSchemaValidator< SchemaDocumentType, OutputHandler, StateAllocator >::PointerType |
typedef SchemaDocumentType::SchemaType GenericSchemaValidator< SchemaDocumentType, OutputHandler, StateAllocator >::SchemaType |
typedef GenericStringRef<Ch> GenericSchemaValidator< SchemaDocumentType, OutputHandler, StateAllocator >::StringRefType |
typedef SchemaType::SValue GenericSchemaValidator< SchemaDocumentType, OutputHandler, StateAllocator >::SValue |
typedef GenericValue<EncodingType, StateAllocator> GenericSchemaValidator< SchemaDocumentType, OutputHandler, StateAllocator >::ValueType |
|
inline |
Constructor without output handler.
schemaDocument | The schema document to conform to. |
allocator | Optional allocator for storing internal validation states. |
schemaStackCapacity | Optional initial capacity of schema path stack. |
documentStackCapacity | Optional initial capacity of document path stack. |
Definition at line 1782 of file schema.h.
|
inline |
Constructor with output handler.
schemaDocument | The schema document to conform to. |
allocator | Optional allocator for storing internal validation states. |
schemaStackCapacity | Optional initial capacity of schema path stack. |
documentStackCapacity | Optional initial capacity of document path stack. |
Definition at line 1812 of file schema.h.
|
inline |
Destructor.
Definition at line 1837 of file schema.h.
|
inlineprivate |
Definition at line 2194 of file schema.h.
|
inline |
Definition at line 1890 of file schema.h.
|
inline |
Definition at line 1894 of file schema.h.
|
inline |
Definition at line 1898 of file schema.h.
|
inlineprivate |
Definition at line 2361 of file schema.h.
|
inline |
Definition at line 1998 of file schema.h.
|
inlineprivate |
Definition at line 2347 of file schema.h.
|
inlineprivate |
Definition at line 2382 of file schema.h.
|
inlineprivate |
Definition at line 2328 of file schema.h.
|
inline |
Definition at line 2019 of file schema.h.
|
inline |
Definition at line 1990 of file schema.h.
|
inline |
Definition at line 1962 of file schema.h.
|
inlineprivate |
Definition at line 2372 of file schema.h.
|
inlineprivate |
Definition at line 2300 of file schema.h.
|
inlineprivate |
Definition at line 2230 of file schema.h.
|
inline |
Definition at line 1902 of file schema.h.
|
inline |
Definition at line 1906 of file schema.h.
|
inline |
Definition at line 1910 of file schema.h.
|
inline |
Definition at line 2102 of file schema.h.
|
inlinevirtual |
Implements internal::ISchemaStateFactory< SchemaDocumentType::SchemaType >.
Definition at line 2167 of file schema.h.
|
inlinevirtual |
Implements internal::ISchemaStateFactory< SchemaDocumentType::SchemaType >.
Definition at line 2153 of file schema.h.
|
inlineprivate |
Definition at line 2393 of file schema.h.
|
inlineprivate |
Definition at line 2394 of file schema.h.
|
inlineprivate |
Definition at line 2392 of file schema.h.
|
inlinevirtual |
Implements internal::ISchemaStateFactory< SchemaDocumentType::SchemaType >.
Definition at line 2175 of file schema.h.
|
inlinevirtual |
Definition at line 2161 of file schema.h.
|
inlinevirtual |
Implements internal::IValidationErrorHandler< SchemaDocumentType::SchemaType >.
Definition at line 2040 of file schema.h.
|
inlinevirtual |
Implements internal::IValidationErrorHandler< SchemaDocumentType::SchemaType >.
Definition at line 1929 of file schema.h.
|
inline |
Definition at line 1978 of file schema.h.
|
inlinevirtual |
Implements internal::IValidationErrorHandler< SchemaDocumentType::SchemaType >.
Definition at line 2012 of file schema.h.
|
inline |
Definition at line 1923 of file schema.h.
|
inline |
Definition at line 2107 of file schema.h.
|
inlinevirtual |
Implements internal::IValidationErrorHandler< SchemaDocumentType::SchemaType >.
Definition at line 1942 of file schema.h.
|
inline |
Definition at line 2140 of file schema.h.
|
inlinevirtual |
Implements internal::IValidationErrorHandler< SchemaDocumentType::SchemaType >.
Definition at line 2002 of file schema.h.
|
inline |
Definition at line 2022 of file schema.h.
|
inline |
Definition at line 1993 of file schema.h.
|
inlinevirtual |
Implements internal::IValidationErrorHandler< SchemaDocumentType::SchemaType >.
Definition at line 1965 of file schema.h.
|
inline |
Definition at line 2127 of file schema.h.
|
inlineprivate |
Definition at line 2261 of file schema.h.
|
inlinevirtual |
|
inline |
|
inline |
|
inlinevirtual |
Implements internal::ISchemaStateFactory< SchemaDocumentType::SchemaType >.
Definition at line 2171 of file schema.h.
|
inline |
Gets the JSON pointer pointed to the invalid value.
Definition at line 1872 of file schema.h.
|
inline |
Gets the keyword of invalid schema.
Definition at line 1867 of file schema.h.
|
inline |
Gets the JSON pointer pointed to the invalid schema.
Definition at line 1862 of file schema.h.
|
inlineprivate |
Definition at line 2224 of file schema.h.
|
inline |
Definition at line 2103 of file schema.h.
|
inline |
Definition at line 2105 of file schema.h.
|
inlinevirtual |
Checks whether the current state is valid.
Implements internal::ISchemaValidator.
Definition at line 1855 of file schema.h.
|
inline |
Definition at line 2119 of file schema.h.
|
inlinevirtual |
Implements internal::ISchemaStateFactory< SchemaDocumentType::SchemaType >.
Definition at line 2181 of file schema.h.
|
inlineprivate |
Definition at line 2366 of file schema.h.
|
inline |
Definition at line 2034 of file schema.h.
|
inline |
Definition at line 2029 of file schema.h.
|
inline |
Definition at line 1881 of file schema.h.
|
inline |
Definition at line 1884 of file schema.h.
|
inline |
Definition at line 1887 of file schema.h.
|
inline |
Definition at line 2037 of file schema.h.
|
inline |
Definition at line 2101 of file schema.h.
|
inlineprivate |
Definition at line 2319 of file schema.h.
|
inline |
Definition at line 1974 of file schema.h.
|
inlineprivate |
Definition at line 2317 of file schema.h.
|
inline |
Definition at line 2108 of file schema.h.
|
inline |
Reset the internal states.
Definition at line 1843 of file schema.h.
|
inline |
Definition at line 2134 of file schema.h.
|
inlinevirtual |
Implements internal::IValidationErrorHandler< SchemaDocumentType::SchemaType >.
Definition at line 1984 of file schema.h.
|
inlinevirtual |
Implements internal::IValidationErrorHandler< SchemaDocumentType::SchemaType >.
Definition at line 2016 of file schema.h.
|
inlinevirtual |
Implements internal::IValidationErrorHandler< SchemaDocumentType::SchemaType >.
Definition at line 1987 of file schema.h.
|
inlinevirtual |
Implements internal::IValidationErrorHandler< SchemaDocumentType::SchemaType >.
Definition at line 1959 of file schema.h.
|
inline |
Definition at line 2113 of file schema.h.
|
inline |
Definition at line 2110 of file schema.h.
|
inlinevirtual |
Implements internal::IValidationErrorHandler< SchemaDocumentType::SchemaType >.
Definition at line 1934 of file schema.h.
|
inlinevirtual |
Implements internal::IValidationErrorHandler< SchemaDocumentType::SchemaType >.
Definition at line 1955 of file schema.h.
|
inline |
Definition at line 1915 of file schema.h.
|
inlinevirtual |
Implements internal::IValidationErrorHandler< SchemaDocumentType::SchemaType >.
Definition at line 1938 of file schema.h.
|
inlinevirtual |
Implements internal::IValidationErrorHandler< SchemaDocumentType::SchemaType >.
Definition at line 1951 of file schema.h.
|
inline |
Definition at line 1919 of file schema.h.
|
inline |
Definition at line 2104 of file schema.h.
|
inline |
Definition at line 2106 of file schema.h.
|
private |
|
private |
|
private |
|
staticprivate |
|
staticprivate |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |