knowL: Knowledge Libraries
Loading...
Searching...
No Matches
Path.h
1#pragma once
2
3#include "Forward.h"
4
5#include <optional>
6#include <QExplicitlySharedDataPointer>
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}
52
53#include <knowCore/Formatter.h>
54
55KNOWCORE_CORE_DECLARE_FORMATTER_ENUM(knowSHACL::Path::Type, Predicate, Alternative, Inverse, ZeroOrMore, OneOrMore, ZeroOrOne, PropertyPath)
56
57KNOWCORE_CORE_DECLARE_FORMATTER(knowSHACL::Path)
58{
59 if(p.isValid())
60 {
61 if(p.next())
62 {
63 return format_to(ctx.out(), "{} {} {}", p.type(), p.predicate(), *p.next());
64 } else {
65 return format_to(ctx.out(), "{} {}", p.type(), p.predicate());
66 }
67 } else {
68 return format_to(ctx.out(), "invalid path");
69 }
70}
Definition UriList.h:9
Definition Uri.h:14
Definition Path.h:15
bool isValid() const
Definition Path.cpp:25
bool operator==(const Path &_rhs) const
Definition Path.cpp:69
Definition ValidationResults.h:8
Definition Validator.h:19
Definition DefinitionParser_p.h:6
Definition Path_p.h:6