kDB: Knowledge DataBase
Loading...
Searching...
No Matches
Path.h
1#pragma once
2
3#include "Forward.h"
4
5#include <QExplicitlySharedDataPointer>
6#include <optional>
7
8namespace knowSHACL
9{
14 class Path
15 {
16 friend class details::DefinitionParser;
17 friend class Validator;
18 friend class ValidationResults;
19 public:
20 Path();
21 Path(const Path& _rhs);
22 Path& operator=(const Path& _rhs);
23 ~Path();
24 enum class Type
25 {
26 Predicate,
27 Alternative,
28 Inverse,
29 ZeroOrMore,
30 OneOrMore,
31 ZeroOrOne,
32 PropertyPath //< work around ill-formation of the standard SHACL validator
33 };
34 Type type() const;
38 bool isValid() const;
39 knowCore::Uri predicate() const;
40 knowCore::UriList alternatives() const;
41 std::optional<Path> next() const;
42 bool match(const knowCore::Uri&) const;
46 bool operator==(const Path& _rhs) const;
47 private:
48 struct Private;
49 QExplicitlySharedDataPointer<Private> d;
50 };
51} // namespace knowSHACL
52
53#include <knowCore/Formatter.h>
54#include <knowCore/Uri.h>
55
56clog_format_declare_enum_formatter(knowSHACL::Path::Type, Predicate, Alternative, Inverse,
57 ZeroOrMore, OneOrMore, ZeroOrOne, PropertyPath);
58
59clog_format_declare_formatter(knowSHACL::Path)
60{
61 if(p.isValid())
62 {
63 if(p.next())
64 {
65 return format_to(ctx.out(), "{} {} {}", p.type(), p.predicate(), *p.next());
66 }
67 else
68 {
69 return format_to(ctx.out(), "{} {}", p.type(), p.predicate());
70 }
71 }
72 else
73 {
74 return format_to(ctx.out(), "invalid path");
75 }
76}
Definition UriList.h:9
Definition Uri.h:15
Definition Path.h:15
bool isValid() const
Definition Path.cpp:19
bool operator==(const Path &_rhs) const
Definition Path.cpp:48
Definition ValidationResults.h:8
Definition Validator.h:20
Definition DefinitionParser_p.h:6
Definition Path_p.h:6