Sourcemeta Core 0.0.0
Loading...
Searching...
No Matches
jsonld_materialize.h
1#ifndef SOURCEMETA_CORE_JSONLD_MATERIALIZE_H_
2#define SOURCEMETA_CORE_JSONLD_MATERIALIZE_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/jsonpointer.h>
10
11#include <cstdint> // std::uint8_t
12#include <optional> // std::optional
13#include <variant> // std::variant
14#include <vector> // std::vector
15
16namespace sourcemeta::core {
17
21struct JSONLDEdge {
25 bool reverse{false};
26};
27
30enum class JSONLDDirection : std::uint8_t {
35};
36
41struct JSONLDNode {
43 std::optional<JSON::String> id{};
45 std::vector<JSON::String> types{};
47 bool graph{false};
52};
53
62 std::optional<JSON::String> datatype{};
64 std::optional<JSON::String> language{};
66 std::optional<JSONLDDirection> direction{};
68 bool json{false};
69};
70
77 std::vector<JSON::String> types{};
82};
83
91 std::optional<JSON::String> id{};
93 std::vector<JSON::String> types{};
103};
104
108enum class JSONLDContainer : std::uint8_t {
117};
118
128
134 std::vector<JSONLDEdge> edges{};
139};
140
143template <typename PointerT> struct JSONLDBasicAnnotation {
145 PointerT pointer{};
148};
149
153template <typename PointerT>
154using JSONLDBasicAnnotationList = std::vector<JSONLDBasicAnnotation<PointerT>>;
155
159
165
198SOURCEMETA_CORE_JSONLD_EXPORT
199auto jsonld_materialize(const JSON &instance,
200 const JSONLDAnnotationList &annotations) -> JSON;
201
238SOURCEMETA_CORE_JSONLD_EXPORT
239auto jsonld_materialize(const JSON &instance,
240 const JSONLDWeakAnnotationList &annotations) -> JSON;
241
266SOURCEMETA_CORE_JSONLD_EXPORT
267auto jsonld_canonicalize_fragment(const JSON &fragment) -> JSON;
268
269} // namespace sourcemeta::core
270
271#endif
std::basic_string< Char, CharTraits, Allocator< Char > > String
The string type used by the JSON document.
Definition json_value.h:52
static auto make_object() -> JSON
Definition json_value.h:39
bool graph
Whether the node's descendants are asserted in the named graph it denotes.
Definition jsonld_materialize.h:47
JSON::String value
The predicate that carries the scalar.
Definition jsonld_materialize.h:95
std::optional< JSON::String > language
The language tag of the literal.
Definition jsonld_materialize.h:64
std::vector< JSONLDEdge > edges
How the position connects to its parent.
Definition jsonld_materialize.h:134
JSONLDContainer container
The container form of the collection.
Definition jsonld_materialize.h:126
JSON constants
Definition jsonld_materialize.h:102
bool json
Whether the literal is preserved as an opaque JSON literal.
Definition jsonld_materialize.h:68
JSONLDLiteral literal
Definition jsonld_materialize.h:98
JSON constants
Definition jsonld_materialize.h:51
std::optional< JSON::String > datatype
Definition jsonld_materialize.h:62
JSON::String predicate
The predicate that connects the position to its parent.
Definition jsonld_materialize.h:23
std::vector< JSON::String > types
The types of the promoted node.
Definition jsonld_materialize.h:93
std::optional< JSONLDDirection > direction
The base direction of the literal.
Definition jsonld_materialize.h:66
bool reverse
Whether the edge is asserted in reverse.
Definition jsonld_materialize.h:25
std::vector< JSON::String > types
The types of the node.
Definition jsonld_materialize.h:45
JSONLDDescriptor descriptor
The JSON-LD semantics of the position.
Definition jsonld_materialize.h:147
std::variant< JSONLDNode, JSONLDLiteral, JSONLDReference, JSONLDCollection, JSONLDPromotion > value
What the position is.
Definition jsonld_materialize.h:138
JSON constants
Definition jsonld_materialize.h:81
std::vector< JSON::String > types
The types of the promoted node.
Definition jsonld_materialize.h:77
JSONLDContainer
Definition jsonld_materialize.h:108
JSONLDBasicAnnotationList< Pointer > JSONLDAnnotationList
Definition jsonld_materialize.h:158
JSONLDDirection
Definition jsonld_materialize.h:30
JSONLDBasicAnnotationList< WeakPointer > JSONLDWeakAnnotationList
Definition jsonld_materialize.h:164
SOURCEMETA_CORE_JSONLD_EXPORT auto jsonld_materialize(const JSON &instance, const JSONLDAnnotationList &annotations) -> JSON
std::vector< JSONLDBasicAnnotation< PointerT > > JSONLDBasicAnnotationList
Definition jsonld_materialize.h:154
SOURCEMETA_CORE_JSONLD_EXPORT auto jsonld_canonicalize_fragment(const JSON &fragment) -> JSON
@ Language
A map of language tag to string ranging over an object.
Definition jsonld_materialize.h:114
@ List
An ordered RDF list ranging over an array.
Definition jsonld_materialize.h:110
@ Set
An unordered set ranging over an array.
Definition jsonld_materialize.h:112
@ Index
A map of index labels carrying no RDF ranging over an object.
Definition jsonld_materialize.h:116
@ LTR
The left-to-right base direction.
Definition jsonld_materialize.h:32
@ RTL
The right-to-left base direction.
Definition jsonld_materialize.h:34
Definition jsonld_materialize.h:143
Definition jsonld_materialize.h:124
Definition jsonld_materialize.h:132
Definition jsonld_materialize.h:21
Definition jsonld_materialize.h:58
Definition jsonld_materialize.h:41
Definition jsonld_materialize.h:89
Definition jsonld_materialize.h:73