Compile a JSON Schema into a set of low-level instructions for fast evaluation. More...
Classes | |
| struct | sourcemeta::blaze::SchemaContext |
| struct | sourcemeta::blaze::DynamicContext |
| struct | sourcemeta::blaze::Tweaks |
| struct | sourcemeta::blaze::Context |
| struct | sourcemeta::blaze::SchemaUnevaluatedEntry |
Typedefs | |
| using | sourcemeta::blaze::Compiler = std::function< Instructions(const Context &, const SchemaContext &, const DynamicContext &, const Instructions &)> |
| using | sourcemeta::blaze::SchemaUnevaluatedEntries = std::map< sourcemeta::core::JSON::String, SchemaUnevaluatedEntry > |
Functions | |
| auto | sourcemeta::blaze::default_schema_compiler (const Context &, const SchemaContext &, const DynamicContext &, const Instructions &) -> Instructions |
| auto | sourcemeta::blaze::compile (const sourcemeta::core::JSON &schema, const sourcemeta::blaze::SchemaWalker &walker, const sourcemeta::blaze::SchemaResolver &resolver, const Compiler &compiler, const Mode mode=Mode::FastValidation, const std::string_view default_dialect="", const std::string_view default_id="", const std::string_view entrypoint="", const std::optional< Tweaks > &tweaks=std::nullopt) -> Template |
| auto | sourcemeta::blaze::compile (const sourcemeta::core::JSON &schema, const sourcemeta::blaze::SchemaWalker &walker, const sourcemeta::blaze::SchemaResolver &resolver, const Compiler &compiler, const sourcemeta::blaze::SchemaFrame &frame, const std::string_view entrypoint, const Mode mode=Mode::FastValidation, const std::optional< Tweaks > &tweaks=std::nullopt) -> Template |
| auto | sourcemeta::blaze::compile (const Context &context, const SchemaContext &schema_context, const DynamicContext &dynamic_context, const sourcemeta::core::WeakPointer &schema_suffix, const sourcemeta::core::WeakPointer &instance_suffix=sourcemeta::core::empty_weak_pointer, std::optional< std::string_view > uri=std::nullopt) -> Instructions |
| auto | sourcemeta::blaze::to_json (const Template &schema_template) -> sourcemeta::core::JSON |
Compile a JSON Schema into a set of low-level instructions for fast evaluation.
| struct sourcemeta::blaze::SchemaContext |
The schema compiler context is the current subschema information you have at your disposal to implement a keyword
Public Attributes | |
| const sourcemeta::core::WeakPointer & | relative_pointer |
| The schema location relative to the base URI. | |
| const sourcemeta::core::JSON & | schema |
| The current subschema. | |
| const sourcemeta::blaze::Vocabularies & | vocabularies |
| The schema vocabularies in use. | |
| const sourcemeta::core::URI & | base |
| The schema base URI. | |
| bool | is_property_name |
| Whether the current schema targets a property name. | |
| struct sourcemeta::blaze::DynamicContext |
The dynamic compiler context is the read-write information you have at your disposal to implement a keyword
| struct sourcemeta::blaze::Tweaks |
Advanced knobs that you can tweak for higher control and optimisations
| struct sourcemeta::blaze::Context |
The static compiler context is the information you have at your disposal to implement a keyword that will never change throughout the compilation process
Public Attributes | |
| const sourcemeta::core::JSON & | root |
| The root schema resource. | |
| const sourcemeta::blaze::SchemaFrame & | frame |
| The reference frame of the entire schema. | |
| const std::vector< std::string > | resources |
| The set of all schema resources in the schema without duplicates. | |
| const sourcemeta::blaze::SchemaWalker & | walker |
| The schema walker in use. | |
| const sourcemeta::blaze::SchemaResolver & | resolver |
| The schema resolver in use. | |
| const Compiler & | compiler |
| The schema compiler in use. | |
| const Mode | mode |
| The mode of the schema compiler. | |
| const bool | uses_dynamic_scopes |
| Whether the schema makes use of dynamic scoping. | |
| const SchemaUnevaluatedEntries | unevaluated |
| The list of unevaluated entries and their dependencies. | |
| const Tweaks | tweaks |
| The set of tweaks for the compiler. | |
| const std::map< std::tuple< sourcemeta::blaze::SchemaReferenceType, std::string_view, bool >, std::pair< std::size_t, const sourcemeta::core::WeakPointer * > > | targets |
| All possible reference targets (key includes is_property_name context) | |
| std::vector< InstructionExtra > & | extra |
| Accumulator for instruction extra data during compilation. | |
| struct sourcemeta::blaze::SchemaUnevaluatedEntry |
Public Attributes | |
| std::set< sourcemeta::core::WeakPointer > | static_dependencies |
| The absolute pointers of the static keyword dependencies. | |
| std::set< sourcemeta::core::WeakPointer > | dynamic_dependencies |
| The absolute pointers of the static keyword dependencies. | |
| bool | unresolved {false} |
| bool sourcemeta::blaze::SchemaUnevaluatedEntry::unresolved {false} |
Whether the entry cannot be fully resolved, which means there might be unknown dynamic dependencies
| using sourcemeta::blaze::Compiler = typedef std::function<Instructions(const Context &, const SchemaContext &, const DynamicContext &, const Instructions &)> |
A compiler is represented as a function that maps a keyword compiler contexts into a compiler template. You can provide your own to implement your own keywords
| using sourcemeta::blaze::SchemaUnevaluatedEntries = typedef std::map<sourcemeta::core::JSON::String, SchemaUnevaluatedEntry> |
The flattened set of unevaluated cases in the schema by absolute URI
| auto sourcemeta::blaze::compile | ( | const Context & | context, |
| const SchemaContext & | schema_context, | ||
| const DynamicContext & | dynamic_context, | ||
| const sourcemeta::core::WeakPointer & | schema_suffix, | ||
| const sourcemeta::core::WeakPointer & | instance_suffix = sourcemeta::core::empty_weak_pointer, |
||
| std::optional< std::string_view > | uri = std::nullopt |
||
| ) | -> Instructions |
This function compiles a single subschema into a compiler template as determined by the given pointer. If a URI is given, the compiler will attempt to jump to that corresponding frame entry. Otherwise, it will navigate within the current keyword. This function is not meant to be used directly, but instead as a building block for supporting applicators on compiler functions.
| auto sourcemeta::blaze::compile | ( | const sourcemeta::core::JSON & | schema, |
| const sourcemeta::blaze::SchemaWalker & | walker, | ||
| const sourcemeta::blaze::SchemaResolver & | resolver, | ||
| const Compiler & | compiler, | ||
| const Mode | mode = Mode::FastValidation, |
||
| const std::string_view | default_dialect = "", |
||
| const std::string_view | default_id = "", |
||
| const std::string_view | entrypoint = "", |
||
| const std::optional< Tweaks > & | tweaks = std::nullopt |
||
| ) | -> Template |
This function compiles an input JSON Schema into a template that can be later evaluated. For example:
| auto sourcemeta::blaze::compile | ( | const sourcemeta::core::JSON & | schema, |
| const sourcemeta::blaze::SchemaWalker & | walker, | ||
| const sourcemeta::blaze::SchemaResolver & | resolver, | ||
| const Compiler & | compiler, | ||
| const sourcemeta::blaze::SchemaFrame & | frame, | ||
| const std::string_view | entrypoint, | ||
| const Mode | mode = Mode::FastValidation, |
||
| const std::optional< Tweaks > & | tweaks = std::nullopt |
||
| ) | -> Template |
This function compiles an input JSON Schema into a template that can be later evaluated, but given an existing schema frame. The schema frame must contain reference information for the given schema and the input schema must be bundled. If those pre-conditions are not met, you will hit undefined behavior.
Don't use this function unless you know what you are doing.
| auto sourcemeta::blaze::default_schema_compiler | ( | const Context & | , |
| const SchemaContext & | , | ||
| const DynamicContext & | , | ||
| const Instructions & | |||
| ) | -> Instructions |
A default compiler that aims to implement every keyword for official JSON Schema dialects.
| auto sourcemeta::blaze::to_json | ( | const Template & | schema_template | ) | -> sourcemeta::core::JSON |
Serialise a template as JSON