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
63SOURCEMETA_CORE_JSONLD_EXPORT
64auto jsonld_expand(const JSON &input, const JSON::StringView base_iri = "",
65 const JSONLDResolver &resolver = {},
66 const JSONLDVersion version = JSONLDVersion::V1_1) -> JSON;
67
88SOURCEMETA_CORE_JSONLD_EXPORT
89auto jsonld_expand(const JSON &input, const JSON &expand_context,
90 const JSON::StringView base_iri = "",
91 const JSONLDResolver &resolver = {},
92 const JSONLDVersion version = JSONLDVersion::V1_1) -> JSON;
93
111SOURCEMETA_CORE_JSONLD_EXPORT
112auto jsonld_is_expanded(const JSON &document) -> bool;
113
137SOURCEMETA_CORE_JSONLD_EXPORT
138auto jsonld_compact(const JSON &input, const JSON &context,
139 const JSON::StringView base_iri = "",
140 const JSONLDResolver &resolver = {},
141 const JSONLDVersion version = JSONLDVersion::V1_1,
142 const bool compact_arrays = true,
143 const bool compact_to_relative = true) -> JSON;
144
167SOURCEMETA_CORE_JSONLD_EXPORT
168auto jsonld_flatten(const JSON &input) -> JSON;
169
193SOURCEMETA_CORE_JSONLD_EXPORT
194auto jsonld_flatten(const JSON &input, const JSON &context,
195 const JSON::StringView base_iri = "",
196 const JSONLDResolver &resolver = {},
197 const JSONLDVersion version = JSONLDVersion::V1_1,
198 const bool compact_arrays = true) -> JSON;
199
200} // namespace sourcemeta::core
201
202#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) -> JSON
SOURCEMETA_CORE_JSONLD_EXPORT auto jsonld_flatten(const JSON &input) -> JSON
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
@ 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