/home/docs/checkouts/readthedocs.org/user_builds/advanced-micro-devices-composable-kernel/checkouts/develop/include/rapidjson/schema.h Source File#
schema.h
Go to the documentation of this file.
29 #if !defined(RAPIDJSON_SCHEMA_USE_STDREGEX) || !(__cplusplus >=201103L || (defined(_MSC_VER) && _MSC_VER >= 1800))
101 inline void PrintSchemaIdsData(const wchar_t* base, const wchar_t* local, const wchar_t* resolved) {
184 };
200 };
222 return ((draft >= kDraftMin && draft <= kDraftMax) && ((oapi == kVersionNone) || (oapi >= kVersionMin && oapi <= kVersionMax)));
257 virtual ISchemaValidator* CreateSchemaValidator(const SchemaType&, const bool inheritContinueOnErrors) = 0;
308 virtual void AddDependencySchemaError(const SValue& souceName, ISchemaValidator* subvalidator) = 0;
334 Hasher(Allocator* allocator = 0, size_t stackCapacity = kDefaultSize) : stack_(allocator, stackCapacity) {}
339 bool Uint(unsigned u) { Number n; n.u.u = u; n.d = static_cast<double>(u); return WriteNumber(n); }
340 bool Int64(int64_t i) { Number n; n.u.i = i; n.d = static_cast<double>(i); return WriteNumber(n); }
341 bool Uint64(uint64_t u) { Number n; n.u.u = u; n.d = static_cast<double>(u); return WriteNumber(n); }
439 };
441 SchemaValidationContext(SchemaValidatorFactoryType& f, ErrorHandlerType& eh, const SchemaType* s, unsigned fl = 0) :
532 Schema(SchemaDocumentType* schemaDocument, const PointerType& p, const ValueType& value, const ValueType& document, AllocatorType* allocator, const UriType& id = UriType()) :
654 for (ConstMemberIterator itr = properties->MemberBegin(); itr != properties->MemberEnd(); ++itr)
665 for (ConstMemberIterator itr = dependencies->MemberBegin(); itr != dependencies->MemberEnd(); ++itr) {
686 for (ConstMemberIterator itr = properties->MemberBegin(); itr != properties->MemberEnd(); ++itr) {
689 schemaDocument->CreateSchema(&properties_[index].schema, q.Append(itr->name, allocator_), itr->value, document, id_);
697 patternProperties_ = static_cast<PatternProperty*>(allocator_->Malloc(sizeof(PatternProperty) * v->MemberCount()));
703 patternProperties_[patternPropertyCount_].pattern = CreatePattern(itr->name, schemaDocument, r);
704 schemaDocument->CreateSchema(&patternProperties_[patternPropertyCount_].schema, r, itr->value, document, id_);
724 for (ConstMemberIterator itr = dependencies->MemberBegin(); itr != dependencies->MemberEnd(); ++itr) {
728 properties_[sourceIndex].dependencies = static_cast<bool*>(allocator_->Malloc(sizeof(bool) * propertyCount_));
730 for (ConstValueIterator targetItr = itr->value.Begin(); targetItr != itr->value.End(); ++targetItr) {
738 schemaDocument->CreateSchema(&properties_[sourceIndex].dependenciesSchema, q.Append(itr->name, allocator_), itr->value, document, id_);
750 schemaDocument->CreateSchema(&additionalPropertiesSchema_, p.Append(GetAdditionalPropertiesString(), allocator_), *v, document, id_);
762 itemsTuple_ = static_cast<const Schema**>(allocator_->Malloc(sizeof(const Schema*) * v->Size()));
765 schemaDocument->CreateSchema(&itemsTuple_[itemsTupleCount_++], q.Append(index, allocator_), *itr, document, id_);
778 schemaDocument->CreateSchema(&additionalItemsSchema_, p.Append(GetAdditionalItemsString(), allocator_), *v, document, id_);
884 // Must set valueSchema for when kValidateContinueOnErrorFlag is set, else reports spurious type error
1090 context.propertyExist = static_cast<bool*>(context.factory.MallocState(sizeof(bool) * propertyCount_));
1096 context.patternPropertiesSchemas = static_cast<const SchemaType**>(context.factory.MallocState(sizeof(const SchemaType*) * count));
1110 if (patternProperties_[i].pattern && IsPatternMatch(patternProperties_[i].pattern, str, len)) {
1111 context.patternPropertiesSchemas[context.patternPropertiesSchemaCount++] = patternProperties_[i].schema;
1119 context.patternPropertiesSchemas[context.patternPropertiesSchemaCount++] = properties_[index].schema;
1134 context.patternPropertiesSchemas[context.patternPropertiesSchemaCount++] = additionalPropertiesSchema_;
1147 if (context.patternPropertiesSchemaCount == 0) { // patternProperties are not additional properties
1148 // Must set valueSchema for when kValidateContinueOnErrorFlag is set, else reports spurious type error
1192 ISchemaValidator* dependenciesValidator = context.validators[source.dependenciesValidatorIndex];
1300 RAPIDJSON_STRING_(PatternProperties, 'p', 'a', 't', 't', 'e', 'r', 'n', 'P', 'r', 'o', 'p', 'e', 'r', 't', 'i', 'e', 's')
1301 RAPIDJSON_STRING_(AdditionalProperties, 'a', 'd', 'd', 'i', 't', 'i', 'o', 'n', 'a', 'l', 'P', 'r', 'o', 'p', 'e', 'r', 't', 'i', 'e', 's')
1302 RAPIDJSON_STRING_(MinProperties, 'm', 'i', 'n', 'P', 'r', 'o', 'p', 'e', 'r', 't', 'i', 'e', 's')
1303 RAPIDJSON_STRING_(MaxProperties, 'm', 'a', 'x', 'P', 'r', 'o', 'p', 'e', 'r', 't', 'i', 'e', 's')
1307 RAPIDJSON_STRING_(AdditionalItems, 'a', 'd', 'd', 'i', 't', 'i', 'o', 'n', 'a', 'l', 'I', 't', 'e', 'm', 's')
1314 RAPIDJSON_STRING_(ExclusiveMinimum, 'e', 'x', 'c', 'l', 'u', 's', 'i', 'v', 'e', 'M', 'i', 'n', 'i', 'm', 'u', 'm')
1315 RAPIDJSON_STRING_(ExclusiveMaximum, 'e', 'x', 'c', 'l', 'u', 's', 'i', 'v', 'e', 'M', 'a', 'x', 'i', 'm', 'u', 'm')
1383 void AssignIfExist(SchemaArray& out, SchemaDocumentType& schemaDocument, const PointerType& p, const ValueType& value, const ValueType& name, const ValueType& document) {
1388 out.schemas = static_cast<const Schema**>(allocator_->Malloc(out.count * sizeof(const Schema*)));
1400 RegexType* CreatePattern(const ValueType& value, SchemaDocumentType* sd, const PointerType& p) {
1402 RegexType* r = new (allocator_->Malloc(sizeof(RegexType))) RegexType(value.GetString(), allocator_);
1420 RegexType* CreatePattern(const ValueType& value, SchemaDocumentType* sd, const PointerType& p) {
1424 return new (r) RegexType(value.GetString(), std::size_t(value.GetStringLength()), std::regex_constants::ECMAScript);
1454 else if (type == GetNumberString() ) type_ |= (1 << kNumberSchemaType) | (1 << kIntegerSchemaType);
1457 // Creates parallel validators for allOf, anyOf, oneOf, not and schema dependencies, if required.
1466 context.validators = static_cast<ISchemaValidator**>(context.factory.MallocState(sizeof(ISchemaValidator*) * validatorCount_));
1486 context.validators[properties_[i].dependenciesValidatorIndex] = context.factory.CreateSchemaValidator(*properties_[i].dependenciesSchema, false);
1503 void CreateSchemaValidators(Context& context, const SchemaArray& schemas, const bool inheritContinueOnErrors) const {
1505 context.validators[schemas.begin + i] = context.factory.CreateSchemaValidator(*schemas.schemas[i], inheritContinueOnErrors);
1540 RAPIDJSON_INVALID_KEYWORD_RETURN(exclusiveMinimum_ ? kValidateErrorExclusiveMinimum : kValidateErrorMinimum);
1545 RAPIDJSON_INVALID_KEYWORD_RETURN(exclusiveMinimum_ ? kValidateErrorExclusiveMinimum : kValidateErrorMinimum); // i <= max(int64_t) < minimum.GetUint64()
1555 RAPIDJSON_INVALID_KEYWORD_RETURN(exclusiveMaximum_ ? kValidateErrorExclusiveMaximum : kValidateErrorMaximum);
1588 RAPIDJSON_INVALID_KEYWORD_RETURN(exclusiveMinimum_ ? kValidateErrorExclusiveMinimum : kValidateErrorMinimum);
1601 RAPIDJSON_INVALID_KEYWORD_RETURN(exclusiveMaximum_ ? kValidateErrorExclusiveMaximum : kValidateErrorMaximum);
1606 RAPIDJSON_INVALID_KEYWORD_RETURN(exclusiveMaximum_ ? kValidateErrorExclusiveMaximum : kValidateErrorMaximum); // i >= 0 > maximum_
1629 RAPIDJSON_INVALID_KEYWORD_RETURN(exclusiveMinimum_ ? kValidateErrorExclusiveMinimum : kValidateErrorMinimum);
1637 RAPIDJSON_INVALID_KEYWORD_RETURN(exclusiveMaximum_ ? kValidateErrorExclusiveMaximum : kValidateErrorMaximum);
1648 bool isMultiple = difference <= scaledEpsilon || difference < (std::numeric_limits<double>::min)();
1673 Property() : schema(), dependenciesSchema(), dependenciesValidatorIndex(), dependencies(), required(false) {}
1754 size_t length = static_cast<size_t>((sizeof(SizeType) == 4 ? u32toa(index, buffer) : u64toa(index, buffer)) - buffer);
1793 virtual const SchemaDocumentType* GetRemoteDocument(const GenericUri<ValueType, AllocatorType> uri, Specification& spec) {
1818 typedef IGenericRemoteSchemaDocumentProvider<GenericSchemaDocument> IRemoteSchemaDocumentProviderType;
1843 explicit GenericSchemaDocument(const ValueType& document, const Ch* uri = 0, SizeType uriLength = 0,
1867 new (typeless_) SchemaType(this, PointerType(), ValueType(kObjectType).Move(), ValueType(kObjectType).Move(), allocator_, docId_);
1886 SchemaErrorValue(kSchemaErrorStartUnknown, PointerType(), sb.GetString(), static_cast<SizeType>(sb.GetSize() / sizeof(Ch)));
1987 void SchemaErrorValue(const SchemaErrorCode code, const PointerType& location, const Ch* value, SizeType length) {
1989 currentError_.AddMember(GetValueString(), GValue(value, length, *allocator_).Move(), *allocator_);
1994 void SchemaErrorPointer(const SchemaErrorCode code, const PointerType& location, const Ch* value, SizeType length, const PointerType& pointer) {
1996 currentError_.AddMember(GetValueString(), GValue(value, length, *allocator_).Move(), *allocator_);
1997 currentError_.AddMember(GetOffsetString(), static_cast<SizeType>(pointer.GetParseErrorOffset() / sizeof(Ch)), *allocator_);
2010 SchemaEntry(const PointerType& p, SchemaType* s, bool o, Allocator* allocator) : pointer(p, allocator), schema(s), owned(o) {}
2025 GValue instanceRef(sb.GetString(), static_cast<SizeType>(sb.GetSize() / sizeof(Ch)), *allocator_);
2064 RAPIDJSON_STRING_(SpecUnsupported, 'S', 'p', 'e', 'c', 'U', 'n', 's', 'u', 'p', 'p', 'o', 'r', 't', 'e', 'd')
2069 RAPIDJSON_STRING_(RefPointerInvalid, 'R', 'e', 'f', 'P', 'o', 'i', 'n', 't', 'e', 'r', 'I', 'n', 'v', 'a', 'l', 'i', 'd')
2072 RAPIDJSON_STRING_(RefNoRemoteProvider, 'R', 'e', 'f', 'N', 'o', 'R', 'e', 'm', 'o', 't', 'e', 'P', 'r', 'o', 'v', 'i', 'd', 'e', 'r')
2073 RAPIDJSON_STRING_(RefNoRemoteSchema, 'R', 'e', 'f', 'N', 'o', 'R', 'e', 'm', 'o', 't', 'e', 'S', 'c', 'h', 'e', 'm', 'a')
2074 RAPIDJSON_STRING_(ReadOnlyAndWriteOnly, 'R', 'e', 'a', 'd', 'O', 'n', 'l', 'y', 'A', 'n', 'd', 'W', 'r', 'i', 't', 'e', 'O', 'n', 'l', 'y')
2081 static const Ch kDraft03String[] = { 'h', 't', 't', 'p', ':', '/', '/', 'j', 's', 'o', 'n', '-', 's', 'c', 'h', 'e', 'm', 'a', '.', 'o', 'r', 'g', '/', 'd', 'r', 'a', 'f', 't', '-', '0', '3', '/', 's', 'c', 'h', 'e', 'm', 'a', '#', '\0' };
2082 static const Ch kDraft04String[] = { 'h', 't', 't', 'p', ':', '/', '/', 'j', 's', 'o', 'n', '-', 's', 'c', 'h', 'e', 'm', 'a', '.', 'o', 'r', 'g', '/', 'd', 'r', 'a', 'f', 't', '-', '0', '4', '/', 's', 'c', 'h', 'e', 'm', 'a', '#', '\0' };
2083 static const Ch kDraft05String[] = { 'h', 't', 't', 'p', ':', '/', '/', 'j', 's', 'o', 'n', '-', 's', 'c', 'h', 'e', 'm', 'a', '.', 'o', 'r', 'g', '/', 'd', 'r', 'a', 'f', 't', '-', '0', '5', '/', 's', 'c', 'h', 'e', 'm', 'a', '#', '\0' };
2084 static const Ch kDraft06String[] = { 'h', 't', 't', 'p', ':', '/', '/', 'j', 's', 'o', 'n', '-', 's', 'c', 'h', 'e', 'm', 'a', '.', 'o', 'r', 'g', '/', 'd', 'r', 'a', 'f', 't', '-', '0', '6', '/', 's', 'c', 'h', 'e', 'm', 'a', '#', '\0' };
2085 static const Ch kDraft07String[] = { 'h', 't', 't', 'p', ':', '/', '/', 'j', 's', 'o', 'n', '-', 's', 'c', 'h', 'e', 'm', 'a', '.', 'o', 'r', 'g', '/', 'd', 'r', 'a', 'f', 't', '-', '0', '7', '/', 's', 'c', 'h', 'e', 'm', 'a', '#', '\0' };
2086 static const Ch kDraft2019_09String[] = { 'h', 't', 't', 'p', 's', ':', '/', '/', 'j', 's', 'o', 'n', '-', 's', 'c', 'h', 'e', 'm', 'a', '.', 'o', 'r', 'g', '/', 'd', 'r', 'a', 'f', 't', '/', '2', '0', '1', '9', '-', '0', '9', '/', 's', 'c', 'h', 'e', 'm', 'a', '\0' };
2087 static const Ch kDraft2020_12String[] = { 'h', 't', 't', 'p', 's', ':', '/', '/', 'j', 's', 'o', 'n', '-', 's', 'c', 'h', 'e', 'm', 'a', '.', 'o', 'r', 'g', '/', 'd', 'r', 'a', 'f', 't', '/', '2', '0', '2', '0', '-', '1', '2', '/', 's', 'c', 'h', 'e', 'm', 'a', '\0' };
2094 typename ValueType::ConstMemberIterator itr = document.FindMember(SchemaType::GetSchemaString());
2125 typename ValueType::ConstMemberIterator itr = document.FindMember(SchemaType::GetSwaggerString());
2132 if (itr->value.GetStringLength() > len && kVersion30Value == ValueType(itr->value.GetString(), len)) return kVersion30; // must match 3.0.x
2134 if (itr->value.GetStringLength() > len && kVersion31Value == ValueType(itr->value.GetString(), len)) return kVersion31; // must match 3.1.x
2142 // Report an error if schema draft or open api version not supported or not recognized, or both in document, and carry on.
2163 void CreateSchemaRecursive(const SchemaType** schema, const PointerType& pointer, const ValueType& v, const ValueType& document, const UriType& id) {
2167 for (typename ValueType::ConstMemberIterator itr = v.MemberBegin(); itr != v.MemberEnd(); ++itr)
2176 const UriType& CreateSchema(const SchemaType** schema, const PointerType& pointer, const ValueType& v, const ValueType& document, const UriType& id) {
2180 RAPIDJSON_SCHEMA_PRINT(Method, "GenericSchemaDocument::CreateSchema", sb.GetString(), id.GetString());
2189 SchemaType* s = new (allocator_->Malloc(sizeof(SchemaType))) SchemaType(this, pointer, v, document, allocator_, id);
2205 bool HandleRefSchema(const PointerType& source, const SchemaType** schema, const ValueType& v, const ValueType& document, const UriType& id) {
2212 RAPIDJSON_SCHEMA_PRINT(Method, "GenericSchemaDocument::HandleRefSchema", sb.GetString(), id.GetString());
2234 if (const GenericSchemaDocument* remoteDocument = remoteProvider_->GetRemoteDocument(ref, spec_)) {
2256 SchemaErrorValue(kSchemaErrorRefNoRemoteSchema, source, ref.GetString(), ref.GetStringLength());
2277 // Call CreateSchema recursively, but first compute the in-scope id for the $ref target as we have jumped there
2294 // Search from the base we just established. Returns the subschema in the document and its absolute JSON pointer.
2295 else if (const ValueType *pv = FindId(*base, ref, pointer, UriType(ref.GetBaseString(), ref.GetBaseStringLength(), allocator_), true, basePointer)) {
2299 // Call CreateSchema recursively, but first compute the in-scope id for the $ref target as we have jumped there
2324 ValueType* FindId(const ValueType& doc, const UriType& finduri, PointerType& resptr, const UriType& baseuri, bool full, const PointerType& here = PointerType()) const {
2337 RAPIDJSON_SCHEMA_PRINT(Method, "GenericSchemaDocument::FindId (match)", full ? localuri.GetString() : localuri.GetBaseString());
2345 resval = FindId(m->value, finduri, resptr, localuri, full, here.Append(m->name.GetString(), m->name.GetStringLength(), allocator_));
2374 for (const SchemaRefPtr* ref = schemaRef_.template Bottom<SchemaRefPtr>(); ref != schemaRef_.template End<SchemaRefPtr>(); ++ref)
2381 for (const SchemaEntry* target = schemaMap_.template Bottom<SchemaEntry>(); target != schemaMap_.template End<SchemaEntry>(); ++target)
2388 for (const SchemaEntry* target = schemaMap_.template Bottom<SchemaEntry>(); target != schemaMap_.template End<SchemaEntry>(); ++target)
2435 typename OutputHandler = BaseReaderHandler<typename SchemaDocumentType::SchemaType::EncodingType>,
2508 RAPIDJSON_SCHEMA_PRINT(Method, "GenericSchemaValidator::GenericSchemaValidator (output handler)");
2562 if (GetContinueOnErrors() && !error_.ObjectEmpty()) return static_cast<const Ch*>(GetErrorsString());
2581 return PointerType(documentStack_.template Bottom<Ch>(), documentStack_.GetSize() / sizeof(Ch));
2595 AddNumberError(exclusive ? kValidateErrorExclusiveMaximum : kValidateErrorMaximum, ValueType(actual).Move(), expected,
2599 AddNumberError(exclusive ? kValidateErrorExclusiveMaximum : kValidateErrorMaximum, ValueType(actual).Move(), expected,
2603 AddNumberError(exclusive ? kValidateErrorExclusiveMaximum : kValidateErrorMaximum, ValueType(actual).Move(), expected,
2607 AddNumberError(exclusive ? kValidateErrorExclusiveMinimum : kValidateErrorMinimum, ValueType(actual).Move(), expected,
2611 AddNumberError(exclusive ? kValidateErrorExclusiveMinimum : kValidateErrorMinimum, ValueType(actual).Move(), expected,
2615 AddNumberError(exclusive ? kValidateErrorExclusiveMinimum : kValidateErrorMinimum, ValueType(actual).Move(), expected,
2629 currentError_.AddMember(GetActualString(), ValueType(str, length, GetStateAllocator()).Move(), GetStateAllocator());
2684 currentError_.AddMember(GetDisallowedString(), ValueType(name, length, GetStateAllocator()).Move(), GetStateAllocator());
2695 missingDependents_.PushBack(ValueType(targetName, GetStateAllocator()).Move(), GetStateAllocator());
2706 PointerType schemaRef = GetInvalidSchemaPointer().Append(SchemaType::GetValidateErrorKeyword(kValidateErrorDependencies), &GetInvalidSchemaPointer().GetAllocator());
2707 AddErrorSchemaLocation(error, schemaRef.Append(sourceName.GetString(), sourceName.GetStringLength(), &GetInvalidSchemaPointer().GetAllocator()));
2709 wrapper.AddMember(ValueType(SchemaType::GetValidateErrorKeyword(code), GetStateAllocator()).Move(), error, GetStateAllocator());
2710 currentError_.AddMember(ValueType(sourceName, GetStateAllocator()).Move(), wrapper, GetStateAllocator());
2735 currentError_.PushBack(ValueType(expectedType, GetStateAllocator()).Move(), GetStateAllocator());
2740 error.AddMember(GetActualString(), ValueType(actualType, GetStateAllocator()).Move(), GetStateAllocator());
2745 // Treat allOf like oneOf and anyOf to match https://rapidjson.org/md_doc_schema.html#allOf-anyOf-oneOf
2801 if ((!BeginValue() && !GetContinueOnErrors()) || (!CurrentSchema().method arg1 && !GetContinueOnErrors())) {\
2810 for (Context* context = schemaStack_.template Bottom<Context>(); context != schemaStack_.template End<Context>(); context++) {\
2822 valid_ = (EndValue() || GetContinueOnErrors()) && (!outputHandler_ || outputHandler_->method arg2);\
2835 bool Uint64(uint64_t u) { RAPIDJSON_SCHEMA_HANDLE_VALUE_(Uint64, (CurrentContext(), u), (u)); }
2838 { RAPIDJSON_SCHEMA_HANDLE_VALUE_(String, (CurrentContext(), str, length, copy), (str, length, copy)); }
2840 { RAPIDJSON_SCHEMA_HANDLE_VALUE_(String, (CurrentContext(), str, length, copy), (str, length, copy)); }
2898 virtual ISchemaValidator* CreateSchemaValidator(const SchemaType& root, const bool inheritContinueOnErrors) {
2901 ISchemaValidator* sv = new (GetStateAllocator().Malloc(sizeof(GenericSchemaValidator))) GenericSchemaValidator(*schemaDocument_, root, documentStack_.template Bottom<char>(), documentStack_.GetSize(),
2904 sv->SetValidateFlags(inheritContinueOnErrors ? GetValidateFlags() : GetValidateFlags() & ~static_cast<unsigned>(kValidateContinueOnErrorFlag));
2965 RAPIDJSON_SCHEMA_PRINT(Method, "GenericSchemaValidator::GenericSchemaValidator (internal)", basePath && basePathSize ? basePath : "");
2986 internal::TokenHelper<internal::Stack<StateAllocator>, Ch>::AppendIndexToken(documentStack_, CurrentContext().arrayElementIndex);
2993 typename Context::PatternValidatorType patternValidatorType = CurrentContext().valuePatternValidatorType;
3022 RAPIDJSON_SCHEMA_PRINT(ValidatorPointers, sb.GetString(), documentStack_.template Bottom<Ch>(), depth_);
3024 uint64_t h = hasher && CurrentContext().arrayUniqueness ? static_cast<HasherType*>(hasher)->GetHashCode() : 0;
3034 CurrentContext().arrayElementHashCodes = a = new (GetStateAllocator().Malloc(sizeof(HashCodeArray))) HashCodeArray(kArrayType);
3057 documentStack_.template Reserve<Ch>(1 + len * 2); // worst case all characters are escaped as two characters
3073 RAPIDJSON_FORCEINLINE void PushSchema(const SchemaType& schema) { new (schemaStack_.template Push<Context>()) Context(*this, *this, &schema, flags_); }
3128 AddError(ValueType(SchemaType::GetValidateErrorKeyword(code), GetStateAllocator(), false).Move(), currentError_);
3132 for (typename ValueType::MemberIterator it = other.MemberBegin(), end = other.MemberEnd(); it != end; ++it) {
3141 currentError_.AddMember(GetExpectedString(), ValueType(expected, GetStateAllocator()).Move(), GetStateAllocator());
3143 currentError_.AddMember(ValueType(exclusive(), GetStateAllocator()).Move(), true, GetStateAllocator());
3151 errors.PushBack(static_cast<GenericSchemaValidator*>(subvalidators[i])->GetError(), GetStateAllocator());
3157 const SchemaType& CurrentSchema() const { return *schemaStack_.template Top<Context>()->schema; }
3210 SchemaValidatingReader(InputStream& is, const SchemaDocumentType& sd) : is_(is), sd_(sd), invalidSchemaKeyword_(), invalidSchemaCode_(kValidateErrorNone), error_(kObjectType), isValid_(true) {}
3214 GenericReader<SourceEncoding, typename SchemaDocumentType::EncodingType, StackAllocator> reader;
SAX-style JSON parser. Use Reader for UTF8 encoding and default allocator.
Definition: reader.h:539
GenericSchemaDocument(const ValueType &document, const Ch *uri=0, SizeType uriLength=0, IRemoteSchemaDocumentProviderType *remoteProvider=0, Allocator *allocator=0, const PointerType &pointer=PointerType(), const Specification &spec=Specification(kDraft04))
Constructor.
Definition: schema.h:1843
const SchemaType & GetRoot() const
Get the root schema.
Definition: schema.h:1955
~GenericSchemaDocument()
Destructor.
Definition: schema.h:1918
GenericValue< EncodingType, AllocatorType > GValue
Definition: schema.h:1824
void SchemaError(const SchemaErrorCode code, const PointerType &location)
Default error method.
Definition: schema.h:1981
const Specification & GetSpecification() const
Definition: schema.h:1937
void SchemaErrorValue(const SchemaErrorCode code, const PointerType &location, const Ch *value, SizeType length)
Method for error with single string value insert.
Definition: schema.h:1987
static const Specification GetSpecification(const ValueType &document)
Static method to get the specification of any schema document.
Definition: schema.h:1942
IGenericRemoteSchemaDocumentProvider< GenericSchemaDocument > IRemoteSchemaDocumentProviderType
Definition: schema.h:1818
static const StringRefType & GetSchemaErrorKeyword(SchemaErrorCode schemaErrorCode)
Definition: schema.h:1961
internal::Schema< GenericSchemaDocument > SchemaType
Definition: schema.h:1822
bool IsSupportedSpecification() const
Definition: schema.h:1938
GenericPointer< ValueType, Allocator > PointerType
Definition: schema.h:1823
void SchemaErrorPointer(const SchemaErrorCode code, const PointerType &location, const Ch *value, SizeType length, const PointerType &pointer)
Method for error with invalid pointer.
Definition: schema.h:1994
virtual void DestroryHasher(void *hasher)
Definition: schema.h:2922
void BelowMinimum(int64_t actual, const SValue &expected, bool exclusive)
Definition: schema.h:2606
GenericSchemaValidator(const SchemaDocumentType &schemaDocument, StateAllocator *allocator=0, size_t schemaStackCapacity=kDefaultSchemaStackCapacity, size_t documentStackCapacity=kDefaultDocumentStackCapacity)
Constructor without output handler.
Definition: schema.h:2457
void TooLong(const Ch *str, SizeType length, SizeType expected)
Definition: schema.h:2619
void AddDependencySchemaError(const SValue &sourceName, ISchemaValidator *subvalidator)
Definition: schema.h:2713
void PropertyViolations(ISchemaValidator **subvalidators, SizeType count)
Definition: schema.h:2678
virtual unsigned GetValidateFlags() const
Definition: schema.h:2537
bool String(const Ch *str, SizeType length, bool copy)
Definition: schema.h:2839
~GenericSchemaValidator()
Destructor.
Definition: schema.h:2512
void StartMissingProperties()
Definition: schema.h:2663
void NotAllOf(ISchemaValidator **subvalidators, SizeType count)
Definition: schema.h:2744
GenericValue< EncodingType, StateAllocator > ValueType
Definition: schema.h:2448
void DisallowedProperty(const Ch *name, SizeType length)
Definition: schema.h:2682
virtual ISchemaValidator * CreateSchemaValidator(const SchemaType &root, const bool inheritContinueOnErrors)
Definition: schema.h:2898
void AboveMaximum(int64_t actual, const SValue &expected, bool exclusive)
Definition: schema.h:2594
void MultipleOneOf(SizeType index1, SizeType index2)
Definition: schema.h:2757
PointerType GetInvalidSchemaPointer() const
Gets the JSON pointer pointed to the invalid schema.
Definition: schema.h:2554
void NotMultipleOf(uint64_t actual, const SValue &expected)
Definition: schema.h:2588
void AddExpectedType(const typename SchemaType::ValueType &expectedType)
Definition: schema.h:2734
bool Key(const Ch *str, SizeType len, bool copy)
Definition: schema.h:2850
void TooShort(const Ch *str, SizeType length, SizeType expected)
Definition: schema.h:2623
void TooManyItems(SizeType actualCount, SizeType expectedCount)
Definition: schema.h:2642
ValueType & GetError()
End of Implementation of ISchemaValidator.
Definition: schema.h:2549
void DuplicateItems(SizeType index1, SizeType index2)
Definition: schema.h:2646
void AddMissingDependentProperty(const SValue &targetName)
Definition: schema.h:2694
void AddMissingProperty(const SValue &name)
Definition: schema.h:2666
void AboveMaximum(uint64_t actual, const SValue &expected, bool exclusive)
Definition: schema.h:2598
void NoneOf(ISchemaValidator **subvalidators, SizeType count)
Definition: schema.h:2751
void TooFewProperties(SizeType actualCount, SizeType expectedCount)
Definition: schema.h:2659
void NotMultipleOf(int64_t actual, const SValue &expected)
Definition: schema.h:2585
const Ch * GetInvalidSchemaKeyword() const
Gets the keyword of invalid schema.
Definition: schema.h:2560
void AboveMaximum(double actual, const SValue &expected, bool exclusive)
Definition: schema.h:2602
virtual uint64_t GetHashCode(void *hasher)
Definition: schema.h:2918
PointerType GetInvalidDocumentPointer() const
Gets the JSON pointer pointed to the invalid value.
Definition: schema.h:2576
GenericSchemaValidator(const SchemaDocumentType &schemaDocument, OutputHandler &outputHandler, StateAllocator *allocator=0, size_t schemaStackCapacity=kDefaultSchemaStackCapacity, size_t documentStackCapacity=kDefaultDocumentStackCapacity)
Constructor with output handler.
Definition: schema.h:2487
void StartMissingDependentProperties()
Definition: schema.h:2691
SchemaDocumentType::SchemaType SchemaType
Definition: schema.h:2442
void BelowMinimum(uint64_t actual, const SValue &expected, bool exclusive)
Definition: schema.h:2610
void NotOneOf(ISchemaValidator **subvalidators, SizeType count)
Definition: schema.h:2754
void TooManyProperties(SizeType actualCount, SizeType expectedCount)
Definition: schema.h:2655
SchemaDocumentType::PointerType PointerType
Definition: schema.h:2443
void EndDisallowedType(const typename SchemaType::ValueType &actualType)
Definition: schema.h:2737
virtual void DestroySchemaValidator(ISchemaValidator *validator)
Definition: schema.h:2908
bool RawNumber(const Ch *str, SizeType length, bool copy)
Definition: schema.h:2837
void NotMultipleOf(double actual, const SValue &expected)
Definition: schema.h:2591
ValidateErrorCode GetInvalidSchemaCode() const
Gets the error code of invalid schema.
Definition: schema.h:2568
void DoesNotMatch(const Ch *str, SizeType length)
Definition: schema.h:2627
void TooFewItems(SizeType actualCount, SizeType expectedCount)
Definition: schema.h:2638
void SetValidateFlags(unsigned flags)
Implementation of ISchemaValidator.
Definition: schema.h:2534
void DisallowedValue(const ValidateErrorCode code=kValidateErrorEnum)
Definition: schema.h:2727
void EndMissingDependentProperties(const SValue &sourceName)
Definition: schema.h:2697
void BelowMinimum(double actual, const SValue &expected, bool exclusive)
Definition: schema.h:2614
size_t GetSize() const
Get the size of string in bytes in the string buffer.
Definition: stringbuffer.h:82
GenericUri Resolve(const GenericUri &baseuri, Allocator *allocator=0)
Resolve this URI against another (base) URI in accordance with URI resolution rules.
Definition: uri.h:156
GenericMemberIterator< false, EncodingType, AllocatorType >::Iterator MemberIterator
Member iterator for iterating in object.
Definition: document.h:676
const GenericValue * ConstValueIterator
Constant value iterator for iterating in array.
Definition: document.h:679
Definition: schema.h:1785
virtual const SchemaDocumentType * GetRemoteDocument(const GenericUri< ValueType, AllocatorType > uri, Specification &spec)
Definition: schema.h:1793
SchemaDocumentType::AllocatorType AllocatorType
Definition: schema.h:1789
virtual ~IGenericRemoteSchemaDocumentProvider()
Definition: schema.h:1791
virtual const SchemaDocumentType * GetRemoteDocument(const Ch *uri, SizeType length)=0
SchemaDocumentType::ValueType ValueType
Definition: schema.h:1788
SchemaDocumentType::PointerType PointerType
Definition: schema.h:3201
const PointerType & GetInvalidDocumentPointer() const
Definition: schema.h:3240
ValidateErrorCode GetInvalidSchemaCode() const
Definition: schema.h:3242
const PointerType & GetInvalidSchemaPointer() const
Definition: schema.h:3238
const Ch * GetInvalidSchemaKeyword() const
Definition: schema.h:3239
const ParseResult & GetParseResult() const
Definition: schema.h:3236
SchemaValidatingReader(InputStream &is, const SchemaDocumentType &sd)
Constructor.
Definition: schema.h:3210
GenericValue< SourceEncoding, StackAllocator > ValueType
Definition: schema.h:3203
Regular expression engine with subset of ECMAscript grammar.
Definition: regex.h:110
Definition: schema.h:330
Hasher(Allocator *allocator=0, size_t stackCapacity=kDefaultSize)
Definition: schema.h:334
bool RawNumber(const Ch *str, SizeType len, bool)
Definition: schema.h:350
Definition: schema.h:254
virtual void DestroySchemaValidator(ISchemaValidator *validator)=0
virtual void FreeState(void *p)=0
virtual void * CreateHasher()=0
virtual void DestroryHasher(void *hasher)=0
virtual ISchemaValidator * CreateSchemaValidator(const SchemaType &, const bool inheritContinueOnErrors)=0
virtual void * MallocState(size_t size)=0
virtual uint64_t GetHashCode(void *hasher)=0
virtual ~ISchemaStateFactory()
Definition: schema.h:256
Definition: schema.h:242
virtual void SetValidateFlags(unsigned flags)=0
virtual bool IsValid() const =0
virtual unsigned GetValidateFlags() const =0
Definition: schema.h:270
virtual void EndMissingDependentProperties(const SValue &sourceName)=0
virtual void DisallowedItem(SizeType index)=0
virtual void NotMultipleOf(int64_t actual, const SValue &expected)=0
virtual void DisallowedWhenWriting()=0
virtual void AddMissingDependentProperty(const SValue &targetName)=0
virtual void TooManyProperties(SizeType actualCount, SizeType expectedCount)=0
virtual bool EndMissingProperties()=0
virtual void DuplicateItems(SizeType index1, SizeType index2)=0
virtual void AddMissingProperty(const SValue &name)=0
virtual void NotAllOf(ISchemaValidator **subvalidators, SizeType count)=0
virtual void AddDependencySchemaError(const SValue &souceName, ISchemaValidator *subvalidator)=0
virtual void Disallowed()=0
virtual void TooShort(const Ch *str, SizeType length, SizeType expected)=0
virtual void BelowMinimum(int64_t actual, const SValue &expected, bool exclusive)=0
virtual void AboveMaximum(double actual, const SValue &expected, bool exclusive)=0
virtual void AddExpectedType(const typename SchemaType::ValueType &expectedType)=0
virtual void DisallowedValue(const ValidateErrorCode code)=0
virtual void DisallowedProperty(const Ch *name, SizeType length)=0
virtual void NoneOf(ISchemaValidator **subvalidators, SizeType count)=0
virtual void NotOneOf(ISchemaValidator **subvalidators, SizeType count)=0
virtual void AboveMaximum(uint64_t actual, const SValue &expected, bool exclusive)=0
virtual ~IValidationErrorHandler()
Definition: schema.h:275
virtual void AboveMaximum(int64_t actual, const SValue &expected, bool exclusive)=0
virtual bool EndDependencyErrors()=0
virtual void BelowMinimum(double actual, const SValue &expected, bool exclusive)=0
virtual void TooManyItems(SizeType actualCount, SizeType expectedCount)=0
virtual void DoesNotMatch(const Ch *str, SizeType length)=0
virtual void StartDisallowedType()=0
virtual void BelowMinimum(uint64_t actual, const SValue &expected, bool exclusive)=0
virtual void StartDependencyErrors()=0
virtual void PropertyViolations(ISchemaValidator **subvalidators, SizeType count)=0
virtual void StartMissingProperties()=0
virtual void DisallowedWhenReading()=0
virtual void EndDisallowedType(const typename SchemaType::ValueType &actualType)=0
virtual void NotMultipleOf(uint64_t actual, const SValue &expected)=0
virtual void NotMultipleOf(double actual, const SValue &expected)=0
virtual void TooFewProperties(SizeType actualCount, SizeType expectedCount)=0
virtual void TooLong(const Ch *str, SizeType length, SizeType expected)=0
virtual void StartMissingDependentProperties()=0
virtual void MultipleOneOf(SizeType index1, SizeType index2)=0
virtual void TooFewItems(SizeType actualCount, SizeType expectedCount)=0
Definition: schema.h:518
IValidationErrorHandler< Schema > ErrorHandler
Definition: schema.h:528
const Specification & GetSpecification() const
Definition: schema.h:859
bool EndObject(Context &context, SizeType memberCount) const
Definition: schema.h:1157
Schema(SchemaDocumentType *schemaDocument, const PointerType &p, const ValueType &value, const ValueType &document, AllocatorType *allocator, const UriType &id=UriType())
Definition: schema.h:532
SchemaDocumentType::AllocatorType AllocatorType
Definition: schema.h:521
bool EndArray(Context &context, SizeType elementCount) const
Definition: schema.h:1218
bool String(Context &context, const Ch *str, SizeType length, bool) const
Definition: schema.h:1053
bool Key(Context &context, const Ch *str, SizeType len, bool) const
Definition: schema.h:1104
static const ValueType & GetValidateErrorKeyword(ValidateErrorCode validateErrorCode)
Definition: schema.h:1235
SchemaValidationContext< SchemaDocumentType > Context
Definition: schema.h:525
RAPIDJSON_FORCEINLINE bool EndValue(Context &context) const
Definition: schema.h:899
Concept for allocating, resizing and freeing memory block.
Concept for receiving events from GenericReader upon parsing. The functions return true if no error o...
#define RAPIDJSON_VALIDATE_DEFAULT_FLAGS
User-defined kValidateDefaultFlags definition.
Definition: schema.h:174
#define RAPIDJSON_NAMESPACE_BEGIN
provide custom rapidjson namespace (opening expression)
Definition: rapidjson.h:121
#define RAPIDJSON_NAMESPACE_END
provide custom rapidjson namespace (closing expression)
Definition: rapidjson.h:124
@ kValidateErrorMinProperties
Object has less members than 'minProperties' value.
Definition: error.h:182
@ kValidateErrorExclusiveMinimum
Number is less than or equal to the 'minimum' value.
Definition: error.h:170
@ kValidateErrorAdditionalItems
Array has additional items that are not allowed by the schema.
Definition: error.h:179
@ kValidateErrorMaxProperties
Object has more members than 'maxProperties' value.
Definition: error.h:181
@ kValidateErrorOneOfMatch
Property matched more than one of the sub-schemas specified by 'oneOf'.
Definition: error.h:192
@ kValidateErrorRequired
Object is missing one or more members required by the schema.
Definition: error.h:183
@ kValidateErrorDependencies
Object has missing property or schema dependencies.
Definition: error.h:186
@ kValidateErrorUniqueItems
Array has duplicate items but 'uniqueItems' is true.
Definition: error.h:178
@ kValidateErrorReadOnly
Property is read-only but has been provided when validation is for writing.
Definition: error.h:197
@ kValidateErrorEnum
Property has a value that is not one of its allowed enumerated values.
Definition: error.h:188
@ kValidateErrorExclusiveMaximum
Number is greater than or equal to the 'maximum' value.
Definition: error.h:168
@ kValidateErrorType
Property has a type that is not allowed by the schema.
Definition: error.h:189
@ kValidateErrorOneOf
Property did not match any of the sub-schemas specified by 'oneOf'.
Definition: error.h:191
@ kValidateErrorMinLength
String is longer than the 'maxLength' value.
Definition: error.h:173
@ kValidateErrors
Top level error code when kValidateContinueOnErrorsFlag set.
Definition: error.h:163
@ kValidateErrorMaxLength
String is longer than the 'maxLength' value.
Definition: error.h:172
@ kValidateErrorWriteOnly
Property is write-only but has been provided when validation is for reading.
Definition: error.h:198
@ kValidateErrorAnyOf
Property did not match any of the sub-schemas specified by 'anyOf'.
Definition: error.h:194
@ kValidateErrorPattern
String does not match the 'pattern' regular expression.
Definition: error.h:174
@ kValidateErrorMaximum
Number is greater than the 'maximum' value.
Definition: error.h:167
@ kValidateErrorMaxItems
Array is longer than the 'maxItems' value.
Definition: error.h:176
@ kValidateErrorMinimum
Number is less than the 'minimum' value.
Definition: error.h:169
@ kValidateErrorMultipleOf
Number is not a multiple of the 'multipleOf' value.
Definition: error.h:166
@ kValidateErrorMinItems
Array is shorter than the 'minItems' value.
Definition: error.h:177
@ kValidateErrorNot
Property matched the sub-schema specified by 'not'.
Definition: error.h:195
@ kValidateErrorAdditionalProperties
Object has additional members that are not allowed by the schema.
Definition: error.h:184
@ kValidateErrorPatternProperties
See other errors.
Definition: error.h:185
@ kValidateErrorAllOf
Property did not match all of the sub-schemas specified by 'allOf'.
Definition: error.h:193
@ kSchemaErrorStartUnknown
Pointer to start of schema does not resolve to a location in the document.
Definition: error.h:223
@ kSchemaErrorSpecIllegal
Both JSON schema draft and OpenAPI version found in document.
Definition: error.h:234
@ kSchemaErrorSpecUnsupported
JSON schema draft or OpenAPI version is not supported.
Definition: error.h:233
@ kSchemaErrorRefPlainName
$ref fragment must be a JSON pointer
Definition: error.h:224
@ kSchemaErrorRefNoRemoteProvider
$ref is remote but there is no remote provider
Definition: error.h:229
@ kSchemaErrorSpecUnknown
JSON schema draft or OpenAPI version is not recognized.
Definition: error.h:232
@ kSchemaErrorRefUnknown
$ref does not resolve to a location in the target document
Definition: error.h:227
@ kSchemaErrorRefPointerInvalid
$ref fragment is not a valid JSON pointer at offset
Definition: error.h:226
@ kSchemaErrorRefNoRemoteSchema
$ref is remote but the remote provider did not return a schema
Definition: error.h:230
@ kSchemaErrorRefInvalid
$ref must not be an empty string
Definition: error.h:225
@ kSchemaErrorRegexInvalid
Invalid regular expression in 'pattern' or 'patternProperties'.
Definition: error.h:231
@ kSchemaErrorReadOnlyAndWriteOnly
Property must not be both 'readOnly' and 'writeOnly'.
Definition: error.h:235
__host__ constexpr __device__ auto depth(const Layout< Shape, UnrolledDescriptorType > &layout)
Get depth of the layout shape (return 0 if scalar).
Definition: layout_utils.hpp:371
auto copy(InputRange &&range, OutputIterator iter) -> decltype(std::copy(std::begin(std::forward< InputRange >(range)), std::end(std::forward< InputRange >(range)), iter))
Definition: algorithm.hpp:14
Definition: allocators.h:423
#define RAPIDJSON_DELETE(x)
! customization point for global delete
Definition: rapidjson.h:716
RAPIDJSON_NAMESPACE_BEGIN typedef unsigned SizeType
Size type (for string lengths, array sizes, etc.)
Definition: rapidjson.h:415
#define RAPIDJSON_UINT64_C2(high32, low32)
Construct a 64-bit literal by a pair of 32-bit integer.
Definition: rapidjson.h:320
#define RAPIDJSON_NEW(TypeName)
! customization point for global new
Definition: rapidjson.h:712
#define RAPIDJSON_SCHEMA_HANDLE_BEGIN_(method, arg1)
Definition: schema.h:2799
@ kValidateDefaultFlags
Default validate flags. Can be customized by defining RAPIDJSON_VALIDATE_DEFAULT_FLAGS.
Definition: schema.h:183
@ kValidateContinueOnErrorFlag
Don't stop after first validation error.
Definition: schema.h:180
GenericSchemaDocument< Value > SchemaDocument
GenericSchemaDocument using Value type.
Definition: schema.h:2414
#define RAPIDJSON_SCHEMA_HANDLE_VALUE_(method, arg1, arg2)
Definition: schema.h:2825
#define RAPIDJSON_SCHEMA_HANDLE_END_(method, arg2)
Definition: schema.h:2821
#define RAPIDJSON_INVALID_KEYWORD_RETURN(code)
Definition: schema.h:156
#define RAPIDJSON_SCHEMA_HANDLE_PARALLEL_(method, arg2)
Definition: schema.h:2809
IGenericRemoteSchemaDocumentProvider< SchemaDocument > IRemoteSchemaDocumentProvider
IGenericRemoteSchemaDocumentProvider using SchemaDocument.
Definition: schema.h:2416
Definition: schema.h:212
Definition: schema.h:428
const SchemaType ** patternPropertiesSchemas
Definition: schema.h:503
SizeType arrayElementIndex
Definition: schema.h:507
SizeType patternPropertiesValidatorCount
Definition: schema.h:502
ISchemaStateFactory< SchemaType > SchemaValidatorFactoryType
Definition: schema.h:430
const SchemaType * valueSchema
Definition: schema.h:494
IValidationErrorHandler< SchemaType > ErrorHandlerType
Definition: schema.h:431
@ kPatternValidatorWithProperty
Definition: schema.h:437
@ kPatternValidatorWithAdditionalProperty
Definition: schema.h:438
@ kPatternValidatorOnly
Definition: schema.h:436
void * arrayElementHashCodes
Definition: schema.h:498
ISchemaValidator ** patternPropertiesValidators
Definition: schema.h:501
SizeType patternPropertiesSchemaCount
Definition: schema.h:504
Schema< SchemaDocumentType > SchemaType
Definition: schema.h:429
SchemaValidationContext(SchemaValidatorFactoryType &f, ErrorHandlerType &eh, const SchemaType *s, unsigned fl=0)
Definition: schema.h:441
~SchemaValidationContext()
Definition: schema.h:465
PatternValidatorType valuePatternValidatorType
Definition: schema.h:505
ErrorHandlerType & error_handler
Definition: schema.h:491
PatternValidatorType objectPatternValidatorType
Definition: schema.h:506
SchemaValidatorFactoryType & factory
Definition: schema.h:490
static RAPIDJSON_FORCEINLINE void AppendIndexToken(Stack &documentStack, SizeType index)
Definition: schema.h:1763
Definition: schema.h:1750
static RAPIDJSON_FORCEINLINE void AppendIndexToken(Stack &documentStack, SizeType index)
Definition: schema.h:1751
Definition: schema.h:393