JSON BinPack  0.0.1
A space-efficient open-source binary JSON serialization format based on JSON Schema with both schema-driven and schema-less support.
Compiler

The built-time schema compiler of JSON BinPack. More...

Functions

SOURCEMETA_JSONBINPACK_COMPILER_EXPORT auto sourcemeta::jsonbinpack::compile (sourcemeta::jsontoolkit::JSON &schema, const sourcemeta::jsontoolkit::SchemaWalker &walker, const sourcemeta::jsontoolkit::SchemaResolver &resolver, const std::optional< std::string > &default_dialect=std::nullopt) -> void
 
SOURCEMETA_JSONBINPACK_COMPILER_EXPORT auto sourcemeta::jsonbinpack::canonicalize (sourcemeta::jsontoolkit::JSON &schema, const sourcemeta::jsontoolkit::SchemaWalker &walker, const sourcemeta::jsontoolkit::SchemaResolver &resolver, const std::optional< std::string > &default_dialect=std::nullopt) -> void
 

Detailed Description

The built-time schema compiler of JSON BinPack.

This functionality is included as follows:

#include <sourcemeta/jsonbinpack/compiler.h>

Function Documentation

◆ canonicalize()

SOURCEMETA_JSONBINPACK_COMPILER_EXPORT auto sourcemeta::jsonbinpack::canonicalize ( sourcemeta::jsontoolkit::JSON &  schema,
const sourcemeta::jsontoolkit::SchemaWalker &  walker,
const sourcemeta::jsontoolkit::SchemaResolver &  resolver,
const std::optional< std::string > &  default_dialect = std::nullopt 
) -> void

Transform a JSON Schema into its canonical form to prepare it for compilation. Keep in mind this function mutates the input schema. Also, the compile function already performs canonicalization. This function is exposed mainly for debugging and testing purposes. For example:

#include <sourcemeta/binpack/compiler.h>
#include <sourcemeta/jsontoolkit/json.h>
#include <sourcemeta/jsontoolkit/jsonschema.h>
#include <iostream>
auto schema{sourcemeta::jsontoolkit::parse(R"JSON({
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "string"
})JSON")};
schema, sourcemeta::jsontoolkit::default_schema_walker,
sourcemeta::jsontoolkit::official_resolver);
sourcemeta::jsontoolkit::prettify(schema, std::cout);
std::cout << std::endl;
SOURCEMETA_JSONBINPACK_COMPILER_EXPORT auto canonicalize(sourcemeta::jsontoolkit::JSON &schema, const sourcemeta::jsontoolkit::SchemaWalker &walker, const sourcemeta::jsontoolkit::SchemaResolver &resolver, const std::optional< std::string > &default_dialect=std::nullopt) -> void

◆ compile()

SOURCEMETA_JSONBINPACK_COMPILER_EXPORT auto sourcemeta::jsonbinpack::compile ( sourcemeta::jsontoolkit::JSON &  schema,
const sourcemeta::jsontoolkit::SchemaWalker &  walker,
const sourcemeta::jsontoolkit::SchemaResolver &  resolver,
const std::optional< std::string > &  default_dialect = std::nullopt 
) -> void

Compile a JSON Schema into an encoding schema. Keep in mind this function mutates the input schema. For example:

#include <sourcemeta/binpack/compiler.h>
#include <sourcemeta/jsontoolkit/json.h>
#include <sourcemeta/jsontoolkit/jsonschema.h>
#include <iostream>
auto schema{sourcemeta::jsontoolkit::parse(R"JSON({
"$schema": "https://json-schema.org/draft/2020-12/schema",
"type": "string"
})JSON")};
schema, sourcemeta::jsontoolkit::default_schema_walker,
sourcemeta::jsontoolkit::official_resolver);
sourcemeta::jsontoolkit::prettify(schema, std::cout);
std::cout << std::endl;
SOURCEMETA_JSONBINPACK_COMPILER_EXPORT auto compile(sourcemeta::jsontoolkit::JSON &schema, const sourcemeta::jsontoolkit::SchemaWalker &walker, const sourcemeta::jsontoolkit::SchemaResolver &resolver, const std::optional< std::string > &default_dialect=std::nullopt) -> void