knowL: Knowledge Libraries
Loading...
Searching...
No Matches
Subject.h
1#pragma once
2
3#include <QSharedDataPointer>
4
5#include <clog_qt>
6#include <cres_qt>
7
8#include <knowCore/Uris/Uris.h>
9
10#include "Forward.h"
11
12class QString;
13
14namespace knowRDF
15{
20 class Subject
21 {
22 public:
23 enum class Type
24 {
25 Undefined,
26 Uri,
28 Variable
29 };
30 public:
31 Subject();
32 Subject(const QString& _string, Type _type);
33 Subject(const knowCore::Uri& _uri);
34 Subject(const knowCore::Uri& _base, const QString& _suffix);
35 Subject(const BlankNode& _blankNodeRef);
36 Subject(const Subject& _rhs);
40 template<typename _T_>
41 requires(knowCore::Uris::IsUriDefinitionV<_T_>)
42 Subject(const _T_& _t) : Subject(knowCore::Uri(_t))
43 {
44 }
45 Subject& operator=(const Subject& _rhs);
46 ~Subject();
47 bool operator==(const Subject& _rhs) const;
48 Type type() const;
49 knowCore::Uri uri() const;
50 BlankNode blankNode() const;
51 QString variableName() const;
52 QByteArray md5() const;
53 QJsonValue toJsonValue() const;
54 static cres_qresult<Subject> fromJsonValue(const QJsonValue& _value);
55 QCborValue toCborValue() const;
56 static cres_qresult<Subject> fromCborValue(const QCborValue& _value);
57 private:
58 struct Private;
59 QSharedDataPointer<Private> d;
60 };
61 uint qHash(const Subject& key, std::size_t seed = 0);
62} // namespace knowRDF
63
64#include "BlankNode.h"
65
66clog_format_declare_formatter(knowRDF::Subject)
67{
68 switch(p.type())
69 {
70 case knowRDF::Subject::Type::Undefined:
71 break;
72 case knowRDF::Subject::Type::Uri:
73 return format_to(ctx.out(), "uri({})", p.uri());
74 case knowRDF::Subject::Type::BlankNode:
75 return format_to(ctx.out(), "blank_node({})", p.blankNode());
76 case knowRDF::Subject::Type::Variable:
77 return format_to(ctx.out(), "variable(?{})", p.variableName());
78 }
79 return format_to(ctx.out(), "undefined()");
80}
Definition Uri.h:15
Definition BlankNode.h:25
Definition Subject.h:21
Subject(const _T_ &_t)
Definition Subject.h:42