-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathrdf_nodes.cpp
More file actions
73 lines (57 loc) · 2.22 KB
/
rdf_nodes.cpp
File metadata and controls
73 lines (57 loc) · 2.22 KB
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
#include <rdf4cpp.hpp>
#include <iostream>
int main() {
using namespace rdf4cpp;
query::Variable variable("x");
std::cout << variable << std::endl;
query::Variable variable2("x1", true);
std::cout << "variable2 =" << variable2 << std::endl;
query::Variable variable3{"x1", true};
std::cout << "variable3 =" << variable2 << std::endl;
std::cout << "(variable 2 == variable3) = " << (variable2 == variable3) << std::endl;
BlankNode blankNode("x1");
std::cout << "blankNode =" << blankNode << std::endl;
std::cout << "(variable2 != blankNode) = " << (variable2 != blankNode) << std::endl;
IRI iri = IRI("http://example.com/");
std::cout << iri << std::endl;
IRI iri_pred("http://example.com/pred");
std::cout << iri_pred << std::endl;
auto print_literal_info = [](Literal lit) {
std::cout << "---" << std::endl;
std::cout << "operator<<: " << lit << std::endl;
std::cout << "lexical_form: " << lit.lexical_form() << std::endl;
std::cout << "datatype: " << lit.datatype() << std::endl;
std::cout << "language_tag: " << lit.language_tag() << std::endl;
std::cout << "---" << std::endl;
};
auto lit1 = Literal::make_simple("xxxx");
auto lit2 = Literal::make_typed("xxxx", iri_pred);
auto lit3 = Literal::make_typed("xxxx", IRI("http://example.com/pred2"));
auto lit4 = Literal::make_lang_tagged("xxxx", "de");
auto lit5 = Literal::make_lang_tagged("xxxx", "de");
print_literal_info(lit1);
print_literal_info(lit2);
print_literal_info(lit3);
print_literal_info(lit4);
print_literal_info(lit5);
std::vector<Node> nodes{};
nodes.push_back(variable);
nodes.push_back(variable2);
nodes.push_back(blankNode);
nodes.push_back(iri_pred);
nodes.push_back(lit1);
nodes.push_back(lit2);
nodes.push_back(lit3);
nodes.push_back(lit4);
nodes.push_back(lit5);
nodes.push_back(lit4.datatype());
std::sort(nodes.begin(), nodes.end());
std::cout << "sorted:" << std::endl;
for (const auto &item : nodes) {
std::cout << item << std::endl;
}
if (nodes[1].is_variable()) {
auto v = nodes[1].as_variable();
std::cout << v << std::endl;
}
}