knowL: Knowledge Libraries
Loading...
Searching...
No Matches
Uri.h
1#ifndef _KNOW_CORE_URI_H_
2#define _KNOW_CORE_URI_H_
3
4#include <functional>
5
6#include <QVariant>
7#include <QSharedDataPointer>
8
9#include "Forward.h"
10
11namespace knowCore
12{
13 class Uri
14 {
15 public:
16 Uri();
17 Uri(const QUrl& _url);
18 Uri(const QString& _uri);
19 Uri(const Uri& _base, const QString& _uri);
20 Uri(const Uri& _rhs);
21 Uri& operator=(const Uri& _rhs);
22 ~Uri();
26 static Uri createUnique(const QStringList& _path = QStringList());
27
28 bool operator==(const Uri& _rhs) const;
29 bool operator==(const char* _rhs) const;
30 bool operator<(const Uri& _rhs) const;
31 bool operator!=(const Uri& _rhs) const { return !(*this == _rhs); }
32 bool operator!=(const char* _rhs) const { return !(*this == _rhs); }
33
34 operator QUrl() const;
35 operator QString() const;
36
37 bool isEmpty() const;
38 bool isAbsolute() const;
39 bool isUrn() const;
40 bool isUrl() const;
41
42 Uri resolved(const Uri& _url) const;
43 Uri resolved(const QString& _url) const;
44
45 static void registerLocalFileResolver(const QString& _scheme, const std::function<QString(const QUrl& _url)>& _resolver);
46 QString toLocalFile() const;
50 QString base() const;
51 private:
52 struct Private;
53 QSharedDataPointer<Private> d;
54 };
55 inline uint qHash(const Uri& key, uint seed = 0) { return qHash((QString)key, seed); }
56}
57
58inline knowCore::Uri operator "" _kCu(const char* _text, std::size_t)
59{
60 return knowCore::Uri(_text);
61}
62
63Q_DECLARE_METATYPE(knowCore::Uri)
64
65#include "Formatter.h"
66KNOWCORE_CORE_DECLARE_CAST_FORMATTER(knowCore::Uri, QString)
67
68
69#endif
Definition Uri.h:14
QString base() const
Definition Uri.cpp:152
static Uri createUnique(const QStringList &_path=QStringList())
Definition Uri.cpp:64
Definition Uri.cpp:12