Classes | Public Types | Public Member Functions | Private Types | Private Member Functions | Static Private Member Functions | Private Attributes | Friends | List of all members
internal::Schema< SchemaDocumentType > Class Template Reference

#include <schema.h>

Classes

struct  PatternProperty
 
struct  Property
 
struct  SchemaArray
 

Public Types

typedef SchemaDocumentType::ValueType ValueType
 
typedef SchemaDocumentType::AllocatorType AllocatorType
 
typedef SchemaDocumentType::PointerType PointerType
 
typedef ValueType::EncodingType EncodingType
 
typedef EncodingType::Ch Ch
 
typedef SchemaValidationContext< SchemaDocumentType > Context
 
typedef Schema< SchemaDocumentType > SchemaType
 
typedef GenericValue< EncodingType, AllocatorTypeSValue
 
typedef IValidationErrorHandler< SchemaErrorHandler
 

Public Member Functions

 Schema (SchemaDocumentType *schemaDocument, const PointerType &p, const ValueType &value, const ValueType &document, AllocatorType *allocator)
 
 ~Schema ()
 
const SValueGetURI () const
 
const PointerTypeGetPointer () const
 
bool BeginValue (Context &context) const
 
RAPIDJSON_FORCEINLINE bool EndValue (Context &context) const
 
bool Null (Context &context) const
 
bool Bool (Context &context, bool) const
 
bool Int (Context &context, int i) const
 
bool Uint (Context &context, unsigned u) const
 
bool Int64 (Context &context, int64_t i) const
 
bool Uint64 (Context &context, uint64_t u) const
 
bool Double (Context &context, double d) const
 
bool String (Context &context, const Ch *str, SizeType length, bool) const
 
bool StartObject (Context &context) const
 
bool Key (Context &context, const Ch *str, SizeType len, bool) const
 
bool EndObject (Context &context, SizeType memberCount) const
 
bool StartArray (Context &context) const
 
bool EndArray (Context &context, SizeType elementCount) const
 

Private Types

enum  SchemaValueType {
  kNullSchemaType, kBooleanSchemaType, kObjectSchemaType, kArraySchemaType,
  kStringSchemaType, kNumberSchemaType, kIntegerSchemaType, kTotalSchemaType
}
 
typedef internal::GenericRegex< EncodingType, AllocatorTypeRegexType
 

Private Member Functions

template<typename V1 , typename V2 >
void AddUniqueElement (V1 &a, const V2 &v)
 
void AssignIfExist (SchemaArray &out, SchemaDocumentType &schemaDocument, const PointerType &p, const ValueType &value, const ValueType &name, const ValueType &document)
 
template<typename ValueType >
RegexTypeCreatePattern (const ValueType &value)
 
void AddType (const ValueType &type)
 
bool CreateParallelValidator (Context &context) const
 
void CreateSchemaValidators (Context &context, const SchemaArray &schemas) const
 
bool FindPropertyIndex (const ValueType &name, SizeType *outIndex) const
 
bool CheckInt (Context &context, int64_t i) const
 
bool CheckUint (Context &context, uint64_t i) const
 
bool CheckDoubleMinimum (Context &context, double d) const
 
bool CheckDoubleMaximum (Context &context, double d) const
 
bool CheckDoubleMultipleOf (Context &context, double d) const
 
void DisallowedType (Context &context, const ValueType &actualType) const
 

Static Private Member Functions

static const ValueTypeGetMember (const ValueType &value, const ValueType &name)
 
static void AssignIfExist (bool &out, const ValueType &value, const ValueType &name)
 
static void AssignIfExist (SizeType &out, const ValueType &value, const ValueType &name)
 
static bool IsPatternMatch (const RegexType *pattern, const Ch *str, SizeType)
 

Private Attributes

AllocatorTypeallocator_
 
SValue uri_
 
PointerType pointer_
 
const SchemaTypetypeless_
 
uint64_tenum_
 
SizeType enumCount_
 
SchemaArray allOf_
 
SchemaArray anyOf_
 
SchemaArray oneOf_
 
const SchemaTypenot_
 
unsigned type_
 
SizeType validatorCount_
 
SizeType notValidatorIndex_
 
Propertyproperties_
 
const SchemaTypeadditionalPropertiesSchema_
 
PatternPropertypatternProperties_
 
SizeType patternPropertyCount_
 
SizeType propertyCount_
 
SizeType minProperties_
 
SizeType maxProperties_
 
bool additionalProperties_
 
bool hasDependencies_
 
bool hasRequired_
 
bool hasSchemaDependencies_
 
const SchemaTypeadditionalItemsSchema_
 
const SchemaTypeitemsList_
 
const SchemaType ** itemsTuple_
 
SizeType itemsTupleCount_
 
SizeType minItems_
 
SizeType maxItems_
 
bool additionalItems_
 
bool uniqueItems_
 
RegexTypepattern_
 
SizeType minLength_
 
SizeType maxLength_
 
SValue minimum_
 
SValue maximum_
 
SValue multipleOf_
 
bool exclusiveMinimum_
 
bool exclusiveMaximum_
 
SizeType defaultValueLength_
 

Friends

class GenericSchemaDocument< ValueType, AllocatorType >
 

Detailed Description

template<typename SchemaDocumentType>
class internal::Schema< SchemaDocumentType >

Definition at line 132 of file schema.h.

Member Typedef Documentation

template<typename SchemaDocumentType >
typedef SchemaDocumentType::AllocatorType internal::Schema< SchemaDocumentType >::AllocatorType

Definition at line 399 of file schema.h.

template<typename SchemaDocumentType >
typedef EncodingType::Ch internal::Schema< SchemaDocumentType >::Ch

Definition at line 402 of file schema.h.

template<typename SchemaDocumentType >
typedef SchemaValidationContext<SchemaDocumentType> internal::Schema< SchemaDocumentType >::Context

Definition at line 403 of file schema.h.

template<typename SchemaDocumentType >
typedef ValueType::EncodingType internal::Schema< SchemaDocumentType >::EncodingType

Definition at line 401 of file schema.h.

template<typename SchemaDocumentType >
typedef IValidationErrorHandler<Schema> internal::Schema< SchemaDocumentType >::ErrorHandler

Definition at line 406 of file schema.h.

template<typename SchemaDocumentType >
typedef SchemaDocumentType::PointerType internal::Schema< SchemaDocumentType >::PointerType

Definition at line 400 of file schema.h.

template<typename SchemaDocumentType >
typedef internal::GenericRegex<EncodingType, AllocatorType> internal::Schema< SchemaDocumentType >::RegexType
private

Definition at line 1074 of file schema.h.

template<typename SchemaDocumentType >
typedef Schema<SchemaDocumentType> internal::Schema< SchemaDocumentType >::SchemaType

Definition at line 404 of file schema.h.

template<typename SchemaDocumentType >
typedef GenericValue<EncodingType, AllocatorType> internal::Schema< SchemaDocumentType >::SValue

Definition at line 405 of file schema.h.

template<typename SchemaDocumentType >
typedef SchemaDocumentType::ValueType internal::Schema< SchemaDocumentType >::ValueType

Definition at line 398 of file schema.h.

Member Enumeration Documentation

template<typename SchemaDocumentType >
enum internal::Schema::SchemaValueType
private
Enumerator
kNullSchemaType 
kBooleanSchemaType 
kObjectSchemaType 
kArraySchemaType 
kStringSchemaType 
kNumberSchemaType 
kIntegerSchemaType 
kTotalSchemaType 

Definition at line 1062 of file schema.h.

Constructor & Destructor Documentation

template<typename SchemaDocumentType >
internal::Schema< SchemaDocumentType >::Schema ( SchemaDocumentType *  schemaDocument,
const PointerType p,
const ValueType value,
const ValueType document,
AllocatorType allocator 
)
inline

Definition at line 409 of file schema.h.

409  :
410  allocator_(allocator),
411  uri_(schemaDocument->GetURI(), *allocator),
412  pointer_(p),
413  typeless_(schemaDocument->GetTypeless()),
414  enum_(),
415  enumCount_(),
416  not_(),
417  type_((1 << kTotalSchemaType) - 1), // typeless
418  validatorCount_(),
420  properties_(),
424  propertyCount_(),
425  minProperties_(),
427  additionalProperties_(true),
429  hasRequired_(),
432  itemsList_(),
433  itemsTuple_(),
435  minItems_(),
436  maxItems_(SizeType(~0)),
437  additionalItems_(true),
438  uniqueItems_(false),
439  pattern_(),
440  minLength_(0),
441  maxLength_(~SizeType(0)),
442  exclusiveMinimum_(false),
443  exclusiveMaximum_(false),
445  {
446  typedef typename SchemaDocumentType::ValueType ValueType;
447  typedef typename ValueType::ConstValueIterator ConstValueIterator;
448  typedef typename ValueType::ConstMemberIterator ConstMemberIterator;
449 
450  if (!value.IsObject())
451  return;
452 
453  if (const ValueType* v = GetMember(value, GetTypeString())) {
454  type_ = 0;
455  if (v->IsString())
456  AddType(*v);
457  else if (v->IsArray())
458  for (ConstValueIterator itr = v->Begin(); itr != v->End(); ++itr)
459  AddType(*itr);
460  }
461 
462  if (const ValueType* v = GetMember(value, GetEnumString()))
463  if (v->IsArray() && v->Size() > 0) {
464  enum_ = static_cast<uint64_t*>(allocator_->Malloc(sizeof(uint64_t) * v->Size()));
465  for (ConstValueIterator itr = v->Begin(); itr != v->End(); ++itr) {
466  typedef Hasher<EncodingType, MemoryPoolAllocator<> > EnumHasherType;
467  char buffer[256u + 24];
468  MemoryPoolAllocator<> hasherAllocator(buffer, sizeof(buffer));
469  EnumHasherType h(&hasherAllocator, 256);
470  itr->Accept(h);
471  enum_[enumCount_++] = h.GetHashCode();
472  }
473  }
474 
475  if (schemaDocument) {
476  AssignIfExist(allOf_, *schemaDocument, p, value, GetAllOfString(), document);
477  AssignIfExist(anyOf_, *schemaDocument, p, value, GetAnyOfString(), document);
478  AssignIfExist(oneOf_, *schemaDocument, p, value, GetOneOfString(), document);
479  }
480 
481  if (const ValueType* v = GetMember(value, GetNotString())) {
482  schemaDocument->CreateSchema(&not_, p.Append(GetNotString(), allocator_), *v, document);
484  validatorCount_++;
485  }
486 
487  // Object
488 
489  const ValueType* properties = GetMember(value, GetPropertiesString());
490  const ValueType* required = GetMember(value, GetRequiredString());
491  const ValueType* dependencies = GetMember(value, GetDependenciesString());
492  {
493  // Gather properties from properties/required/dependencies
494  SValue allProperties(kArrayType);
495 
496  if (properties && properties->IsObject())
497  for (ConstMemberIterator itr = properties->MemberBegin(); itr != properties->MemberEnd(); ++itr)
498  AddUniqueElement(allProperties, itr->name);
499 
500  if (required && required->IsArray())
501  for (ConstValueIterator itr = required->Begin(); itr != required->End(); ++itr)
502  if (itr->IsString())
503  AddUniqueElement(allProperties, *itr);
504 
505  if (dependencies && dependencies->IsObject())
506  for (ConstMemberIterator itr = dependencies->MemberBegin(); itr != dependencies->MemberEnd(); ++itr) {
507  AddUniqueElement(allProperties, itr->name);
508  if (itr->value.IsArray())
509  for (ConstValueIterator i = itr->value.Begin(); i != itr->value.End(); ++i)
510  if (i->IsString())
511  AddUniqueElement(allProperties, *i);
512  }
513 
514  if (allProperties.Size() > 0) {
515  propertyCount_ = allProperties.Size();
516  properties_ = static_cast<Property*>(allocator_->Malloc(sizeof(Property) * propertyCount_));
517  for (SizeType i = 0; i < propertyCount_; i++) {
518  new (&properties_[i]) Property();
519  properties_[i].name = allProperties[i];
521  }
522  }
523  }
524 
525  if (properties && properties->IsObject()) {
526  PointerType q = p.Append(GetPropertiesString(), allocator_);
527  for (ConstMemberIterator itr = properties->MemberBegin(); itr != properties->MemberEnd(); ++itr) {
528  SizeType index;
529  if (FindPropertyIndex(itr->name, &index))
530  schemaDocument->CreateSchema(&properties_[index].schema, q.Append(itr->name, allocator_), itr->value, document);
531  }
532  }
533 
534  if (const ValueType* v = GetMember(value, GetPatternPropertiesString())) {
535  PointerType q = p.Append(GetPatternPropertiesString(), allocator_);
536  patternProperties_ = static_cast<PatternProperty*>(allocator_->Malloc(sizeof(PatternProperty) * v->MemberCount()));
538 
539  for (ConstMemberIterator itr = v->MemberBegin(); itr != v->MemberEnd(); ++itr) {
540  new (&patternProperties_[patternPropertyCount_]) PatternProperty();
542  schemaDocument->CreateSchema(&patternProperties_[patternPropertyCount_].schema, q.Append(itr->name, allocator_), itr->value, document);
544  }
545  }
546 
547  if (required && required->IsArray())
548  for (ConstValueIterator itr = required->Begin(); itr != required->End(); ++itr)
549  if (itr->IsString()) {
550  SizeType index;
551  if (FindPropertyIndex(*itr, &index)) {
552  properties_[index].required = true;
553  hasRequired_ = true;
554  }
555  }
556 
557  if (dependencies && dependencies->IsObject()) {
558  PointerType q = p.Append(GetDependenciesString(), allocator_);
559  hasDependencies_ = true;
560  for (ConstMemberIterator itr = dependencies->MemberBegin(); itr != dependencies->MemberEnd(); ++itr) {
561  SizeType sourceIndex;
562  if (FindPropertyIndex(itr->name, &sourceIndex)) {
563  if (itr->value.IsArray()) {
564  properties_[sourceIndex].dependencies = static_cast<bool*>(allocator_->Malloc(sizeof(bool) * propertyCount_));
565  std::memset(properties_[sourceIndex].dependencies, 0, sizeof(bool)* propertyCount_);
566  for (ConstValueIterator targetItr = itr->value.Begin(); targetItr != itr->value.End(); ++targetItr) {
567  SizeType targetIndex;
568  if (FindPropertyIndex(*targetItr, &targetIndex))
569  properties_[sourceIndex].dependencies[targetIndex] = true;
570  }
571  }
572  else if (itr->value.IsObject()) {
573  hasSchemaDependencies_ = true;
574  schemaDocument->CreateSchema(&properties_[sourceIndex].dependenciesSchema, q.Append(itr->name, allocator_), itr->value, document);
576  validatorCount_++;
577  }
578  }
579  }
580  }
581 
582  if (const ValueType* v = GetMember(value, GetAdditionalPropertiesString())) {
583  if (v->IsBool())
584  additionalProperties_ = v->GetBool();
585  else if (v->IsObject())
586  schemaDocument->CreateSchema(&additionalPropertiesSchema_, p.Append(GetAdditionalPropertiesString(), allocator_), *v, document);
587  }
588 
589  AssignIfExist(minProperties_, value, GetMinPropertiesString());
590  AssignIfExist(maxProperties_, value, GetMaxPropertiesString());
591 
592  // Array
593  if (const ValueType* v = GetMember(value, GetItemsString())) {
594  PointerType q = p.Append(GetItemsString(), allocator_);
595  if (v->IsObject()) // List validation
596  schemaDocument->CreateSchema(&itemsList_, q, *v, document);
597  else if (v->IsArray()) { // Tuple validation
598  itemsTuple_ = static_cast<const Schema**>(allocator_->Malloc(sizeof(const Schema*) * v->Size()));
599  SizeType index = 0;
600  for (ConstValueIterator itr = v->Begin(); itr != v->End(); ++itr, index++)
601  schemaDocument->CreateSchema(&itemsTuple_[itemsTupleCount_++], q.Append(index, allocator_), *itr, document);
602  }
603  }
604 
605  AssignIfExist(minItems_, value, GetMinItemsString());
606  AssignIfExist(maxItems_, value, GetMaxItemsString());
607 
608  if (const ValueType* v = GetMember(value, GetAdditionalItemsString())) {
609  if (v->IsBool())
610  additionalItems_ = v->GetBool();
611  else if (v->IsObject())
612  schemaDocument->CreateSchema(&additionalItemsSchema_, p.Append(GetAdditionalItemsString(), allocator_), *v, document);
613  }
614 
615  AssignIfExist(uniqueItems_, value, GetUniqueItemsString());
616 
617  // String
618  AssignIfExist(minLength_, value, GetMinLengthString());
619  AssignIfExist(maxLength_, value, GetMaxLengthString());
620 
621  if (const ValueType* v = GetMember(value, GetPatternString()))
622  pattern_ = CreatePattern(*v);
623 
624  // Number
625  if (const ValueType* v = GetMember(value, GetMinimumString()))
626  if (v->IsNumber())
627  minimum_.CopyFrom(*v, *allocator_);
628 
629  if (const ValueType* v = GetMember(value, GetMaximumString()))
630  if (v->IsNumber())
631  maximum_.CopyFrom(*v, *allocator_);
632 
633  AssignIfExist(exclusiveMinimum_, value, GetExclusiveMinimumString());
634  AssignIfExist(exclusiveMaximum_, value, GetExclusiveMaximumString());
635 
636  if (const ValueType* v = GetMember(value, GetMultipleOfString()))
637  if (v->IsNumber() && v->GetDouble() > 0.0)
638  multipleOf_.CopyFrom(*v, *allocator_);
639 
640  // Default
641  if (const ValueType* v = GetMember(value, GetDefaultValueString()))
642  if (v->IsString())
643  defaultValueLength_ = v->GetStringLength();
644 
645  }
bool hasRequired_
Definition: schema.h:1417
SizeType enumCount_
Definition: schema.h:1399
SchemaArray allOf_
Definition: schema.h:1400
SizeType patternPropertyCount_
Definition: schema.h:1411
SizeType minProperties_
Definition: schema.h:1413
SizeType defaultValueLength_
Definition: schema.h:1439
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
Definition: rapidjson.h:384
AllocatorType * allocator_
Definition: schema.h:1394
void AddUniqueElement(V1 &a, const V2 &v)
Definition: schema.h:1090
const SchemaType * typeless_
Definition: schema.h:1397
PatternProperty * patternProperties_
Definition: schema.h:1410
array
Definition: rapidjson.h:623
SchemaDocumentType::PointerType PointerType
Definition: schema.h:400
const SchemaType * additionalItemsSchema_
Definition: schema.h:1420
SizeType maxProperties_
Definition: schema.h:1414
SizeType notValidatorIndex_
Definition: schema.h:1406
static const ValueType * GetMember(const ValueType &value, const ValueType &name)
Definition: schema.h:1098
const SchemaType * itemsList_
Definition: schema.h:1421
const SchemaType ** itemsTuple_
Definition: schema.h:1422
SValue minimum_
Definition: schema.h:1433
SizeType itemsTupleCount_
Definition: schema.h:1423
uint64_t * enum_
Definition: schema.h:1398
unsigned type_
Definition: schema.h:1404
SizeType maxItems_
Definition: schema.h:1425
GenericValue< EncodingType, AllocatorType > SValue
Definition: schema.h:405
PointerType pointer_
Definition: schema.h:1396
SizeType dependenciesValidatorIndex
Definition: schema.h:1377
const SchemaType * additionalPropertiesSchema_
Definition: schema.h:1409
SizeType propertyCount_
Definition: schema.h:1412
SchemaArray anyOf_
Definition: schema.h:1401
const SchemaType * not_
Definition: schema.h:1403
unsigned __int64 uint64_t
Definition: stdint.h:136
SizeType maxLength_
Definition: schema.h:1431
p
Definition: test.py:223
SValue multipleOf_
Definition: schema.h:1435
bool additionalItems_
Definition: schema.h:1426
bool hasDependencies_
Definition: schema.h:1416
const SchemaType * schema
Definition: schema.h:1375
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1225
SchemaDocumentType::ValueType ValueType
Definition: schema.h:398
Schema(SchemaDocumentType *schemaDocument, const PointerType &p, const ValueType &value, const ValueType &document, AllocatorType *allocator)
Definition: schema.h:409
Property * properties_
Definition: schema.h:1408
bool exclusiveMinimum_
Definition: schema.h:1436
bool additionalProperties_
Definition: schema.h:1415
SizeType minItems_
Definition: schema.h:1424
RegexType * pattern_
Definition: schema.h:1429
SValue maximum_
Definition: schema.h:1434
bool FindPropertyIndex(const ValueType &name, SizeType *outIndex) const
Definition: schema.h:1219
bool uniqueItems_
Definition: schema.h:1427
SizeType minLength_
Definition: schema.h:1430
bool hasSchemaDependencies_
Definition: schema.h:1418
bool exclusiveMaximum_
Definition: schema.h:1437
Default memory allocator used by the parser and DOM.
Definition: allocators.h:115
RegexType * CreatePattern(const ValueType &value)
Definition: schema.h:1132
Definition: types.h:32
static void AssignIfExist(bool &out, const ValueType &value, const ValueType &name)
Definition: schema.h:1103
SizeType validatorCount_
Definition: schema.h:1405
h
training ###############################
Definition: train_cnn.py:186
void AddType(const ValueType &type)
Definition: schema.h:1172
SchemaArray oneOf_
Definition: schema.h:1402
template<typename SchemaDocumentType >
internal::Schema< SchemaDocumentType >::~Schema ( )
inline

Definition at line 647 of file schema.h.

647  {
648  AllocatorType::Free(enum_);
649  if (properties_) {
650  for (SizeType i = 0; i < propertyCount_; i++)
651  properties_[i].~Property();
652  AllocatorType::Free(properties_);
653  }
654  if (patternProperties_) {
655  for (SizeType i = 0; i < patternPropertyCount_; i++)
656  patternProperties_[i].~PatternProperty();
657  AllocatorType::Free(patternProperties_);
658  }
659  AllocatorType::Free(itemsTuple_);
660 #if RAPIDJSON_SCHEMA_HAS_REGEX
661  if (pattern_) {
662  pattern_->~RegexType();
663  AllocatorType::Free(pattern_);
664  }
665 #endif
666  }
SizeType patternPropertyCount_
Definition: schema.h:1411
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
Definition: rapidjson.h:384
PatternProperty * patternProperties_
Definition: schema.h:1410
const SchemaType ** itemsTuple_
Definition: schema.h:1422
uint64_t * enum_
Definition: schema.h:1398
SizeType propertyCount_
Definition: schema.h:1412
Property * properties_
Definition: schema.h:1408
RegexType * pattern_
Definition: schema.h:1429
Definition: types.h:32

Member Function Documentation

template<typename SchemaDocumentType >
void internal::Schema< SchemaDocumentType >::AddType ( const ValueType type)
inlineprivate

Definition at line 1172 of file schema.h.

1172  {
1173  if (type == GetNullString() ) type_ |= 1 << kNullSchemaType;
1174  else if (type == GetBooleanString()) type_ |= 1 << kBooleanSchemaType;
1175  else if (type == GetObjectString() ) type_ |= 1 << kObjectSchemaType;
1176  else if (type == GetArrayString() ) type_ |= 1 << kArraySchemaType;
1177  else if (type == GetStringString() ) type_ |= 1 << kStringSchemaType;
1178  else if (type == GetIntegerString()) type_ |= 1 << kIntegerSchemaType;
1179  else if (type == GetNumberString() ) type_ |= (1 << kNumberSchemaType) | (1 << kIntegerSchemaType);
1180  }
unsigned type_
Definition: schema.h:1404
template<typename SchemaDocumentType >
template<typename V1 , typename V2 >
void internal::Schema< SchemaDocumentType >::AddUniqueElement ( V1 &  a,
const V2 &  v 
)
inlineprivate

Definition at line 1090 of file schema.h.

1090  {
1091  for (typename V1::ConstValueIterator itr = a.Begin(); itr != a.End(); ++itr)
1092  if (*itr == v)
1093  return;
1094  V1 c(v, *allocator_);
1095  a.PushBack(c, *allocator_);
1096  }
AllocatorType * allocator_
Definition: schema.h:1394
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition: pointer.h:1124
template<typename SchemaDocumentType >
static void internal::Schema< SchemaDocumentType >::AssignIfExist ( bool out,
const ValueType value,
const ValueType name 
)
inlinestaticprivate

Definition at line 1103 of file schema.h.

1103  {
1104  if (const ValueType* v = GetMember(value, name))
1105  if (v->IsBool())
1106  out = v->GetBool();
1107  }
static QCString name
Definition: declinfo.cpp:673
static const ValueType * GetMember(const ValueType &value, const ValueType &name)
Definition: schema.h:1098
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1225
SchemaDocumentType::ValueType ValueType
Definition: schema.h:398
template<typename SchemaDocumentType >
static void internal::Schema< SchemaDocumentType >::AssignIfExist ( SizeType out,
const ValueType value,
const ValueType name 
)
inlinestaticprivate

Definition at line 1109 of file schema.h.

1109  {
1110  if (const ValueType* v = GetMember(value, name))
1111  if (v->IsUint64() && v->GetUint64() <= SizeType(~0))
1112  out = static_cast<SizeType>(v->GetUint64());
1113  }
static QCString name
Definition: declinfo.cpp:673
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
Definition: rapidjson.h:384
static const ValueType * GetMember(const ValueType &value, const ValueType &name)
Definition: schema.h:1098
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1225
SchemaDocumentType::ValueType ValueType
Definition: schema.h:398
template<typename SchemaDocumentType >
void internal::Schema< SchemaDocumentType >::AssignIfExist ( SchemaArray out,
SchemaDocumentType &  schemaDocument,
const PointerType p,
const ValueType value,
const ValueType name,
const ValueType document 
)
inlineprivate

Definition at line 1115 of file schema.h.

1115  {
1116  if (const ValueType* v = GetMember(value, name)) {
1117  if (v->IsArray() && v->Size() > 0) {
1118  PointerType q = p.Append(name, allocator_);
1119  out.count = v->Size();
1120  out.schemas = static_cast<const Schema**>(allocator_->Malloc(out.count * sizeof(const Schema*)));
1121  memset(out.schemas, 0, sizeof(Schema*)* out.count);
1122  for (SizeType i = 0; i < out.count; i++)
1123  schemaDocument.CreateSchema(&out.schemas[i], q.Append(i, allocator_), (*v)[i], document);
1124  out.begin = validatorCount_;
1125  validatorCount_ += out.count;
1126  }
1127  }
1128  }
static QCString name
Definition: declinfo.cpp:673
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
Definition: rapidjson.h:384
AllocatorType * allocator_
Definition: schema.h:1394
SchemaDocumentType::PointerType PointerType
Definition: schema.h:400
static const ValueType * GetMember(const ValueType &value, const ValueType &name)
Definition: schema.h:1098
p
Definition: test.py:223
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1225
SchemaDocumentType::ValueType ValueType
Definition: schema.h:398
Schema(SchemaDocumentType *schemaDocument, const PointerType &p, const ValueType &value, const ValueType &document, AllocatorType *allocator)
Definition: schema.h:409
SizeType validatorCount_
Definition: schema.h:1405
template<typename SchemaDocumentType >
bool internal::Schema< SchemaDocumentType >::BeginValue ( Context context) const
inline

Definition at line 676 of file schema.h.

676  {
677  if (context.inArray) {
678  if (uniqueItems_)
679  context.valueUniqueness = true;
680 
681  if (itemsList_)
682  context.valueSchema = itemsList_;
683  else if (itemsTuple_) {
684  if (context.arrayElementIndex < itemsTupleCount_)
685  context.valueSchema = itemsTuple_[context.arrayElementIndex];
686  else if (additionalItemsSchema_)
687  context.valueSchema = additionalItemsSchema_;
688  else if (additionalItems_)
689  context.valueSchema = typeless_;
690  else {
691  context.error_handler.DisallowedItem(context.arrayElementIndex);
692  RAPIDJSON_INVALID_KEYWORD_RETURN(GetItemsString());
693  }
694  }
695  else
696  context.valueSchema = typeless_;
697 
698  context.arrayElementIndex++;
699  }
700  return true;
701  }
const SchemaType * typeless_
Definition: schema.h:1397
const SchemaType * additionalItemsSchema_
Definition: schema.h:1420
const SchemaType * itemsList_
Definition: schema.h:1421
const SchemaType ** itemsTuple_
Definition: schema.h:1422
SizeType itemsTupleCount_
Definition: schema.h:1423
#define RAPIDJSON_INVALID_KEYWORD_RETURN(keyword)
Definition: schema.h:116
bool additionalItems_
Definition: schema.h:1426
bool uniqueItems_
Definition: schema.h:1427
template<typename SchemaDocumentType >
bool internal::Schema< SchemaDocumentType >::Bool ( Context context,
bool   
) const
inline

Definition at line 793 of file schema.h.

793  {
794  if (!(type_ & (1 << kBooleanSchemaType))) {
795  DisallowedType(context, GetBooleanString());
796  RAPIDJSON_INVALID_KEYWORD_RETURN(GetTypeString());
797  }
798  return CreateParallelValidator(context);
799  }
bool CreateParallelValidator(Context &context) const
Definition: schema.h:1182
unsigned type_
Definition: schema.h:1404
void DisallowedType(Context &context, const ValueType &actualType) const
Definition: schema.h:1355
#define RAPIDJSON_INVALID_KEYWORD_RETURN(keyword)
Definition: schema.h:116
template<typename SchemaDocumentType >
bool internal::Schema< SchemaDocumentType >::CheckDoubleMaximum ( Context context,
double  d 
) const
inlineprivate

Definition at line 1336 of file schema.h.

1336  {
1337  if (exclusiveMaximum_ ? d >= maximum_.GetDouble() : d > maximum_.GetDouble()) {
1338  context.error_handler.AboveMaximum(d, maximum_, exclusiveMaximum_);
1339  RAPIDJSON_INVALID_KEYWORD_RETURN(GetMaximumString());
1340  }
1341  return true;
1342  }
#define RAPIDJSON_INVALID_KEYWORD_RETURN(keyword)
Definition: schema.h:116
SValue maximum_
Definition: schema.h:1434
bool exclusiveMaximum_
Definition: schema.h:1437
template<typename SchemaDocumentType >
bool internal::Schema< SchemaDocumentType >::CheckDoubleMinimum ( Context context,
double  d 
) const
inlineprivate

Definition at line 1328 of file schema.h.

1328  {
1329  if (exclusiveMinimum_ ? d <= minimum_.GetDouble() : d < minimum_.GetDouble()) {
1330  context.error_handler.BelowMinimum(d, minimum_, exclusiveMinimum_);
1331  RAPIDJSON_INVALID_KEYWORD_RETURN(GetMinimumString());
1332  }
1333  return true;
1334  }
SValue minimum_
Definition: schema.h:1433
#define RAPIDJSON_INVALID_KEYWORD_RETURN(keyword)
Definition: schema.h:116
bool exclusiveMinimum_
Definition: schema.h:1436
template<typename SchemaDocumentType >
bool internal::Schema< SchemaDocumentType >::CheckDoubleMultipleOf ( Context context,
double  d 
) const
inlineprivate

Definition at line 1344 of file schema.h.

1344  {
1345  double a = std::abs(d), b = std::abs(multipleOf_.GetDouble());
1346  double q = std::floor(a / b);
1347  double r = a - q * b;
1348  if (r > 0.0) {
1349  context.error_handler.NotMultipleOf(d, multipleOf_);
1350  RAPIDJSON_INVALID_KEYWORD_RETURN(GetMultipleOfString());
1351  }
1352  return true;
1353  }
T abs(T value)
#define RAPIDJSON_INVALID_KEYWORD_RETURN(keyword)
Definition: schema.h:116
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition: pointer.h:1124
SValue multipleOf_
Definition: schema.h:1435
static bool * b
Definition: config.cpp:1043
template<typename SchemaDocumentType >
bool internal::Schema< SchemaDocumentType >::CheckInt ( Context context,
int64_t  i 
) const
inlineprivate

Definition at line 1232 of file schema.h.

1232  {
1233  if (!(type_ & ((1 << kIntegerSchemaType) | (1 << kNumberSchemaType)))) {
1234  DisallowedType(context, GetIntegerString());
1235  RAPIDJSON_INVALID_KEYWORD_RETURN(GetTypeString());
1236  }
1237 
1238  if (!minimum_.IsNull()) {
1239  if (minimum_.IsInt64()) {
1240  if (exclusiveMinimum_ ? i <= minimum_.GetInt64() : i < minimum_.GetInt64()) {
1241  context.error_handler.BelowMinimum(i, minimum_, exclusiveMinimum_);
1242  RAPIDJSON_INVALID_KEYWORD_RETURN(GetMinimumString());
1243  }
1244  }
1245  else if (minimum_.IsUint64()) {
1246  context.error_handler.BelowMinimum(i, minimum_, exclusiveMinimum_);
1247  RAPIDJSON_INVALID_KEYWORD_RETURN(GetMinimumString()); // i <= max(int64_t) < minimum.GetUint64()
1248  }
1249  else if (!CheckDoubleMinimum(context, static_cast<double>(i)))
1250  return false;
1251  }
1252 
1253  if (!maximum_.IsNull()) {
1254  if (maximum_.IsInt64()) {
1255  if (exclusiveMaximum_ ? i >= maximum_.GetInt64() : i > maximum_.GetInt64()) {
1256  context.error_handler.AboveMaximum(i, maximum_, exclusiveMaximum_);
1257  RAPIDJSON_INVALID_KEYWORD_RETURN(GetMaximumString());
1258  }
1259  }
1260  else if (maximum_.IsUint64()) { }
1261  /* do nothing */ // i <= max(int64_t) < maximum_.GetUint64()
1262  else if (!CheckDoubleMaximum(context, static_cast<double>(i)))
1263  return false;
1264  }
1265 
1266  if (!multipleOf_.IsNull()) {
1267  if (multipleOf_.IsUint64()) {
1268  if (static_cast<uint64_t>(i >= 0 ? i : -i) % multipleOf_.GetUint64() != 0) {
1269  context.error_handler.NotMultipleOf(i, multipleOf_);
1270  RAPIDJSON_INVALID_KEYWORD_RETURN(GetMultipleOfString());
1271  }
1272  }
1273  else if (!CheckDoubleMultipleOf(context, static_cast<double>(i)))
1274  return false;
1275  }
1276 
1277  return true;
1278  }
SValue minimum_
Definition: schema.h:1433
unsigned type_
Definition: schema.h:1404
bool CheckDoubleMultipleOf(Context &context, double d) const
Definition: schema.h:1344
void DisallowedType(Context &context, const ValueType &actualType) const
Definition: schema.h:1355
bool CheckDoubleMaximum(Context &context, double d) const
Definition: schema.h:1336
#define RAPIDJSON_INVALID_KEYWORD_RETURN(keyword)
Definition: schema.h:116
bool CheckDoubleMinimum(Context &context, double d) const
Definition: schema.h:1328
SValue multipleOf_
Definition: schema.h:1435
bool exclusiveMinimum_
Definition: schema.h:1436
SValue maximum_
Definition: schema.h:1434
bool exclusiveMaximum_
Definition: schema.h:1437
template<typename SchemaDocumentType >
bool internal::Schema< SchemaDocumentType >::CheckUint ( Context context,
uint64_t  i 
) const
inlineprivate

Definition at line 1280 of file schema.h.

1280  {
1281  if (!(type_ & ((1 << kIntegerSchemaType) | (1 << kNumberSchemaType)))) {
1282  DisallowedType(context, GetIntegerString());
1283  RAPIDJSON_INVALID_KEYWORD_RETURN(GetTypeString());
1284  }
1285 
1286  if (!minimum_.IsNull()) {
1287  if (minimum_.IsUint64()) {
1288  if (exclusiveMinimum_ ? i <= minimum_.GetUint64() : i < minimum_.GetUint64()) {
1289  context.error_handler.BelowMinimum(i, minimum_, exclusiveMinimum_);
1290  RAPIDJSON_INVALID_KEYWORD_RETURN(GetMinimumString());
1291  }
1292  }
1293  else if (minimum_.IsInt64())
1294  /* do nothing */; // i >= 0 > minimum.Getint64()
1295  else if (!CheckDoubleMinimum(context, static_cast<double>(i)))
1296  return false;
1297  }
1298 
1299  if (!maximum_.IsNull()) {
1300  if (maximum_.IsUint64()) {
1301  if (exclusiveMaximum_ ? i >= maximum_.GetUint64() : i > maximum_.GetUint64()) {
1302  context.error_handler.AboveMaximum(i, maximum_, exclusiveMaximum_);
1303  RAPIDJSON_INVALID_KEYWORD_RETURN(GetMaximumString());
1304  }
1305  }
1306  else if (maximum_.IsInt64()) {
1307  context.error_handler.AboveMaximum(i, maximum_, exclusiveMaximum_);
1308  RAPIDJSON_INVALID_KEYWORD_RETURN(GetMaximumString()); // i >= 0 > maximum_
1309  }
1310  else if (!CheckDoubleMaximum(context, static_cast<double>(i)))
1311  return false;
1312  }
1313 
1314  if (!multipleOf_.IsNull()) {
1315  if (multipleOf_.IsUint64()) {
1316  if (i % multipleOf_.GetUint64() != 0) {
1317  context.error_handler.NotMultipleOf(i, multipleOf_);
1318  RAPIDJSON_INVALID_KEYWORD_RETURN(GetMultipleOfString());
1319  }
1320  }
1321  else if (!CheckDoubleMultipleOf(context, static_cast<double>(i)))
1322  return false;
1323  }
1324 
1325  return true;
1326  }
SValue minimum_
Definition: schema.h:1433
unsigned type_
Definition: schema.h:1404
bool CheckDoubleMultipleOf(Context &context, double d) const
Definition: schema.h:1344
void DisallowedType(Context &context, const ValueType &actualType) const
Definition: schema.h:1355
bool CheckDoubleMaximum(Context &context, double d) const
Definition: schema.h:1336
#define RAPIDJSON_INVALID_KEYWORD_RETURN(keyword)
Definition: schema.h:116
bool CheckDoubleMinimum(Context &context, double d) const
Definition: schema.h:1328
SValue multipleOf_
Definition: schema.h:1435
bool exclusiveMinimum_
Definition: schema.h:1436
SValue maximum_
Definition: schema.h:1434
bool exclusiveMaximum_
Definition: schema.h:1437
template<typename SchemaDocumentType >
bool internal::Schema< SchemaDocumentType >::CreateParallelValidator ( Context context) const
inlineprivate

Definition at line 1182 of file schema.h.

1182  {
1183  if (enum_ || context.arrayUniqueness)
1184  context.hasher = context.factory.CreateHasher();
1185 
1186  if (validatorCount_) {
1187  RAPIDJSON_ASSERT(context.validators == 0);
1188  context.validators = static_cast<ISchemaValidator**>(context.factory.MallocState(sizeof(ISchemaValidator*) * validatorCount_));
1189  context.validatorCount = validatorCount_;
1190 
1191  if (allOf_.schemas)
1192  CreateSchemaValidators(context, allOf_);
1193 
1194  if (anyOf_.schemas)
1195  CreateSchemaValidators(context, anyOf_);
1196 
1197  if (oneOf_.schemas)
1198  CreateSchemaValidators(context, oneOf_);
1199 
1200  if (not_)
1201  context.validators[notValidatorIndex_] = context.factory.CreateSchemaValidator(*not_);
1202 
1203  if (hasSchemaDependencies_) {
1204  for (SizeType i = 0; i < propertyCount_; i++)
1205  if (properties_[i].dependenciesSchema)
1206  context.validators[properties_[i].dependenciesValidatorIndex] = context.factory.CreateSchemaValidator(*properties_[i].dependenciesSchema);
1207  }
1208  }
1209 
1210  return true;
1211  }
SchemaArray allOf_
Definition: schema.h:1400
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
Definition: rapidjson.h:384
#define RAPIDJSON_ASSERT(x)
Assertion.
Definition: rapidjson.h:406
const SchemaType ** schemas
Definition: schema.h:1084
SizeType notValidatorIndex_
Definition: schema.h:1406
uint64_t * enum_
Definition: schema.h:1398
SizeType dependenciesValidatorIndex
Definition: schema.h:1377
SizeType propertyCount_
Definition: schema.h:1412
SchemaArray anyOf_
Definition: schema.h:1401
const SchemaType * not_
Definition: schema.h:1403
void CreateSchemaValidators(Context &context, const SchemaArray &schemas) const
Definition: schema.h:1213
Property * properties_
Definition: schema.h:1408
bool hasSchemaDependencies_
Definition: schema.h:1418
SizeType validatorCount_
Definition: schema.h:1405
SchemaArray oneOf_
Definition: schema.h:1402
template<typename SchemaDocumentType >
template<typename ValueType >
RegexType* internal::Schema< SchemaDocumentType >::CreatePattern ( const ValueType value)
inlineprivate

Definition at line 1132 of file schema.h.

1132  {
1133  if (value.IsString()) {
1134  RegexType* r = new (allocator_->Malloc(sizeof(RegexType))) RegexType(value.GetString(), allocator_);
1135  if (!r->IsValid()) {
1136  r->~RegexType();
1137  AllocatorType::Free(r);
1138  r = 0;
1139  }
1140  return r;
1141  }
1142  return 0;
1143  }
AllocatorType * allocator_
Definition: schema.h:1394
internal::GenericRegex< EncodingType, AllocatorType > RegexType
Definition: schema.h:1074
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1225
template<typename SchemaDocumentType >
void internal::Schema< SchemaDocumentType >::CreateSchemaValidators ( Context context,
const SchemaArray schemas 
) const
inlineprivate

Definition at line 1213 of file schema.h.

1213  {
1214  for (SizeType i = 0; i < schemas.count; i++)
1215  context.validators[schemas.begin + i] = context.factory.CreateSchemaValidator(*schemas.schemas[i]);
1216  }
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
Definition: rapidjson.h:384
template<typename SchemaDocumentType >
void internal::Schema< SchemaDocumentType >::DisallowedType ( Context context,
const ValueType actualType 
) const
inlineprivate

Definition at line 1355 of file schema.h.

1355  {
1356  ErrorHandler& eh = context.error_handler;
1357  eh.StartDisallowedType();
1358 
1359  if (type_ & (1 << kNullSchemaType)) eh.AddExpectedType(GetNullString());
1360  if (type_ & (1 << kBooleanSchemaType)) eh.AddExpectedType(GetBooleanString());
1361  if (type_ & (1 << kObjectSchemaType)) eh.AddExpectedType(GetObjectString());
1362  if (type_ & (1 << kArraySchemaType)) eh.AddExpectedType(GetArrayString());
1363  if (type_ & (1 << kStringSchemaType)) eh.AddExpectedType(GetStringString());
1364 
1365  if (type_ & (1 << kNumberSchemaType)) eh.AddExpectedType(GetNumberString());
1366  else if (type_ & (1 << kIntegerSchemaType)) eh.AddExpectedType(GetIntegerString());
1367 
1368  eh.EndDisallowedType(actualType);
1369  }
unsigned type_
Definition: schema.h:1404
template<typename SchemaDocumentType >
bool internal::Schema< SchemaDocumentType >::Double ( Context context,
double  d 
) const
inline

Definition at line 825 of file schema.h.

825  {
826  if (!(type_ & (1 << kNumberSchemaType))) {
827  DisallowedType(context, GetNumberString());
828  RAPIDJSON_INVALID_KEYWORD_RETURN(GetTypeString());
829  }
830 
831  if (!minimum_.IsNull() && !CheckDoubleMinimum(context, d))
832  return false;
833 
834  if (!maximum_.IsNull() && !CheckDoubleMaximum(context, d))
835  return false;
836 
837  if (!multipleOf_.IsNull() && !CheckDoubleMultipleOf(context, d))
838  return false;
839 
840  return CreateParallelValidator(context);
841  }
SValue minimum_
Definition: schema.h:1433
bool CreateParallelValidator(Context &context) const
Definition: schema.h:1182
unsigned type_
Definition: schema.h:1404
bool CheckDoubleMultipleOf(Context &context, double d) const
Definition: schema.h:1344
void DisallowedType(Context &context, const ValueType &actualType) const
Definition: schema.h:1355
bool CheckDoubleMaximum(Context &context, double d) const
Definition: schema.h:1336
#define RAPIDJSON_INVALID_KEYWORD_RETURN(keyword)
Definition: schema.h:116
bool CheckDoubleMinimum(Context &context, double d) const
Definition: schema.h:1328
SValue multipleOf_
Definition: schema.h:1435
SValue maximum_
Definition: schema.h:1434
template<typename SchemaDocumentType >
bool internal::Schema< SchemaDocumentType >::EndArray ( Context context,
SizeType  elementCount 
) const
inline

Definition at line 1000 of file schema.h.

1000  {
1001  context.inArray = false;
1002 
1003  if (elementCount < minItems_) {
1004  context.error_handler.TooFewItems(elementCount, minItems_);
1005  RAPIDJSON_INVALID_KEYWORD_RETURN(GetMinItemsString());
1006  }
1007 
1008  if (elementCount > maxItems_) {
1009  context.error_handler.TooManyItems(elementCount, maxItems_);
1010  RAPIDJSON_INVALID_KEYWORD_RETURN(GetMaxItemsString());
1011  }
1012 
1013  return true;
1014  }
SizeType maxItems_
Definition: schema.h:1425
#define RAPIDJSON_INVALID_KEYWORD_RETURN(keyword)
Definition: schema.h:116
SizeType minItems_
Definition: schema.h:1424
template<typename SchemaDocumentType >
bool internal::Schema< SchemaDocumentType >::EndObject ( Context context,
SizeType  memberCount 
) const
inline

Definition at line 941 of file schema.h.

941  {
942  if (hasRequired_) {
943  context.error_handler.StartMissingProperties();
944  for (SizeType index = 0; index < propertyCount_; index++)
945  if (properties_[index].required && !context.propertyExist[index])
946  if (properties_[index].schema->defaultValueLength_ == 0 )
947  context.error_handler.AddMissingProperty(properties_[index].name);
948  if (context.error_handler.EndMissingProperties())
949  RAPIDJSON_INVALID_KEYWORD_RETURN(GetRequiredString());
950  }
951 
952  if (memberCount < minProperties_) {
953  context.error_handler.TooFewProperties(memberCount, minProperties_);
954  RAPIDJSON_INVALID_KEYWORD_RETURN(GetMinPropertiesString());
955  }
956 
957  if (memberCount > maxProperties_) {
958  context.error_handler.TooManyProperties(memberCount, maxProperties_);
959  RAPIDJSON_INVALID_KEYWORD_RETURN(GetMaxPropertiesString());
960  }
961 
962  if (hasDependencies_) {
963  context.error_handler.StartDependencyErrors();
964  for (SizeType sourceIndex = 0; sourceIndex < propertyCount_; sourceIndex++) {
965  const Property& source = properties_[sourceIndex];
966  if (context.propertyExist[sourceIndex]) {
967  if (source.dependencies) {
968  context.error_handler.StartMissingDependentProperties();
969  for (SizeType targetIndex = 0; targetIndex < propertyCount_; targetIndex++)
970  if (source.dependencies[targetIndex] && !context.propertyExist[targetIndex])
971  context.error_handler.AddMissingDependentProperty(properties_[targetIndex].name);
972  context.error_handler.EndMissingDependentProperties(source.name);
973  }
974  else if (source.dependenciesSchema) {
975  ISchemaValidator* dependenciesValidator = context.validators[source.dependenciesValidatorIndex];
976  if (!dependenciesValidator->IsValid())
977  context.error_handler.AddDependencySchemaError(source.name, dependenciesValidator);
978  }
979  }
980  }
981  if (context.error_handler.EndDependencyErrors())
982  RAPIDJSON_INVALID_KEYWORD_RETURN(GetDependenciesString());
983  }
984 
985  return true;
986  }
static QCString name
Definition: declinfo.cpp:673
bool hasRequired_
Definition: schema.h:1417
const CharType(& source)[N]
Definition: pointer.h:1147
SizeType minProperties_
Definition: schema.h:1413
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
Definition: rapidjson.h:384
SizeType maxProperties_
Definition: schema.h:1414
SizeType propertyCount_
Definition: schema.h:1412
#define RAPIDJSON_INVALID_KEYWORD_RETURN(keyword)
Definition: schema.h:116
bool hasDependencies_
Definition: schema.h:1416
Property * properties_
Definition: schema.h:1408
Definition: types.h:32
template<typename SchemaDocumentType >
RAPIDJSON_FORCEINLINE bool internal::Schema< SchemaDocumentType >::EndValue ( Context context) const
inline

Definition at line 703 of file schema.h.

703  {
704  if (context.patternPropertiesValidatorCount > 0) {
705  bool otherValid = false;
706  SizeType count = context.patternPropertiesValidatorCount;
707  if (context.objectPatternValidatorType != Context::kPatternValidatorOnly)
708  otherValid = context.patternPropertiesValidators[--count]->IsValid();
709 
710  bool patternValid = true;
711  for (SizeType i = 0; i < count; i++)
712  if (!context.patternPropertiesValidators[i]->IsValid()) {
713  patternValid = false;
714  break;
715  }
716 
717  if (context.objectPatternValidatorType == Context::kPatternValidatorOnly) {
718  if (!patternValid) {
719  context.error_handler.PropertyViolations(context.patternPropertiesValidators, count);
720  RAPIDJSON_INVALID_KEYWORD_RETURN(GetPatternPropertiesString());
721  }
722  }
723  else if (context.objectPatternValidatorType == Context::kPatternValidatorWithProperty) {
724  if (!patternValid || !otherValid) {
725  context.error_handler.PropertyViolations(context.patternPropertiesValidators, count + 1);
726  RAPIDJSON_INVALID_KEYWORD_RETURN(GetPatternPropertiesString());
727  }
728  }
729  else if (!patternValid && !otherValid) { // kPatternValidatorWithAdditionalProperty)
730  context.error_handler.PropertyViolations(context.patternPropertiesValidators, count + 1);
731  RAPIDJSON_INVALID_KEYWORD_RETURN(GetPatternPropertiesString());
732  }
733  }
734 
735  if (enum_) {
736  const uint64_t h = context.factory.GetHashCode(context.hasher);
737  for (SizeType i = 0; i < enumCount_; i++)
738  if (enum_[i] == h)
739  goto foundEnum;
740  context.error_handler.DisallowedValue();
741  RAPIDJSON_INVALID_KEYWORD_RETURN(GetEnumString());
742  foundEnum:;
743  }
744 
745  if (allOf_.schemas)
746  for (SizeType i = allOf_.begin; i < allOf_.begin + allOf_.count; i++)
747  if (!context.validators[i]->IsValid()) {
748  context.error_handler.NotAllOf(&context.validators[allOf_.begin], allOf_.count);
749  RAPIDJSON_INVALID_KEYWORD_RETURN(GetAllOfString());
750  }
751 
752  if (anyOf_.schemas) {
753  for (SizeType i = anyOf_.begin; i < anyOf_.begin + anyOf_.count; i++)
754  if (context.validators[i]->IsValid())
755  goto foundAny;
756  context.error_handler.NoneOf(&context.validators[anyOf_.begin], anyOf_.count);
757  RAPIDJSON_INVALID_KEYWORD_RETURN(GetAnyOfString());
758  foundAny:;
759  }
760 
761  if (oneOf_.schemas) {
762  bool oneValid = false;
763  for (SizeType i = oneOf_.begin; i < oneOf_.begin + oneOf_.count; i++)
764  if (context.validators[i]->IsValid()) {
765  if (oneValid) {
766  context.error_handler.NotOneOf(&context.validators[oneOf_.begin], oneOf_.count);
767  RAPIDJSON_INVALID_KEYWORD_RETURN(GetOneOfString());
768  } else
769  oneValid = true;
770  }
771  if (!oneValid) {
772  context.error_handler.NotOneOf(&context.validators[oneOf_.begin], oneOf_.count);
773  RAPIDJSON_INVALID_KEYWORD_RETURN(GetOneOfString());
774  }
775  }
776 
777  if (not_ && context.validators[notValidatorIndex_]->IsValid()) {
778  context.error_handler.Disallowed();
779  RAPIDJSON_INVALID_KEYWORD_RETURN(GetNotString());
780  }
781 
782  return true;
783  }
SizeType enumCount_
Definition: schema.h:1399
SchemaArray allOf_
Definition: schema.h:1400
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
Definition: rapidjson.h:384
const SchemaType ** schemas
Definition: schema.h:1084
SizeType notValidatorIndex_
Definition: schema.h:1406
uint64_t * enum_
Definition: schema.h:1398
SchemaArray anyOf_
Definition: schema.h:1401
const SchemaType * not_
Definition: schema.h:1403
unsigned __int64 uint64_t
Definition: stdint.h:136
#define RAPIDJSON_INVALID_KEYWORD_RETURN(keyword)
Definition: schema.h:116
h
training ###############################
Definition: train_cnn.py:186
SchemaArray oneOf_
Definition: schema.h:1402
template<typename SchemaDocumentType >
bool internal::Schema< SchemaDocumentType >::FindPropertyIndex ( const ValueType name,
SizeType outIndex 
) const
inlineprivate

Definition at line 1219 of file schema.h.

1219  {
1220  SizeType len = name.GetStringLength();
1221  const Ch* str = name.GetString();
1222  for (SizeType index = 0; index < propertyCount_; index++)
1223  if (properties_[index].name.GetStringLength() == len &&
1224  (std::memcmp(properties_[index].name.GetString(), str, sizeof(Ch) * len) == 0))
1225  {
1226  *outIndex = index;
1227  return true;
1228  }
1229  return false;
1230  }
static QCString name
Definition: declinfo.cpp:673
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
Definition: rapidjson.h:384
SizeType propertyCount_
Definition: schema.h:1412
Property * properties_
Definition: schema.h:1408
static QCString str
EncodingType::Ch Ch
Definition: schema.h:402
template<typename SchemaDocumentType >
static const ValueType* internal::Schema< SchemaDocumentType >::GetMember ( const ValueType value,
const ValueType name 
)
inlinestaticprivate

Definition at line 1098 of file schema.h.

1098  {
1099  typename ValueType::ConstMemberIterator itr = value.FindMember(name);
1100  return itr != value.MemberEnd() ? &(itr->value) : 0;
1101  }
static QCString name
Definition: declinfo.cpp:673
const GenericPointer< typename T::ValueType > T2 value
Definition: pointer.h:1225
template<typename SchemaDocumentType >
const PointerType& internal::Schema< SchemaDocumentType >::GetPointer ( ) const
inline

Definition at line 672 of file schema.h.

672  {
673  return pointer_;
674  }
PointerType pointer_
Definition: schema.h:1396
template<typename SchemaDocumentType >
const SValue& internal::Schema< SchemaDocumentType >::GetURI ( ) const
inline

Definition at line 668 of file schema.h.

668  {
669  return uri_;
670  }
template<typename SchemaDocumentType >
bool internal::Schema< SchemaDocumentType >::Int ( Context context,
int  i 
) const
inline

Definition at line 801 of file schema.h.

801  {
802  if (!CheckInt(context, i))
803  return false;
804  return CreateParallelValidator(context);
805  }
bool CreateParallelValidator(Context &context) const
Definition: schema.h:1182
bool CheckInt(Context &context, int64_t i) const
Definition: schema.h:1232
template<typename SchemaDocumentType >
bool internal::Schema< SchemaDocumentType >::Int64 ( Context context,
int64_t  i 
) const
inline

Definition at line 813 of file schema.h.

813  {
814  if (!CheckInt(context, i))
815  return false;
816  return CreateParallelValidator(context);
817  }
bool CreateParallelValidator(Context &context) const
Definition: schema.h:1182
bool CheckInt(Context &context, int64_t i) const
Definition: schema.h:1232
template<typename SchemaDocumentType >
static bool internal::Schema< SchemaDocumentType >::IsPatternMatch ( const RegexType pattern,
const Ch str,
SizeType   
)
inlinestaticprivate

Definition at line 1145 of file schema.h.

1145  {
1146  GenericRegexSearch<RegexType> rs(*pattern);
1147  return rs.Search(str);
1148  }
std::string pattern
Definition: regex_t.cc:33
static QCString str
template<typename SchemaDocumentType >
bool internal::Schema< SchemaDocumentType >::Key ( Context context,
const Ch str,
SizeType  len,
bool   
) const
inline

Definition at line 892 of file schema.h.

892  {
893  if (patternProperties_) {
894  context.patternPropertiesSchemaCount = 0;
895  for (SizeType i = 0; i < patternPropertyCount_; i++)
897  context.patternPropertiesSchemas[context.patternPropertiesSchemaCount++] = patternProperties_[i].schema;
898  context.valueSchema = typeless_;
899  }
900  }
901 
902  SizeType index;
903  if (FindPropertyIndex(ValueType(str, len).Move(), &index)) {
904  if (context.patternPropertiesSchemaCount > 0) {
905  context.patternPropertiesSchemas[context.patternPropertiesSchemaCount++] = properties_[index].schema;
906  context.valueSchema = typeless_;
907  context.valuePatternValidatorType = Context::kPatternValidatorWithProperty;
908  }
909  else
910  context.valueSchema = properties_[index].schema;
911 
912  if (context.propertyExist)
913  context.propertyExist[index] = true;
914 
915  return true;
916  }
917 
919  if (additionalPropertiesSchema_ && context.patternPropertiesSchemaCount > 0) {
920  context.patternPropertiesSchemas[context.patternPropertiesSchemaCount++] = additionalPropertiesSchema_;
921  context.valueSchema = typeless_;
922  context.valuePatternValidatorType = Context::kPatternValidatorWithAdditionalProperty;
923  }
924  else
925  context.valueSchema = additionalPropertiesSchema_;
926  return true;
927  }
928  else if (additionalProperties_) {
929  context.valueSchema = typeless_;
930  return true;
931  }
932 
933  if (context.patternPropertiesSchemaCount == 0) { // patternProperties are not additional properties
934  context.error_handler.DisallowedProperty(str, len);
935  RAPIDJSON_INVALID_KEYWORD_RETURN(GetAdditionalPropertiesString());
936  }
937 
938  return true;
939  }
SizeType patternPropertyCount_
Definition: schema.h:1411
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
Definition: rapidjson.h:384
static bool IsPatternMatch(const RegexType *pattern, const Ch *str, SizeType)
Definition: schema.h:1145
const SchemaType * typeless_
Definition: schema.h:1397
PatternProperty * patternProperties_
Definition: schema.h:1410
const SchemaType * additionalPropertiesSchema_
Definition: schema.h:1409
#define RAPIDJSON_INVALID_KEYWORD_RETURN(keyword)
Definition: schema.h:116
const SchemaType * schema
Definition: schema.h:1375
SchemaDocumentType::ValueType ValueType
Definition: schema.h:398
Property * properties_
Definition: schema.h:1408
std::string pattern
Definition: regex_t.cc:33
const SchemaType * schema
Definition: schema.h:1390
bool additionalProperties_
Definition: schema.h:1415
bool FindPropertyIndex(const ValueType &name, SizeType *outIndex) const
Definition: schema.h:1219
static QCString str
template<typename SchemaDocumentType >
bool internal::Schema< SchemaDocumentType >::Null ( Context context) const
inline

Definition at line 785 of file schema.h.

785  {
786  if (!(type_ & (1 << kNullSchemaType))) {
787  DisallowedType(context, GetNullString());
788  RAPIDJSON_INVALID_KEYWORD_RETURN(GetTypeString());
789  }
790  return CreateParallelValidator(context);
791  }
bool CreateParallelValidator(Context &context) const
Definition: schema.h:1182
unsigned type_
Definition: schema.h:1404
void DisallowedType(Context &context, const ValueType &actualType) const
Definition: schema.h:1355
#define RAPIDJSON_INVALID_KEYWORD_RETURN(keyword)
Definition: schema.h:116
template<typename SchemaDocumentType >
bool internal::Schema< SchemaDocumentType >::StartArray ( Context context) const
inline

Definition at line 988 of file schema.h.

988  {
989  if (!(type_ & (1 << kArraySchemaType))) {
990  DisallowedType(context, GetArrayString());
991  RAPIDJSON_INVALID_KEYWORD_RETURN(GetTypeString());
992  }
993 
994  context.arrayElementIndex = 0;
995  context.inArray = true;
996 
997  return CreateParallelValidator(context);
998  }
bool CreateParallelValidator(Context &context) const
Definition: schema.h:1182
unsigned type_
Definition: schema.h:1404
void DisallowedType(Context &context, const ValueType &actualType) const
Definition: schema.h:1355
#define RAPIDJSON_INVALID_KEYWORD_RETURN(keyword)
Definition: schema.h:116
template<typename SchemaDocumentType >
bool internal::Schema< SchemaDocumentType >::StartObject ( Context context) const
inline

Definition at line 871 of file schema.h.

871  {
872  if (!(type_ & (1 << kObjectSchemaType))) {
873  DisallowedType(context, GetObjectString());
874  RAPIDJSON_INVALID_KEYWORD_RETURN(GetTypeString());
875  }
876 
878  context.propertyExist = static_cast<bool*>(context.factory.MallocState(sizeof(bool) * propertyCount_));
879  std::memset(context.propertyExist, 0, sizeof(bool) * propertyCount_);
880  }
881 
882  if (patternProperties_) { // pre-allocate schema array
883  SizeType count = patternPropertyCount_ + 1; // extra for valuePatternValidatorType
884  context.patternPropertiesSchemas = static_cast<const SchemaType**>(context.factory.MallocState(sizeof(const SchemaType*) * count));
885  context.patternPropertiesSchemaCount = 0;
886  std::memset(context.patternPropertiesSchemas, 0, sizeof(SchemaType*) * count);
887  }
888 
889  return CreateParallelValidator(context);
890  }
bool hasRequired_
Definition: schema.h:1417
SizeType patternPropertyCount_
Definition: schema.h:1411
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
Definition: rapidjson.h:384
Schema< SchemaDocumentType > SchemaType
Definition: schema.h:404
PatternProperty * patternProperties_
Definition: schema.h:1410
bool CreateParallelValidator(Context &context) const
Definition: schema.h:1182
unsigned type_
Definition: schema.h:1404
SizeType propertyCount_
Definition: schema.h:1412
void DisallowedType(Context &context, const ValueType &actualType) const
Definition: schema.h:1355
#define RAPIDJSON_INVALID_KEYWORD_RETURN(keyword)
Definition: schema.h:116
bool hasDependencies_
Definition: schema.h:1416
template<typename SchemaDocumentType >
bool internal::Schema< SchemaDocumentType >::String ( Context context,
const Ch str,
SizeType  length,
bool   
) const
inline

Definition at line 843 of file schema.h.

843  {
844  if (!(type_ & (1 << kStringSchemaType))) {
845  DisallowedType(context, GetStringString());
846  RAPIDJSON_INVALID_KEYWORD_RETURN(GetTypeString());
847  }
848 
849  if (minLength_ != 0 || maxLength_ != SizeType(~0)) {
850  SizeType count;
851  if (internal::CountStringCodePoint<EncodingType>(str, length, &count)) {
852  if (count < minLength_) {
853  context.error_handler.TooShort(str, length, minLength_);
854  RAPIDJSON_INVALID_KEYWORD_RETURN(GetMinLengthString());
855  }
856  if (count > maxLength_) {
857  context.error_handler.TooLong(str, length, maxLength_);
858  RAPIDJSON_INVALID_KEYWORD_RETURN(GetMaxLengthString());
859  }
860  }
861  }
862 
863  if (pattern_ && !IsPatternMatch(pattern_, str, length)) {
864  context.error_handler.DoesNotMatch(str, length);
865  RAPIDJSON_INVALID_KEYWORD_RETURN(GetPatternString());
866  }
867 
868  return CreateParallelValidator(context);
869  }
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
Definition: rapidjson.h:384
static bool IsPatternMatch(const RegexType *pattern, const Ch *str, SizeType)
Definition: schema.h:1145
bool CreateParallelValidator(Context &context) const
Definition: schema.h:1182
unsigned type_
Definition: schema.h:1404
void DisallowedType(Context &context, const ValueType &actualType) const
Definition: schema.h:1355
#define RAPIDJSON_INVALID_KEYWORD_RETURN(keyword)
Definition: schema.h:116
SizeType maxLength_
Definition: schema.h:1431
RegexType * pattern_
Definition: schema.h:1429
SizeType minLength_
Definition: schema.h:1430
static QCString str
template<typename SchemaDocumentType >
bool internal::Schema< SchemaDocumentType >::Uint ( Context context,
unsigned  u 
) const
inline

Definition at line 807 of file schema.h.

807  {
808  if (!CheckUint(context, u))
809  return false;
810  return CreateParallelValidator(context);
811  }
bool CreateParallelValidator(Context &context) const
Definition: schema.h:1182
bool CheckUint(Context &context, uint64_t i) const
Definition: schema.h:1280
template<typename SchemaDocumentType >
bool internal::Schema< SchemaDocumentType >::Uint64 ( Context context,
uint64_t  u 
) const
inline

Definition at line 819 of file schema.h.

819  {
820  if (!CheckUint(context, u))
821  return false;
822  return CreateParallelValidator(context);
823  }
bool CreateParallelValidator(Context &context) const
Definition: schema.h:1182
bool CheckUint(Context &context, uint64_t i) const
Definition: schema.h:1280

Friends And Related Function Documentation

template<typename SchemaDocumentType >
friend class GenericSchemaDocument< ValueType, AllocatorType >
friend

Definition at line 407 of file schema.h.

Member Data Documentation

template<typename SchemaDocumentType >
bool internal::Schema< SchemaDocumentType >::additionalItems_
private

Definition at line 1426 of file schema.h.

template<typename SchemaDocumentType >
const SchemaType* internal::Schema< SchemaDocumentType >::additionalItemsSchema_
private

Definition at line 1420 of file schema.h.

template<typename SchemaDocumentType >
bool internal::Schema< SchemaDocumentType >::additionalProperties_
private

Definition at line 1415 of file schema.h.

template<typename SchemaDocumentType >
const SchemaType* internal::Schema< SchemaDocumentType >::additionalPropertiesSchema_
private

Definition at line 1409 of file schema.h.

template<typename SchemaDocumentType >
AllocatorType* internal::Schema< SchemaDocumentType >::allocator_
private

Definition at line 1394 of file schema.h.

template<typename SchemaDocumentType >
SchemaArray internal::Schema< SchemaDocumentType >::allOf_
private

Definition at line 1400 of file schema.h.

template<typename SchemaDocumentType >
SchemaArray internal::Schema< SchemaDocumentType >::anyOf_
private

Definition at line 1401 of file schema.h.

template<typename SchemaDocumentType >
SizeType internal::Schema< SchemaDocumentType >::defaultValueLength_
private

Definition at line 1439 of file schema.h.

template<typename SchemaDocumentType >
uint64_t* internal::Schema< SchemaDocumentType >::enum_
private

Definition at line 1398 of file schema.h.

template<typename SchemaDocumentType >
SizeType internal::Schema< SchemaDocumentType >::enumCount_
private

Definition at line 1399 of file schema.h.

template<typename SchemaDocumentType >
bool internal::Schema< SchemaDocumentType >::exclusiveMaximum_
private

Definition at line 1437 of file schema.h.

template<typename SchemaDocumentType >
bool internal::Schema< SchemaDocumentType >::exclusiveMinimum_
private

Definition at line 1436 of file schema.h.

template<typename SchemaDocumentType >
bool internal::Schema< SchemaDocumentType >::hasDependencies_
private

Definition at line 1416 of file schema.h.

template<typename SchemaDocumentType >
bool internal::Schema< SchemaDocumentType >::hasRequired_
private

Definition at line 1417 of file schema.h.

template<typename SchemaDocumentType >
bool internal::Schema< SchemaDocumentType >::hasSchemaDependencies_
private

Definition at line 1418 of file schema.h.

template<typename SchemaDocumentType >
const SchemaType* internal::Schema< SchemaDocumentType >::itemsList_
private

Definition at line 1421 of file schema.h.

template<typename SchemaDocumentType >
const SchemaType** internal::Schema< SchemaDocumentType >::itemsTuple_
private

Definition at line 1422 of file schema.h.

template<typename SchemaDocumentType >
SizeType internal::Schema< SchemaDocumentType >::itemsTupleCount_
private

Definition at line 1423 of file schema.h.

template<typename SchemaDocumentType >
SValue internal::Schema< SchemaDocumentType >::maximum_
private

Definition at line 1434 of file schema.h.

template<typename SchemaDocumentType >
SizeType internal::Schema< SchemaDocumentType >::maxItems_
private

Definition at line 1425 of file schema.h.

template<typename SchemaDocumentType >
SizeType internal::Schema< SchemaDocumentType >::maxLength_
private

Definition at line 1431 of file schema.h.

template<typename SchemaDocumentType >
SizeType internal::Schema< SchemaDocumentType >::maxProperties_
private

Definition at line 1414 of file schema.h.

template<typename SchemaDocumentType >
SValue internal::Schema< SchemaDocumentType >::minimum_
private

Definition at line 1433 of file schema.h.

template<typename SchemaDocumentType >
SizeType internal::Schema< SchemaDocumentType >::minItems_
private

Definition at line 1424 of file schema.h.

template<typename SchemaDocumentType >
SizeType internal::Schema< SchemaDocumentType >::minLength_
private

Definition at line 1430 of file schema.h.

template<typename SchemaDocumentType >
SizeType internal::Schema< SchemaDocumentType >::minProperties_
private

Definition at line 1413 of file schema.h.

template<typename SchemaDocumentType >
SValue internal::Schema< SchemaDocumentType >::multipleOf_
private

Definition at line 1435 of file schema.h.

template<typename SchemaDocumentType >
const SchemaType* internal::Schema< SchemaDocumentType >::not_
private

Definition at line 1403 of file schema.h.

template<typename SchemaDocumentType >
SizeType internal::Schema< SchemaDocumentType >::notValidatorIndex_
private

Definition at line 1406 of file schema.h.

template<typename SchemaDocumentType >
SchemaArray internal::Schema< SchemaDocumentType >::oneOf_
private

Definition at line 1402 of file schema.h.

template<typename SchemaDocumentType >
RegexType* internal::Schema< SchemaDocumentType >::pattern_
private

Definition at line 1429 of file schema.h.

template<typename SchemaDocumentType >
PatternProperty* internal::Schema< SchemaDocumentType >::patternProperties_
private

Definition at line 1410 of file schema.h.

template<typename SchemaDocumentType >
SizeType internal::Schema< SchemaDocumentType >::patternPropertyCount_
private

Definition at line 1411 of file schema.h.

template<typename SchemaDocumentType >
PointerType internal::Schema< SchemaDocumentType >::pointer_
private

Definition at line 1396 of file schema.h.

template<typename SchemaDocumentType >
Property* internal::Schema< SchemaDocumentType >::properties_
private

Definition at line 1408 of file schema.h.

template<typename SchemaDocumentType >
SizeType internal::Schema< SchemaDocumentType >::propertyCount_
private

Definition at line 1412 of file schema.h.

template<typename SchemaDocumentType >
unsigned internal::Schema< SchemaDocumentType >::type_
private

Definition at line 1404 of file schema.h.

template<typename SchemaDocumentType >
const SchemaType* internal::Schema< SchemaDocumentType >::typeless_
private

Definition at line 1397 of file schema.h.

template<typename SchemaDocumentType >
bool internal::Schema< SchemaDocumentType >::uniqueItems_
private

Definition at line 1427 of file schema.h.

template<typename SchemaDocumentType >
SValue internal::Schema< SchemaDocumentType >::uri_
private

Definition at line 1395 of file schema.h.

template<typename SchemaDocumentType >
SizeType internal::Schema< SchemaDocumentType >::validatorCount_
private

Definition at line 1405 of file schema.h.


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