15 #ifndef RAPIDJSON_SCHEMA_H_
16 #define RAPIDJSON_SCHEMA_H_
22 #if !defined(RAPIDJSON_SCHEMA_USE_INTERNALREGEX)
23 #define RAPIDJSON_SCHEMA_USE_INTERNALREGEX 1
25 #define RAPIDJSON_SCHEMA_USE_INTERNALREGEX 0
28 #if !RAPIDJSON_SCHEMA_USE_INTERNALREGEX && !defined(RAPIDJSON_SCHEMA_USE_STDREGEX) && (__cplusplus >=201103L || (defined(_MSC_VER) && _MSC_VER >= 1800))
29 #define RAPIDJSON_SCHEMA_USE_STDREGEX 1
31 #define RAPIDJSON_SCHEMA_USE_STDREGEX 0
34 #if RAPIDJSON_SCHEMA_USE_INTERNALREGEX
36 #elif RAPIDJSON_SCHEMA_USE_STDREGEX
40 #if RAPIDJSON_SCHEMA_USE_INTERNALREGEX || RAPIDJSON_SCHEMA_USE_STDREGEX
41 #define RAPIDJSON_SCHEMA_HAS_REGEX 1
43 #define RAPIDJSON_SCHEMA_HAS_REGEX 0
46 #ifndef RAPIDJSON_SCHEMA_VERBOSE
47 #define RAPIDJSON_SCHEMA_VERBOSE 0
50 #if RAPIDJSON_SCHEMA_VERBOSE
57 RAPIDJSON_DIAG_OFF(effc++)
61 RAPIDJSON_DIAG_OFF(weak-vtables)
62 RAPIDJSON_DIAG_OFF(
exit-time-destructors)
63 RAPIDJSON_DIAG_OFF(c++98-compat-pedantic)
64 RAPIDJSON_DIAG_OFF(variadic-macros)
68 RAPIDJSON_DIAG_OFF(4512)
76 #if RAPIDJSON_SCHEMA_VERBOSE
80 inline void PrintInvalidKeyword(
const char* keyword) {
81 printf(
"Fail keyword: %s\n", keyword);
84 inline void PrintInvalidKeyword(
const wchar_t* keyword) {
85 wprintf(L
"Fail keyword: %ls\n", keyword);
88 inline void PrintInvalidDocument(
const char* document) {
89 printf(
"Fail document: %s\n\n", document);
92 inline void PrintInvalidDocument(
const wchar_t* document) {
93 wprintf(L
"Fail document: %ls\n\n", document);
96 inline void PrintValidatorPointers(
unsigned depth,
const char* s,
const char* d) {
97 printf(
"S: %*s%s\nD: %*s%s\n\n",
depth * 4,
" ", s,
depth * 4,
" ", d);
100 inline void PrintValidatorPointers(
unsigned depth,
const wchar_t* s,
const wchar_t* d) {
101 wprintf(L
"S: %*ls%ls\nD: %*ls%ls\n\n",
depth * 4, L
" ", s,
depth * 4, L
" ", d);
111 #if RAPIDJSON_SCHEMA_VERBOSE
112 #define RAPIDJSON_INVALID_KEYWORD_VERBOSE(keyword) internal::PrintInvalidKeyword(keyword)
114 #define RAPIDJSON_INVALID_KEYWORD_VERBOSE(keyword)
117 #define RAPIDJSON_INVALID_KEYWORD_RETURN(keyword)\
118 RAPIDJSON_MULTILINEMACRO_BEGIN\
119 context.invalidKeyword = keyword.GetString();\
120 RAPIDJSON_INVALID_KEYWORD_VERBOSE(keyword.GetString());\
122 RAPIDJSON_MULTILINEMACRO_END
127 template <
typename ValueType,
typename Allocator>
128 class GenericSchemaDocument;
132 template <
typename SchemaDocumentType>
147 template <
typename SchemaType>
164 template<
typename Encoding,
typename Allocator>
167 typedef typename Encoding::Ch
Ch;
169 Hasher(
Allocator* allocator = 0,
size_t stackCapacity = kDefaultSize) : stack_(allocator, stackCapacity) {}
173 bool Int(
int i) {
Number n;
n.u.i =
i;
n.d =
static_cast<double>(
i);
return WriteNumber(
n); }
174 bool Uint(
unsigned u) {
Number n;
n.u.u = u;
n.d =
static_cast<double>(u);
return WriteNumber(
n); }
179 if (d < 0)
n.u.i =
static_cast<int64_t>(d);
182 return WriteNumber(
n);
199 uint64_t* kv = stack_.template Pop<uint64_t>(memberCount * 2);
201 h ^=
Hash(kv[
i * 2], kv[
i * 2 + 1]);
202 *stack_.template Push<uint64_t>() = h;
209 uint64_t* e = stack_.template Pop<uint64_t>(elementCount);
212 *stack_.template Push<uint64_t>() = h;
220 return *stack_.template Top<uint64_t>();
224 static const size_t kDefaultSize = 256;
240 const unsigned char* d =
static_cast<const unsigned char*
>(
data);
241 for (
size_t i = 0;
i <
len;
i++)
243 *stack_.template Push<uint64_t>() = h;
260 template <
typename SchemaDocumentType>
265 typedef typename ValueType::Ch
Ch;
270 kPatternValidatorWithAdditionalProperty
279 arrayElementHashCodes(),
282 patternPropertiesValidators(),
283 patternPropertiesValidatorCount(),
284 patternPropertiesSchemas(),
285 patternPropertiesSchemaCount(),
286 valuePatternValidatorType(kPatternValidatorOnly),
289 valueUniqueness(
false),
290 arrayUniqueness(
false)
296 factory.DestroryHasher(hasher);
299 factory.DestroySchemaValidator(validators[
i]);
300 factory.FreeState(validators);
302 if (patternPropertiesValidators) {
303 for (
SizeType i = 0;
i < patternPropertiesValidatorCount;
i++)
304 factory.DestroySchemaValidator(patternPropertiesValidators[
i]);
305 factory.FreeState(patternPropertiesValidators);
307 if (patternPropertiesSchemas)
308 factory.FreeState(patternPropertiesSchemas);
310 factory.FreeState(propertyExist);
337 template <
typename SchemaDocumentType>
340 typedef typename SchemaDocumentType::ValueType
ValueType;
344 typedef typename EncodingType::Ch
Ch;
351 allocator_(allocator),
352 typeless_(schemaDocument->GetTypeless()),
356 type_((1 << kTotalSchemaType) - 1),
359 additionalPropertiesSchema_(),
360 patternProperties_(),
361 patternPropertyCount_(),
365 additionalProperties_(
true),
368 hasSchemaDependencies_(),
369 additionalItemsSchema_(),
375 additionalItems_(
true),
380 exclusiveMinimum_(
false),
381 exclusiveMaximum_(
false)
383 typedef typename ValueType::ConstValueIterator ConstValueIterator;
384 typedef typename ValueType::ConstMemberIterator ConstMemberIterator;
386 if (!
value.IsObject())
393 else if (v->IsArray())
394 for (ConstValueIterator itr = v->Begin(); itr != v->End(); ++itr)
399 if (v->IsArray() && v->Size() > 0) {
400 enum_ =
static_cast<uint64_t*
>(allocator_->Malloc(
sizeof(
uint64_t) * v->Size()));
401 for (ConstValueIterator itr = v->Begin(); itr != v->End(); ++itr) {
405 EnumHasherType h(&hasherAllocator, 256);
407 enum_[enumCount_++] = h.GetHashCode();
411 if (schemaDocument) {
412 AssignIfExist(allOf_, *schemaDocument, p,
value, GetAllOfString(), document);
413 AssignIfExist(anyOf_, *schemaDocument, p,
value, GetAnyOfString(), document);
414 AssignIfExist(oneOf_, *schemaDocument, p,
value, GetOneOfString(), document);
418 schemaDocument->CreateSchema(¬_, p.Append(GetNotString(), allocator_), *v, document);
419 notValidatorIndex_ = validatorCount_;
432 if (properties && properties->IsObject())
433 for (ConstMemberIterator itr = properties->MemberBegin(); itr != properties->MemberEnd(); ++itr)
434 AddUniqueElement(allProperties, itr->name);
436 if (required && required->IsArray())
437 for (ConstValueIterator itr = required->Begin(); itr != required->End(); ++itr)
439 AddUniqueElement(allProperties, *itr);
441 if (dependencies && dependencies->IsObject())
442 for (ConstMemberIterator itr = dependencies->MemberBegin(); itr != dependencies->MemberEnd(); ++itr) {
443 AddUniqueElement(allProperties, itr->name);
444 if (itr->value.IsArray())
445 for (ConstValueIterator
i = itr->value.Begin();
i != itr->value.End(); ++
i)
447 AddUniqueElement(allProperties, *
i);
450 if (allProperties.Size() > 0) {
451 propertyCount_ = allProperties.Size();
452 properties_ =
static_cast<Property*
>(allocator_->Malloc(
sizeof(
Property) * propertyCount_));
455 properties_[
i].
name = allProperties[
i];
456 properties_[
i].schema = typeless_;
461 if (properties && properties->IsObject()) {
462 PointerType q = p.Append(GetPropertiesString(), allocator_);
463 for (ConstMemberIterator itr = properties->MemberBegin(); itr != properties->MemberEnd(); ++itr) {
465 if (FindPropertyIndex(itr->name, &index))
466 schemaDocument->CreateSchema(&properties_[index].schema, q.Append(itr->name, allocator_), itr->value, document);
471 PointerType q = p.Append(GetPatternPropertiesString(), allocator_);
473 patternPropertyCount_ = 0;
475 for (ConstMemberIterator itr = v->MemberBegin(); itr != v->MemberEnd(); ++itr) {
477 patternProperties_[patternPropertyCount_].
pattern = CreatePattern(itr->name);
478 schemaDocument->CreateSchema(&patternProperties_[patternPropertyCount_].
schema, q.Append(itr->name, allocator_), itr->value, document);
479 patternPropertyCount_++;
483 if (required && required->IsArray())
484 for (ConstValueIterator itr = required->Begin(); itr != required->End(); ++itr)
485 if (itr->IsString()) {
487 if (FindPropertyIndex(*itr, &index)) {
488 properties_[index].required =
true;
493 if (dependencies && dependencies->IsObject()) {
494 PointerType q = p.Append(GetDependenciesString(), allocator_);
495 hasDependencies_ =
true;
496 for (ConstMemberIterator itr = dependencies->MemberBegin(); itr != dependencies->MemberEnd(); ++itr) {
498 if (FindPropertyIndex(itr->name, &sourceIndex)) {
499 if (itr->value.IsArray()) {
500 properties_[sourceIndex].dependencies =
static_cast<bool*
>(allocator_->Malloc(
sizeof(
bool) * propertyCount_));
501 std::memset(properties_[sourceIndex].dependencies, 0,
sizeof(
bool)* propertyCount_);
502 for (ConstValueIterator targetItr = itr->value.Begin(); targetItr != itr->value.End(); ++targetItr) {
504 if (FindPropertyIndex(*targetItr, &targetIndex))
505 properties_[sourceIndex].dependencies[targetIndex] =
true;
508 else if (itr->value.IsObject()) {
509 hasSchemaDependencies_ =
true;
510 schemaDocument->CreateSchema(&properties_[sourceIndex].dependenciesSchema, q.Append(itr->name, allocator_), itr->value, document);
511 properties_[sourceIndex].dependenciesValidatorIndex = validatorCount_;
520 additionalProperties_ = v->GetBool();
521 else if (v->IsObject())
522 schemaDocument->CreateSchema(&additionalPropertiesSchema_, p.Append(GetAdditionalPropertiesString(), allocator_), *v, document);
525 AssignIfExist(minProperties_,
value, GetMinPropertiesString());
526 AssignIfExist(maxProperties_,
value, GetMaxPropertiesString());
530 PointerType q = p.Append(GetItemsString(), allocator_);
532 schemaDocument->CreateSchema(&itemsList_, q, *v, document);
533 else if (v->IsArray()) {
534 itemsTuple_ =
static_cast<const Schema**
>(allocator_->Malloc(
sizeof(
const Schema*) * v->Size()));
536 for (ConstValueIterator itr = v->Begin(); itr != v->End(); ++itr, index++)
537 schemaDocument->CreateSchema(&itemsTuple_[itemsTupleCount_++], q.Append(index, allocator_), *itr, document);
541 AssignIfExist(minItems_,
value, GetMinItemsString());
542 AssignIfExist(maxItems_,
value, GetMaxItemsString());
546 additionalItems_ = v->GetBool();
547 else if (v->IsObject())
548 schemaDocument->CreateSchema(&additionalItemsSchema_, p.Append(GetAdditionalItemsString(), allocator_), *v, document);
551 AssignIfExist(uniqueItems_,
value, GetUniqueItemsString());
554 AssignIfExist(minLength_,
value, GetMinLengthString());
555 AssignIfExist(maxLength_,
value, GetMaxLengthString());
558 pattern_ = CreatePattern(*v);
563 minimum_.CopyFrom(*v, *allocator_);
567 maximum_.CopyFrom(*v, *allocator_);
569 AssignIfExist(exclusiveMinimum_,
value, GetExclusiveMinimumString());
570 AssignIfExist(exclusiveMaximum_,
value, GetExclusiveMaximumString());
573 if (v->IsNumber() && v->GetDouble() > 0.0)
574 multipleOf_.CopyFrom(*v, *allocator_);
584 if (patternProperties_) {
585 for (
SizeType i = 0;
i < patternPropertyCount_;
i++)
590 #if RAPIDJSON_SCHEMA_HAS_REGEX
592 pattern_->~RegexType();
601 context.valueUniqueness =
true;
604 context.valueSchema = itemsList_;
605 else if (itemsTuple_) {
606 if (
context.arrayElementIndex < itemsTupleCount_)
608 else if (additionalItemsSchema_)
609 context.valueSchema = additionalItemsSchema_;
610 else if (additionalItems_)
611 context.valueSchema = typeless_;
616 context.valueSchema = typeless_;
624 if (
context.patternPropertiesValidatorCount > 0) {
625 bool otherValid =
false;
627 if (
context.objectPatternValidatorType != Context::kPatternValidatorOnly)
628 otherValid =
context.patternPropertiesValidators[--
count]->IsValid();
630 bool patternValid =
true;
632 if (!
context.patternPropertiesValidators[
i]->IsValid()) {
633 patternValid =
false;
637 if (
context.objectPatternValidatorType == Context::kPatternValidatorOnly) {
641 else if (
context.objectPatternValidatorType == Context::kPatternValidatorWithProperty) {
642 if (!patternValid || !otherValid)
645 else if (!patternValid && !otherValid)
659 for (
SizeType i = allOf_.begin;
i < allOf_.begin + allOf_.count;
i++)
660 if (!
context.validators[
i]->IsValid())
663 if (anyOf_.schemas) {
664 for (
SizeType i = anyOf_.begin;
i < anyOf_.begin + anyOf_.count;
i++)
665 if (
context.validators[
i]->IsValid())
671 if (oneOf_.schemas) {
672 bool oneValid =
false;
673 for (
SizeType i = oneOf_.begin;
i < oneOf_.begin + oneOf_.count;
i++)
674 if (
context.validators[
i]->IsValid()) {
684 if (not_ &&
context.validators[notValidatorIndex_]->IsValid())
691 if (!(type_ & (1 << kNullSchemaType)))
693 return CreateParallelValidator(
context);
697 if (!(type_ & (1 << kBooleanSchemaType)))
699 return CreateParallelValidator(
context);
705 return CreateParallelValidator(
context);
711 return CreateParallelValidator(
context);
717 return CreateParallelValidator(
context);
723 return CreateParallelValidator(
context);
727 if (!(type_ & (1 << kNumberSchemaType)))
730 if (!minimum_.IsNull() && !CheckDoubleMinimum(
context, d))
733 if (!maximum_.IsNull() && !CheckDoubleMaximum(
context, d))
736 if (!multipleOf_.IsNull() && !CheckDoubleMultipleOf(
context, d))
739 return CreateParallelValidator(
context);
743 if (!(type_ & (1 << kStringSchemaType)))
746 if (minLength_ != 0 || maxLength_ !=
SizeType(~0)) {
748 if (internal::CountStringCodePoint<EncodingType>(
str, length, &
count)) {
749 if (
count < minLength_)
751 if (
count > maxLength_)
756 if (pattern_ && !IsPatternMatch(pattern_,
str, length))
759 return CreateParallelValidator(
context);
763 if (!(type_ & (1 << kObjectSchemaType)))
766 if (hasDependencies_ || hasRequired_) {
767 context.propertyExist =
static_cast<bool*
>(
context.factory.MallocState(
sizeof(
bool) * propertyCount_));
768 std::memset(
context.propertyExist, 0,
sizeof(
bool) * propertyCount_);
771 if (patternProperties_) {
774 context.patternPropertiesSchemaCount = 0;
778 return CreateParallelValidator(
context);
782 if (patternProperties_) {
783 context.patternPropertiesSchemaCount = 0;
784 for (
SizeType i = 0;
i < patternPropertyCount_;
i++)
785 if (patternProperties_[
i].pattern && IsPatternMatch(patternProperties_[
i].pattern,
str,
len))
786 context.patternPropertiesSchemas[
context.patternPropertiesSchemaCount++] = patternProperties_[
i].schema;
791 if (
context.patternPropertiesSchemaCount > 0) {
792 context.patternPropertiesSchemas[
context.patternPropertiesSchemaCount++] = properties_[index].schema;
793 context.valueSchema = typeless_;
794 context.valuePatternValidatorType = Context::kPatternValidatorWithProperty;
797 context.valueSchema = properties_[index].schema;
800 context.propertyExist[index] =
true;
805 if (additionalPropertiesSchema_) {
806 if (additionalPropertiesSchema_ &&
context.patternPropertiesSchemaCount > 0) {
807 context.patternPropertiesSchemas[
context.patternPropertiesSchemaCount++] = additionalPropertiesSchema_;
808 context.valueSchema = typeless_;
809 context.valuePatternValidatorType = Context::kPatternValidatorWithAdditionalProperty;
812 context.valueSchema = additionalPropertiesSchema_;
815 else if (additionalProperties_) {
816 context.valueSchema = typeless_;
820 if (
context.patternPropertiesSchemaCount == 0)
828 for (
SizeType index = 0; index < propertyCount_; index++)
829 if (properties_[index].required)
830 if (!
context.propertyExist[index])
833 if (memberCount < minProperties_)
836 if (memberCount > maxProperties_)
839 if (hasDependencies_) {
840 for (
SizeType sourceIndex = 0; sourceIndex < propertyCount_; sourceIndex++)
841 if (
context.propertyExist[sourceIndex]) {
842 if (properties_[sourceIndex].dependencies) {
843 for (
SizeType targetIndex = 0; targetIndex < propertyCount_; targetIndex++)
844 if (properties_[sourceIndex].dependencies[targetIndex] && !
context.propertyExist[targetIndex])
847 else if (properties_[sourceIndex].dependenciesSchema)
848 if (!
context.validators[properties_[sourceIndex].dependenciesValidatorIndex]->IsValid())
857 if (!(type_ & (1 << kArraySchemaType)))
863 return CreateParallelValidator(
context);
869 if (elementCount < minItems_)
872 if (elementCount > maxItems_)
879 #define RAPIDJSON_STRING_(name, ...) \
880 static const ValueType& Get##name##String() {\
881 static const Ch s[] = { __VA_ARGS__, '\0' };\
882 static const ValueType v(s, sizeof(s) / sizeof(Ch) - 1);\
899 RAPIDJSON_STRING_(Properties, 'p', '
r', 'o', 'p', 'e', '
r', '
t', '
i', 'e', 's')
901 RAPIDJSON_STRING_(Dependencies, 'd', 'e', 'p', 'e', '
n', 'd', 'e', '
n', 'c', '
i', 'e', 's')
902 RAPIDJSON_STRING_(PatternProperties, 'p', '
a', '
t', '
t', 'e', '
r', '
n', '
P', '
r', 'o', 'p', 'e', '
r', '
t', '
i', 'e', 's')
903 RAPIDJSON_STRING_(AdditionalProperties, '
a', 'd', 'd', '
i', '
t', '
i', 'o', '
n', '
a', '
l', '
P', '
r', 'o', 'p', 'e', '
r', '
t', '
i', 'e', 's')
904 RAPIDJSON_STRING_(MinProperties, 'm', '
i', '
n', '
P', '
r', 'o', 'p', 'e', '
r', '
t', '
i', 'e', 's')
905 RAPIDJSON_STRING_(MaxProperties, 'm', '
a', 'x', '
P', '
r', 'o', 'p', 'e', '
r', '
t', '
i', 'e', 's')
909 RAPIDJSON_STRING_(AdditionalItems, '
a', 'd', 'd', '
i', '
t', '
i', 'o', '
n', '
a', '
l', 'I', '
t', 'e', 'm', 's')
910 RAPIDJSON_STRING_(UniqueItems, 'u', '
n', '
i', 'q', 'u', 'e', 'I', '
t', 'e', 'm', 's')
916 RAPIDJSON_STRING_(ExclusiveMinimum, 'e', 'x', 'c', '
l', 'u', 's', '
i', 'v', 'e', '
M', '
i', '
n', '
i', 'm', 'u', 'm')
917 RAPIDJSON_STRING_(ExclusiveMaximum, 'e', 'x', 'c', '
l', 'u', 's', '
i', 'v', 'e', '
M', '
a', 'x', '
i', 'm', 'u', 'm')
918 RAPIDJSON_STRING_(MultipleOf, 'm', 'u', '
l', '
t', '
i', 'p', '
l', 'e', 'O', '
f')
920 #undef RAPIDJSON_STRING_
934 #if RAPIDJSON_SCHEMA_USE_INTERNALREGEX
936 #elif RAPIDJSON_SCHEMA_USE_STDREGEX
950 template <
typename V1,
typename V2>
952 for (
typename V1::ConstValueIterator itr =
a.Begin(); itr !=
a.End(); ++itr)
955 V1 c(v, *allocator_);
956 a.PushBack(c, *allocator_);
960 typename ValueType::ConstMemberIterator itr =
value.FindMember(name);
961 return itr !=
value.MemberEnd() ? &(itr->value) : 0;
972 if (v->IsUint64() && v->GetUint64() <=
SizeType(~0))
978 if (v->IsArray() && v->Size() > 0) {
980 out.count = v->Size();
981 out.schemas =
static_cast<const Schema**
>(allocator_->Malloc(
out.count *
sizeof(
const Schema*)));
984 schemaDocument.CreateSchema(&
out.schemas[
i], q.Append(
i, allocator_), (*v)[
i], document);
985 out.begin = validatorCount_;
986 validatorCount_ +=
out.count;
991 #if RAPIDJSON_SCHEMA_USE_INTERNALREGEX
992 template <
typename ValueType>
994 if (
value.IsString()) {
1010 #elif RAPIDJSON_SCHEMA_USE_STDREGEX
1011 template <
typename ValueType>
1012 RegexType* CreatePattern(
const ValueType&
value) {
1013 if (
value.IsString())
1015 return new (allocator_->Malloc(
sizeof(RegexType))) RegexType(
value.GetString(), std::size_t(
value.GetStringLength()), std::regex_constants::ECMAScript);
1017 catch (
const std::regex_error&) {
1022 static bool IsPatternMatch(
const RegexType* pattern,
const Ch *
str,
SizeType length) {
1023 std::match_results<const Ch*>
r;
1024 return std::regex_search(
str,
str + length,
r, *pattern);
1027 template <
typename ValueType>
1028 RegexType* CreatePattern(
const ValueType&) {
return 0; }
1030 static bool IsPatternMatch(
const RegexType*,
const Ch *,
SizeType) {
return true; }
1034 if (
type == GetNullString() ) type_ |= 1 << kNullSchemaType;
1035 else if (
type == GetBooleanString()) type_ |= 1 << kBooleanSchemaType;
1036 else if (
type == GetObjectString() ) type_ |= 1 << kObjectSchemaType;
1037 else if (
type == GetArrayString() ) type_ |= 1 << kArraySchemaType;
1038 else if (
type == GetStringString() ) type_ |= 1 << kStringSchemaType;
1039 else if (
type == GetIntegerString()) type_ |= 1 << kIntegerSchemaType;
1040 else if (
type == GetNumberString() ) type_ |= (1 << kNumberSchemaType) | (1 << kIntegerSchemaType);
1044 if (enum_ ||
context.arrayUniqueness)
1047 if (validatorCount_) {
1050 context.validatorCount = validatorCount_;
1053 CreateSchemaValidators(
context, allOf_);
1056 CreateSchemaValidators(
context, anyOf_);
1059 CreateSchemaValidators(
context, oneOf_);
1062 context.validators[notValidatorIndex_] =
context.factory.CreateSchemaValidator(*not_);
1064 if (hasSchemaDependencies_) {
1066 if (properties_[
i].dependenciesSchema)
1067 context.validators[properties_[
i].dependenciesValidatorIndex] =
context.factory.CreateSchemaValidator(*properties_[
i].dependenciesSchema);
1082 const Ch*
str = name.GetString();
1083 for (
SizeType index = 0; index < propertyCount_; index++)
1084 if (properties_[index].name.GetStringLength() ==
len &&
1085 (std::memcmp(properties_[index].name.GetString(),
str,
sizeof(
Ch) *
len) == 0))
1094 if (!(type_ & ((1 << kIntegerSchemaType) | (1 << kNumberSchemaType))))
1097 if (!minimum_.IsNull()) {
1098 if (minimum_.IsInt64()) {
1099 if (exclusiveMinimum_ ?
i <= minimum_.GetInt64() :
i < minimum_.GetInt64())
1102 else if (minimum_.IsUint64()) {
1105 else if (!CheckDoubleMinimum(
context,
static_cast<double>(
i)))
1109 if (!maximum_.IsNull()) {
1110 if (maximum_.IsInt64()) {
1111 if (exclusiveMaximum_ ?
i >= maximum_.GetInt64() :
i > maximum_.GetInt64())
1114 else if (maximum_.IsUint64())
1116 else if (!CheckDoubleMaximum(
context,
static_cast<double>(
i)))
1120 if (!multipleOf_.IsNull()) {
1121 if (multipleOf_.IsUint64()) {
1122 if (
static_cast<uint64_t>(
i >= 0 ?
i : -
i) % multipleOf_.GetUint64() != 0)
1125 else if (!CheckDoubleMultipleOf(
context,
static_cast<double>(
i)))
1133 if (!(type_ & ((1 << kIntegerSchemaType) | (1 << kNumberSchemaType))))
1136 if (!minimum_.IsNull()) {
1137 if (minimum_.IsUint64()) {
1138 if (exclusiveMinimum_ ?
i <= minimum_.GetUint64() :
i < minimum_.GetUint64())
1141 else if (minimum_.IsInt64())
1143 else if (!CheckDoubleMinimum(
context,
static_cast<double>(
i)))
1147 if (!maximum_.IsNull()) {
1148 if (maximum_.IsUint64()) {
1149 if (exclusiveMaximum_ ?
i >= maximum_.GetUint64() :
i > maximum_.GetUint64())
1152 else if (maximum_.IsInt64())
1154 else if (!CheckDoubleMaximum(
context,
static_cast<double>(
i)))
1158 if (!multipleOf_.IsNull()) {
1159 if (multipleOf_.IsUint64()) {
1160 if (
i % multipleOf_.GetUint64() != 0)
1163 else if (!CheckDoubleMultipleOf(
context,
static_cast<double>(
i)))
1171 if (exclusiveMinimum_ ? d <= minimum_.GetDouble() : d < minimum_.GetDouble())
1177 if (exclusiveMaximum_ ? d >= maximum_.GetDouble() : d > maximum_.GetDouble())
1184 double q = std::floor(
a /
b);
1185 double r =
a - q *
b;
1206 pattern->~RegexType();
1258 template<
typename Stack,
typename Ch>
1261 *documentStack.template Push<Ch>() =
'/';
1264 for (
size_t i = 0;
i < length;
i++)
1265 *documentStack.template Push<Ch>() =
static_cast<Ch
>(
buffer[
i]);
1270 template <
typename Stack>
1274 char *
buffer = documentStack.template Push<char>(1 + 10);
1277 documentStack.template Pop<char>(
static_cast<size_t>(10 - (end -
buffer)));
1280 char *
buffer = documentStack.template Push<char>(1 + 20);
1283 documentStack.template Pop<char>(
static_cast<size_t>(20 - (end -
buffer)));
1293 template <
typename SchemaDocumentType>
1296 typedef typename SchemaDocumentType::Ch
Ch;
1314 template <
typename ValueT,
typename Allocator = CrtAllocator>
1321 typedef typename EncodingType::Ch
Ch;
1325 template <
typename,
typename,
typename>
1337 remoteProvider_(remoteProvider),
1338 allocator_(allocator),
1342 schemaMap_(allocator, kInitialSchemaMapSize),
1343 schemaRef_(allocator, kInitialSchemaRefSize)
1353 CreateSchemaRecursive(&root_,
PointerType(), document, document);
1356 while (!schemaRef_.Empty()) {
1357 SchemaRefEntry* refEntry = schemaRef_.template Pop<SchemaRefEntry>(1);
1363 if (!GetSchema(refEntry->
source)) {
1367 else if (refEntry->
schema)
1368 *refEntry->
schema = typeless_;
1370 refEntry->~SchemaRefEntry();
1375 schemaRef_.ShrinkToFit();
1378 #if RAPIDJSON_HAS_CXX11_RVALUE_REFS
1381 remoteProvider_(rhs.remoteProvider_),
1382 allocator_(rhs.allocator_),
1383 ownAllocator_(rhs.ownAllocator_),
1385 typeless_(rhs.typeless_),
1386 schemaMap_(std::move(rhs.schemaMap_)),
1387 schemaRef_(std::move(rhs.schemaRef_))
1391 rhs.ownAllocator_ = 0;
1398 while (!schemaMap_.Empty())
1399 schemaMap_.template Pop<SchemaEntry>(1)->~SchemaEntry();
1402 typeless_->~SchemaType();
1447 for (
typename ValueType::ConstMemberIterator itr = v.MemberBegin(); itr != v.MemberEnd(); ++itr)
1448 CreateSchemaRecursive(0,
pointer.Append(itr->name, allocator_), itr->value, document);
1452 CreateSchemaRecursive(0,
pointer.Append(
i, allocator_), v[
i], document);
1460 new (schemaMap_.template Push<SchemaEntry>())
SchemaEntry(
pointer, s,
true, allocator_);
1468 static const Ch kRefString[] = {
'$',
'r',
'e',
'f',
'\0' };
1469 static const ValueType kRefValue(kRefString, 4);
1471 typename ValueType::ConstMemberIterator itr = v.FindMember(kRefValue);
1472 if (itr == v.MemberEnd())
1475 if (itr->value.IsString()) {
1478 const Ch* s = itr->value.GetString();
1480 while (
i <
len && s[
i] !=
'#')
1484 if (remoteProvider_) {
1497 else if (s[
i] ==
'#') {
1514 for (
const SchemaEntry* target = schemaMap_.template Bottom<SchemaEntry>(); target != schemaMap_.template End<SchemaEntry>(); ++target)
1515 if (
pointer == target->pointer)
1516 return target->schema;
1521 for (
const SchemaEntry* target = schemaMap_.template Bottom<SchemaEntry>(); target != schemaMap_.template End<SchemaEntry>(); ++target)
1522 if (
schema == target->schema)
1523 return target->pointer;
1529 static const size_t kInitialSchemaMapSize = 64;
1530 static const size_t kInitialSchemaRefSize = 64;
1562 typename SchemaDocumentType,
1573 typedef typename EncodingType::Ch
Ch;
1583 const SchemaDocumentType& schemaDocument,
1584 StateAllocator* allocator = 0,
1585 size_t schemaStackCapacity = kDefaultSchemaStackCapacity,
1586 size_t documentStackCapacity = kDefaultDocumentStackCapacity)
1588 schemaDocument_(&schemaDocument),
1589 root_(schemaDocument.GetRoot()),
1590 stateAllocator_(allocator),
1591 ownStateAllocator_(0),
1592 schemaStack_(allocator, schemaStackCapacity),
1593 documentStack_(allocator, documentStackCapacity),
1594 outputHandler_(CreateNullHandler()),
1601 , invalidSchemaKeyword_(0)
1614 const SchemaDocumentType& schemaDocument,
1615 OutputHandler& outputHandler,
1616 StateAllocator* allocator = 0,
1617 size_t schemaStackCapacity = kDefaultSchemaStackCapacity,
1618 size_t documentStackCapacity = kDefaultDocumentStackCapacity)
1620 schemaDocument_(&schemaDocument),
1621 root_(schemaDocument.GetRoot()),
1622 stateAllocator_(allocator),
1623 ownStateAllocator_(0),
1624 schemaStack_(allocator, schemaStackCapacity),
1625 documentStack_(allocator, documentStackCapacity),
1626 outputHandler_(outputHandler),
1634 , invalidSchemaKeyword_(0)
1643 nullHandler_->~OutputHandler();
1651 while (!schemaStack_.Empty())
1653 documentStack_.Clear();
1657 invalidSchemaKeyword_ = 0;
1668 return invalidSchemaKeyword_ ? invalidSchemaPointer_ : (schemaStack_.Empty() ?
PointerType() : schemaDocument_->GetPointer(&CurrentSchema()));
1673 return invalidSchemaKeyword_ ? invalidSchemaKeyword_ : (schemaStack_.Empty() ? 0 : CurrentContext().invalidKeyword);
1678 return invalidSchemaKeyword_ ? invalidDocumentPointer_ : (documentStack_.Empty() ?
PointerType() :
PointerType(documentStack_.template Bottom<Ch>(), documentStack_.GetSize() /
sizeof(
Ch)));
1681 #if RAPIDJSON_SCHEMA_VERBOSE
1682 #define RAPIDJSON_SCHEMA_HANDLE_BEGIN_VERBOSE_() \
1683 RAPIDJSON_MULTILINEMACRO_BEGIN\
1684 *documentStack_.template Push<Ch>() = '\0';\
1685 documentStack_.template Pop<Ch>(1);\
1686 internal::PrintInvalidDocument(documentStack_.template Bottom<Ch>());\
1687 RAPIDJSON_MULTILINEMACRO_END
1689 #define RAPIDJSON_SCHEMA_HANDLE_BEGIN_VERBOSE_()
1692 #define RAPIDJSON_SCHEMA_HANDLE_BEGIN_(method, arg1)\
1693 if (!valid_) return false; \
1694 if (!BeginValue() || !CurrentSchema().method arg1) {\
1695 RAPIDJSON_SCHEMA_HANDLE_BEGIN_VERBOSE_();\
1696 return valid_ = false;\
1699 #define RAPIDJSON_SCHEMA_HANDLE_PARALLEL_(method, arg2)\
1700 for (Context* context = schemaStack_.template Bottom<Context>(); context != schemaStack_.template End<Context>(); context++) {\
1701 if (context->hasher)\
1702 static_cast<HasherType*>(context->hasher)->method arg2;\
1703 if (context->validators)\
1704 for (SizeType i_ = 0; i_ < context->validatorCount; i_++)\
1705 static_cast<GenericSchemaValidator*>(context->validators[i_])->method arg2;\
1706 if (context->patternPropertiesValidators)\
1707 for (SizeType i_ = 0; i_ < context->patternPropertiesValidatorCount; i_++)\
1708 static_cast<GenericSchemaValidator*>(context->patternPropertiesValidators[i_])->method arg2;\
1711 #define RAPIDJSON_SCHEMA_HANDLE_END_(method, arg2)\
1712 return valid_ = EndValue() && outputHandler_.method arg2
1714 #define RAPIDJSON_SCHEMA_HANDLE_VALUE_(method, arg1, arg2) \
1715 RAPIDJSON_SCHEMA_HANDLE_BEGIN_ (method, arg1);\
1716 RAPIDJSON_SCHEMA_HANDLE_PARALLEL_(method, arg2);\
1717 RAPIDJSON_SCHEMA_HANDLE_END_ (method, arg2)
1734 return valid_ = outputHandler_.StartObject();
1738 if (!valid_)
return false;
1740 if (!CurrentSchema().Key(CurrentContext(),
str,
len,
copy))
return valid_ =
false;
1742 return valid_ = outputHandler_.Key(
str,
len,
copy);
1746 if (!valid_)
return false;
1748 if (!CurrentSchema().EndObject(CurrentContext(), memberCount))
return valid_ =
false;
1755 return valid_ = outputHandler_.StartArray();
1759 if (!valid_)
return false;
1761 if (!CurrentSchema().EndArray(CurrentContext(), elementCount))
return valid_ =
false;
1765 #undef RAPIDJSON_SCHEMA_HANDLE_BEGIN_VERBOSE_
1766 #undef RAPIDJSON_SCHEMA_HANDLE_BEGIN_
1767 #undef RAPIDJSON_SCHEMA_HANDLE_PARALLEL_
1768 #undef RAPIDJSON_SCHEMA_HANDLE_VALUE_
1776 &GetStateAllocator());
1790 return static_cast<HasherType*
>(hasher)->GetHashCode();
1800 return GetStateAllocator().Malloc(
size);
1813 const SchemaDocumentType& schemaDocument,
1818 StateAllocator* allocator = 0,
1819 size_t schemaStackCapacity = kDefaultSchemaStackCapacity,
1820 size_t documentStackCapacity = kDefaultDocumentStackCapacity)
1822 schemaDocument_(&schemaDocument),
1824 stateAllocator_(allocator),
1825 ownStateAllocator_(0),
1826 schemaStack_(allocator, schemaStackCapacity),
1827 documentStack_(allocator, documentStackCapacity),
1828 outputHandler_(CreateNullHandler()),
1835 , invalidSchemaKeyword_(0)
1841 if (!stateAllocator_)
1842 stateAllocator_ = ownStateAllocator_ =
RAPIDJSON_NEW(StateAllocator)();
1843 return *stateAllocator_;
1847 if (schemaStack_.Empty())
1850 if (CurrentContext().inArray)
1853 if (!CurrentSchema().BeginValue(CurrentContext()))
1856 SizeType count = CurrentContext().patternPropertiesSchemaCount;
1857 const SchemaType** sa = CurrentContext().patternPropertiesSchemas;
1858 typename Context::PatternValidatorType patternValidatorType = CurrentContext().valuePatternValidatorType;
1859 bool valueUniqueness = CurrentContext().valueUniqueness;
1861 PushSchema(*CurrentContext().valueSchema);
1864 CurrentContext().objectPatternValidatorType = patternValidatorType;
1865 ISchemaValidator**& va = CurrentContext().patternPropertiesValidators;
1866 SizeType& validatorCount = CurrentContext().patternPropertiesValidatorCount;
1867 va =
static_cast<ISchemaValidator**
>(MallocState(
sizeof(ISchemaValidator*) *
count));
1869 va[validatorCount++] = CreateSchemaValidator(*sa[
i]);
1872 CurrentContext().arrayUniqueness = valueUniqueness;
1878 if (!CurrentSchema().EndValue(CurrentContext()))
1881 #if RAPIDJSON_SCHEMA_VERBOSE
1883 schemaDocument_->GetPointer(&CurrentSchema()).Stringify(sb);
1885 *documentStack_.template Push<Ch>() =
'\0';
1886 documentStack_.template Pop<Ch>(1);
1887 internal::PrintValidatorPointers(depth_, sb.
GetString(), documentStack_.template Bottom<Ch>());
1890 uint64_t h = CurrentContext().arrayUniqueness ?
static_cast<HasherType*
>(CurrentContext().hasher)->GetHashCode() : 0;
1894 if (!schemaStack_.Empty()) {
1896 if (
context.valueUniqueness) {
1901 if (itr->GetUint64() == h)
1903 a->PushBack(h, GetStateAllocator());
1908 while (!documentStack_.Empty() && *documentStack_.template Pop<Ch>(1) !=
'/')
1915 documentStack_.template Reserve<Ch>(1 +
len * 2);
1916 *documentStack_.template PushUnsafe<Ch>() =
'/';
1918 if (
str[
i] ==
'~') {
1919 *documentStack_.template PushUnsafe<Ch>() =
'~';
1920 *documentStack_.template PushUnsafe<Ch>() =
'0';
1922 else if (
str[
i] ==
'/') {
1923 *documentStack_.template PushUnsafe<Ch>() =
'~';
1924 *documentStack_.template PushUnsafe<Ch>() =
'1';
1927 *documentStack_.template PushUnsafe<Ch>() =
str[
i];
1934 Context* c = schemaStack_.template Pop<Context>(1);
1936 a->~HashCodeArray();
1947 return *(nullHandler_ =
static_cast<OutputHandler*
>(GetStateAllocator().Malloc(
sizeof(OutputHandler))));
1950 static const size_t kDefaultSchemaStackCapacity = 1024;
1951 static const size_t kDefaultDocumentStackCapacity = 256;
1961 #if RAPIDJSON_SCHEMA_VERBOSE
1969 template <
typename ExtHandler>
1971 invalidSchemaPointer_ = validator.GetInvalidSchemaPointer();
1972 invalidSchemaKeyword_ = validator.GetInvalidSchemaKeyword();
1973 invalidDocumentPointer_ = validator.GetInvalidDocumentPointer();
1974 valid_ = invalidSchemaKeyword_ ==
nullptr;
1994 unsigned parseFlags,
1995 typename InputStream,
1996 typename SourceEncoding,
1998 typename StackAllocator = CrtAllocator>
2002 typedef typename InputStream::Ch
Ch;
2011 template <
typename Handler>
2015 parseResult_ = reader.template Parse<parseFlags>(is_, validator);
2017 isValid_ = validator.
IsValid();
2020 invalidSchemaKeyword_ = 0;
2029 return parseResult_;
2040 const SchemaDocumentType&
sd_;
static TObjectPtr GetMember(const CMemberInfo *memberInfo, TObjectPtr object)
Concept for allocating, resizing and freeing memory block.
C-runtime library allocator.
SAX-style JSON parser. Use Reader for UTF8 encoding and default allocator.
PointerType GetPointer(const SchemaType *schema) const
ValueType::EncodingType EncodingType
void CreateSchemaRecursive(const SchemaType **schema, const PointerType &pointer, const ValueType &v, const ValueType &document)
IRemoteSchemaDocumentProviderType * remoteProvider_
GenericSchemaDocument(const GenericSchemaDocument &)
Prohibit copying.
GenericPointer< ValueType, Allocator > PointerType
Allocator * ownAllocator_
GenericSchemaDocument & operator=(const GenericSchemaDocument &)
Prohibit assignment.
const SchemaType & GetRoot() const
Get the root schema.
internal::Schema< GenericSchemaDocument > SchemaType
IGenericRemoteSchemaDocumentProvider< GenericSchemaDocument > IRemoteSchemaDocumentProviderType
void CreateSchema(const SchemaType **schema, const PointerType &pointer, const ValueType &v, const ValueType &document)
GenericSchemaDocument(const ValueType &document, IRemoteSchemaDocumentProviderType *remoteProvider=0, Allocator *allocator=0)
Constructor.
bool HandleRefSchema(const PointerType &source, const SchemaType **schema, const ValueType &v, const ValueType &document)
internal::Stack< Allocator > schemaRef_
internal::Stack< Allocator > schemaMap_
const SchemaType * root_
Root schema.
~GenericSchemaDocument()
Destructor.
const SchemaType * GetTypeless() const
const SchemaType * GetSchema(const PointerType &pointer) const
const Ch * GetInvalidSchemaKeyword() const
Gets the keyword of invalid schema.
RAPIDJSON_FORCEINLINE void PushSchema(const SchemaType &schema)
SchemaDocumentType::SchemaType SchemaType
OutputHandler & CreateNullHandler()
StateAllocator & GetStateAllocator()
GenericSchemaValidator(const SchemaDocumentType &schemaDocument, OutputHandler &outputHandler, StateAllocator *allocator=0, size_t schemaStackCapacity=kDefaultSchemaStackCapacity, size_t documentStackCapacity=kDefaultDocumentStackCapacity)
Constructor with output handler.
PointerType invalidSchemaPointer_
void AppendToken(const Ch *str, SizeType len)
const Ch * invalidSchemaKeyword_
PointerType GetInvalidSchemaPointer() const
Gets the JSON pointer pointed to the invalid schema.
internal::Stack< StateAllocator > schemaStack_
stack to store the current path of schema (BaseSchemaType *)
const SchemaType & CurrentSchema() const
GenericSchemaValidator(const SchemaDocumentType &schemaDocument, const SchemaType &root, StateAllocator *allocator=0, size_t schemaStackCapacity=kDefaultSchemaStackCapacity, size_t documentStackCapacity=kDefaultDocumentStackCapacity)
StateAllocator * ownStateAllocator_
bool RawNumber(const Ch *str, SizeType length, bool copy)
internal::Hasher< EncodingType, StateAllocator > HasherType
PointerType GetInvalidDocumentPointer() const
Gets the JSON pointer pointed to the invalid value.
virtual void * MallocState(size_t size)
OutputHandler & outputHandler_
virtual uint64_t GetHashCode(void *hasher)
bool String(const Ch *str, SizeType length, bool copy)
bool EndArray(SizeType elementCount)
internal::Stack< StateAllocator > documentStack_
stack to store the current path of validating document (Ch)
SchemaDocumentType::PointerType PointerType
StateAllocator * stateAllocator_
SchemaType::EncodingType EncodingType
PointerType invalidDocumentPointer_
void SetValidationError(const ExtHandler &validator)
GenericSchemaValidator(const SchemaDocumentType &schemaDocument, StateAllocator *allocator=0, size_t schemaStackCapacity=kDefaultSchemaStackCapacity, size_t documentStackCapacity=kDefaultDocumentStackCapacity)
Constructor without output handler.
GenericValue< UTF8<>, StateAllocator > HashCodeArray
virtual void FreeState(void *p)
Context & CurrentContext()
virtual bool IsValid() const
Checks whether the current state is valid.
OutputHandler * nullHandler_
~GenericSchemaValidator()
Destructor.
const Context & CurrentContext() const
bool EndObject(SizeType memberCount)
virtual ISchemaValidator * CreateSchemaValidator(const SchemaType &root)
SchemaType::Context Context
RAPIDJSON_FORCEINLINE void PopSchema()
virtual void * CreateHasher()
virtual void DestroySchemaValidator(ISchemaValidator *validator)
const SchemaDocumentType * schemaDocument_
bool Key(const Ch *str, SizeType len, bool copy)
virtual void DestroryHasher(void *hasher)
void Reset()
Reset the internal states.
Represents an in-memory output stream.
const Ch * GetString() const
Concept for receiving events from GenericReader upon parsing. The functions return true if no error o...
virtual ~IGenericRemoteSchemaDocumentProvider()
virtual const SchemaDocumentType * GetRemoteDocument(const Ch *uri, SizeType length)=0
SchemaDocumentType::Ch Ch
Default memory allocator used by the parser and DOM.
A helper class for parsing with validation.
const PointerType & GetInvalidDocumentPointer() const
SchemaValidatingReader(InputStream &is, const SchemaDocumentType &sd)
Constructor.
PointerType invalidDocumentPointer_
const Ch * invalidSchemaKeyword_
SchemaDocumentType::PointerType PointerType
const Ch * GetInvalidSchemaKeyword() const
const ParseResult & GetParseResult() const
PointerType invalidSchemaPointer_
const SchemaDocumentType & sd_
bool operator()(Handler &handler)
const PointerType & GetInvalidSchemaPointer() const
bool Search(InputStream &is)
Regular expression engine with subset of ECMAscript grammar.
bool WriteBuffer(Type type, const void *data, size_t len)
bool WriteType(Type type)
bool WriteNumber(const Number &n)
static uint64_t Hash(uint64_t h, uint64_t d)
bool Key(const Ch *str, SizeType len, bool copy)
bool RawNumber(const Ch *str, SizeType len, bool)
bool EndObject(SizeType memberCount)
Hasher(Allocator *allocator=0, size_t stackCapacity=kDefaultSize)
Stack< Allocator > stack_
uint64_t GetHashCode() const
bool String(const Ch *str, SizeType len, bool)
bool EndArray(SizeType elementCount)
virtual ~ISchemaStateFactory()
virtual void * CreateHasher()=0
virtual void * MallocState(size_t size)=0
virtual void DestroryHasher(void *hasher)=0
virtual void DestroySchemaValidator(ISchemaValidator *validator)=0
virtual ISchemaValidator * CreateSchemaValidator(const SchemaType &)=0
virtual void FreeState(void *p)=0
virtual uint64_t GetHashCode(void *hasher)=0
virtual ~ISchemaValidator()
virtual bool IsValid() const =0
AllocatorType * allocator_
bool CheckInt(Context &context, int64_t i) const
bool Uint64(Context &context, uint64_t u) const
const SchemaType ** itemsTuple_
bool String(Context &context, const Ch *str, SizeType length, bool) const
bool StartArray(Context &context) const
bool Null(Context &context) const
SchemaDocumentType::ValueType ValueType
ValueType::EncodingType EncodingType
static bool IsPatternMatch(const RegexType *pattern, const Ch *str, SizeType)
static void AssignIfExist(SizeType &out, const ValueType &value, const ValueType &name)
static void AssignIfExist(bool &out, const ValueType &value, const ValueType &name)
const SchemaType * itemsList_
Schema< SchemaDocumentType > SchemaType
bool Int64(Context &context, int64_t i) const
bool StartObject(Context &context) const
RAPIDJSON_FORCEINLINE bool EndValue(Context &context) const
bool Bool(Context &context, bool) const
bool FindPropertyIndex(const ValueType &name, SizeType *outIndex) const
bool Uint(Context &context, unsigned u) const
bool CheckDoubleMaximum(Context &context, double d) const
bool Key(Context &context, const Ch *str, SizeType len, bool) const
void AddType(const ValueType &type)
SizeType notValidatorIndex_
void AssignIfExist(SchemaArray &out, SchemaDocumentType &schemaDocument, const PointerType &p, const ValueType &value, const ValueType &name, const ValueType &document)
bool additionalProperties_
const SchemaType * typeless_
GenericValue< EncodingType, AllocatorType > SValue
bool EndObject(Context &context, SizeType memberCount) const
SchemaDocumentType::PointerType PointerType
bool CreateParallelValidator(Context &context) const
RegexType * CreatePattern(const ValueType &value)
SchemaDocumentType::AllocatorType AllocatorType
bool hasSchemaDependencies_
bool Double(Context &context, double d) const
bool BeginValue(Context &context) const
void AddUniqueElement(V1 &a, const V2 &v)
const SchemaType * additionalItemsSchema_
static const ValueType * GetMember(const ValueType &value, const ValueType &name)
bool CheckDoubleMinimum(Context &context, double d) const
const SchemaType * additionalPropertiesSchema_
SizeType itemsTupleCount_
bool CheckUint(Context &context, uint64_t i) const
bool EndArray(Context &context, SizeType elementCount) const
Schema(SchemaDocumentType *schemaDocument, const PointerType &p, const ValueType &value, const ValueType &document, AllocatorType *allocator)
internal::GenericRegex< EncodingType > RegexType
void CreateSchemaValidators(Context &context, const SchemaArray &schemas) const
bool Int(Context &context, int i) const
SizeType patternPropertyCount_
bool CheckDoubleMultipleOf(Context &context, double d) const
PatternProperty * patternProperties_
SchemaValidationContext< SchemaDocumentType > Context
A type-unsafe stack for storing different types of data.
void(*)(CSeq_entry_Handle seh, IWorkbench *wb, const CSerialObject &obj) handler
static unsigned char depth[2 *(256+1+29)+1]
std::ofstream out("events_result.xml")
main entry point for tests
static const char * schema
static const char * str(char *buf, int n)
bool IsValid(const CSeq_point &pt, CScope *scope)
Checks that point >= 0 and point < length of Bioseq.
#define RAPIDJSON_ASSERT(x)
Assertion.
#define RAPIDJSON_NAMESPACE_BEGIN
provide custom rapidjson namespace (opening expression)
#define RAPIDJSON_NAMESPACE_END
provide custom rapidjson namespace (closing expression)
if(yy_accept[yy_current_state])
const struct ncbi::grid::netcache::search::fields::SIZE size
char * u32toa(uint32_t value, char *buffer)
char * u64toa(uint64_t value, char *buffer)
const GenericPointer< typename T::ValueType > T2 value
const CharType(& source)[N]
GenericSchemaValidator< SchemaDocument, BaseReaderHandler< UTF8< char >, void >, CrtAllocator > SchemaValidator
unsigned SizeType
Size type (for string lengths, array sizes, etc.)
GenericSchemaDocument< Value, CrtAllocator > SchemaDocument
GenericSchemaDocument using Value type.
const GenericPointer< typename T::ValueType > & pointer
IGenericRemoteSchemaDocumentProvider< SchemaDocument > IRemoteSchemaDocumentProvider
IGenericRemoteSchemaDocumentProvider using SchemaDocument.
size_t Hash(const char *s, size_t len)
Uint1 Boolean
bool replacment for C
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
void copy(Njn::Matrix< S > *matrix_, const Njn::Matrix< T > &matrix0_)
#define RAPIDJSON_DELETE(x)
! customization point for global delete
#define RAPIDJSON_UINT64_C2(high32, low32)
Construct a 64-bit literal by a pair of 32-bit integer.
#define RAPIDJSON_NEW(TypeName)
! customization point for global new
#define RAPIDJSON_SCHEMA_HANDLE_BEGIN_(method, arg1)
#define RAPIDJSON_SCHEMA_VERBOSE
#define RAPIDJSON_SCHEMA_HANDLE_VALUE_(method, arg1, arg2)
#define RAPIDJSON_SCHEMA_HANDLE_END_(method, arg2)
#define RAPIDJSON_STRING_(name,...)
#define RAPIDJSON_INVALID_KEYWORD_RETURN(keyword)
#define RAPIDJSON_SCHEMA_HANDLE_PARALLEL_(method, arg2)
static SLJIT_INLINE sljit_ins l(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
SchemaEntry(const PointerType &p, SchemaType *s, bool o, Allocator *allocator)
SchemaRefEntry(const PointerType &s, const PointerType &t, const SchemaType **outSchema, Allocator *allocator)
const SchemaType ** schema
Result of parsing (wraps ParseErrorCode)
PatternValidatorType valuePatternValidatorType
ISchemaStateFactory< SchemaType > SchemaValidatorFactoryType
SchemaValidationContext(SchemaValidatorFactoryType &f, const SchemaType *s)
const SchemaType * schema
PatternValidatorType objectPatternValidatorType
const Ch * invalidKeyword
SizeType arrayElementIndex
SchemaType::ValueType ValueType
void * arrayElementHashCodes
const SchemaType ** patternPropertiesSchemas
SizeType patternPropertiesValidatorCount
ISchemaValidator ** patternPropertiesValidators
@ kPatternValidatorWithProperty
SchemaValidatorFactoryType & factory
SizeType patternPropertiesSchemaCount
~SchemaValidationContext()
Schema< SchemaDocumentType > SchemaType
const SchemaType * valueSchema
ISchemaValidator ** validators
const SchemaType * schema
const SchemaType * schema
const SchemaType * dependenciesSchema
SizeType dependenciesValidatorIndex
const SchemaType ** schemas
static RAPIDJSON_FORCEINLINE void AppendIndexToken(Stack &documentStack, SizeType index)
static RAPIDJSON_FORCEINLINE void AppendIndexToken(Stack &documentStack, SizeType index)
int g(Seg_Gsm *spe, Seq_Mtf *psm, Thd_Gsm *tdg)
static CS_CONTEXT * context