-
Notifications
You must be signed in to change notification settings - Fork 2
/
update.h
102 lines (79 loc) · 2.42 KB
/
update.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
#pragma once
#include "atoms.h"
#include "algebra.h"
#include "dataset.h"
#include "triples.h"
namespace sparqlxx
{
// SPARQL Update operations - inline namespace
inline namespace UpdateCmd
{
using GraphRef = Iri;
struct [[gnu::visibility("default")]] Default {Default(){} Default(const Default&){}};
struct [[gnu::visibility("default")]] Named {Named(){} Named(const Named&){}};
struct [[gnu::visibility("default")]] All {All(){} All(const All&){}};
using GraphRefAll = xx::variant<GraphRef, Default, Named, All>;
using GraphOrDefault = xx::variant<GraphRef, Default>;
struct [[gnu::visibility("default")]] Create
{
bool silent;
GraphRef what;
Create(bool silent, GraphRef&& what): silent(silent), what(std::move(what)) {}
};
struct [[gnu::visibility("default")]] Load
{
bool silent;
Iri what;
optional<GraphRef> into;
Load(bool silent, Iri&& what, optional<GraphRef>&& into = nullopt): silent(silent), what(std::move(what)), into(std::move(into)) {}
};
struct [[gnu::visibility("default")]] Clear
{
bool silent;
GraphRefAll what;
Clear(bool silent, GraphRefAll&& what): silent(silent), what(std::move(what)) {}
};
struct [[gnu::visibility("default")]] Drop
{
bool silent;
GraphRefAll what;
Drop(bool silent, GraphRefAll&& what): silent(silent), what(std::move(what)) {}
};
struct [[gnu::visibility("default")]] MassOp
{
enum class Type { Move, Copy, Add } type;
bool silent;
GraphOrDefault from;
GraphOrDefault to;
MassOp(Type type, bool silent, GraphOrDefault&& from, GraphOrDefault&& to): type(type), silent(silent), from{std::move(from)}, to{std::move(to)} {}
};
struct [[gnu::visibility("default")]] InsertData
{
Quads data;
InsertData(Quads&& data): data(std::move(data)) {}
};
struct [[gnu::visibility("default")]] DeleteData
{
Quads data;
DeleteData(Quads&& data): data(std::move(data)) {}
};
struct [[gnu::visibility("default")]] Modify
{
optional<Iri> with;
QuadPatternN delete_;
QuadPatternN insert_;
Dataset using_;
Algebra::AnyOp where;
Modify() {}
};
inline auto DeleteWhere(QuadPatternN&& data)
{
auto q = Modify{};
q.delete_ = data;
q.where = Algebra::make<Algebra::Quad>(std::move(data));
return q;
}
using ModifyOrData = xx::variant<InsertData, DeleteData, Modify>;
}
using Update = xx::variant<InsertData, DeleteData, Modify, MassOp, Create, Load, Clear, Drop>;
}