Sourcemeta Core 0.0.0
Loading...
Searching...
No Matches
jsonld.h
1#ifndef SOURCEMETA_CORE_JSONLD_H_
2#define SOURCEMETA_CORE_JSONLD_H_
3
4#ifndef SOURCEMETA_CORE_JSONLD_EXPORT
5#include <sourcemeta/core/jsonld_export.h>
6#endif
7
8#include <sourcemeta/core/json.h>
9#include <sourcemeta/core/jsonld_error.h>
10#include <sourcemeta/core/jsonld_materialize.h>
11
12#include <cstdint> // std::uint8_t
13#include <functional> // std::function
14#include <optional> // std::optional
15
25
26namespace sourcemeta::core {
27
32using JSONLDResolver = std::function<std::optional<JSON>(JSON::StringView)>;
33
36enum class JSONLDVersion : std::uint8_t {
41};
42
70
82using JSONLDExpandDropCallback = std::function<void(
83 JSONLDExpandDropReason, const WeakPointer &, const JSON &)>;
84
105SOURCEMETA_CORE_JSONLD_EXPORT
106auto jsonld_expand(const JSON &input, const JSON::StringView base_iri = "",
107 const JSONLDResolver &resolver = {},
108 const JSONLDVersion version = JSONLDVersion::V1_1,
109 const JSONLDExpandDropCallback &drop_callback = {}) -> JSON;
110
131SOURCEMETA_CORE_JSONLD_EXPORT
132auto jsonld_expand(const JSON &input, const JSON &expand_context,
133 const JSON::StringView base_iri = "",
134 const JSONLDResolver &resolver = {},
135 const JSONLDVersion version = JSONLDVersion::V1_1,
136 const JSONLDExpandDropCallback &drop_callback = {}) -> JSON;
137
155SOURCEMETA_CORE_JSONLD_EXPORT
156auto jsonld_is_expanded(const JSON &document) -> bool;
157
181SOURCEMETA_CORE_JSONLD_EXPORT
182auto jsonld_compact(const JSON &input, const JSON &context,
183 const JSON::StringView base_iri = "",
184 const JSONLDResolver &resolver = {},
185 const JSONLDVersion version = JSONLDVersion::V1_1,
186 const bool compact_arrays = true,
187 const bool compact_to_relative = true) -> JSON;
188
211SOURCEMETA_CORE_JSONLD_EXPORT
212auto jsonld_flatten(const JSON &input) -> JSON;
213
237SOURCEMETA_CORE_JSONLD_EXPORT
238auto jsonld_flatten(const JSON &input, const JSON &context,
239 const JSON::StringView base_iri = "",
240 const JSONLDResolver &resolver = {},
241 const JSONLDVersion version = JSONLDVersion::V1_1,
242 const bool compact_arrays = true) -> JSON;
243
244} // namespace sourcemeta::core
245
246#endif
std::basic_string_view< Char, CharTraits > StringView
The string view type used by the JSON document.
Definition json_value.h:54
Definition json_value.h:39
SOURCEMETA_CORE_JSONLD_EXPORT auto jsonld_expand(const JSON &input, const JSON::StringView base_iri="", const JSONLDResolver &resolver={}, const JSONLDVersion version=JSONLDVersion::V1_1, const JSONLDExpandDropCallback &drop_callback={}) -> JSON
std::function< void( JSONLDExpandDropReason, const WeakPointer &, const JSON &)> JSONLDExpandDropCallback
Definition jsonld.h:82
SOURCEMETA_CORE_JSONLD_EXPORT auto jsonld_flatten(const JSON &input) -> JSON
JSONLDExpandDropReason
Definition jsonld.h:45
SOURCEMETA_CORE_JSONLD_EXPORT auto jsonld_is_expanded(const JSON &document) -> bool
std::function< std::optional< JSON >(JSON::StringView)> JSONLDResolver
Definition jsonld.h:32
JSONLDVersion
Definition jsonld.h:36
SOURCEMETA_CORE_JSONLD_EXPORT auto jsonld_compact(const JSON &input, const JSON &context, const JSON::StringView base_iri="", const JSONLDResolver &resolver={}, const JSONLDVersion version=JSONLDVersion::V1_1, const bool compact_arrays=true, const bool compact_to_relative=true) -> JSON
@ FreeFloatingValue
Definition jsonld.h:66
@ IncompleteValueObject
A value object that carries a language or a direction but no value.
Definition jsonld.h:63
@ UnhandledKeyword
Definition jsonld.h:59
@ NullValueObject
A value object whose value is null.
Definition jsonld.h:61
@ UndefinedType
A type that expands to no absolute IRI, which cannot name a type.
Definition jsonld.h:56
@ KeywordFormKey
Definition jsonld.h:51
@ UndefinedKey
Definition jsonld.h:48
@ NullValue
A null written where a value was expected.
Definition jsonld.h:68
@ V1_1
The JSON-LD 1.1 processing mode.
Definition jsonld.h:40
@ V1_0
The JSON-LD 1.0 processing mode.
Definition jsonld.h:38
GenericPointer< std::reference_wrapper< const std::string >, PropertyHashJSON< JSON::String > > WeakPointer
Definition jsonpointer.h:46