#include <json-schema.hpp>
|
| static std::string | escape (const std::string &) |
|
| void | update (const std::string &uri) |
| std::tuple< std::string, std::string, std::string, std::string, std::string > | as_tuple () const |
Definition at line 47 of file json-schema.hpp.
◆ json_uri()
Definition at line 68 of file json-schema.hpp.
69 {
71 }
void update(const std::string &uri)
◆ append()
Definition at line 103 of file json-schema.hpp.
104 {
106 return *this;
107
110 return u;
111 }
json_uri(const std::string &uri)
json::json_pointer pointer_
◆ as_tuple()
◆ authority()
◆ derive()
◆ escape()
Definition at line 137 of file json-uri.cpp.
138{
139 std::vector<std::pair<std::string, std::string>> chars = {
140 {"~", "~0"},
141 {"/", "~1"}};
142
143 std::string l = src;
144
145 for (const auto &c : chars) {
146 std::size_t pos = 0;
147 do {
148 pos = l.find(c.first, pos);
149 if (pos == std::string::npos)
150 break;
151 l.replace(pos, 1, c.second);
152 pos += c.second.size();
153 } while (1);
154 }
155
156 return l;
157}
◆ fragment()
◆ identifier()
◆ location()
Definition at line 102 of file json-uri.cpp.
103{
106
107 std::stringstream s;
108
111
114
115 return s.str();
116}
◆ path()
◆ pointer()
◆ scheme()
◆ to_string()
Definition at line 118 of file json-uri.cpp.
119{
120 std::stringstream s;
121
123
126 else
128
129 return s.str();
130}
std::string location() const
◆ update()
Definition at line 16 of file json-uri.cpp.
17{
19
20
21 auto pointer_separator = uri.find('#');
22 if (pointer_separator != std::string::npos) {
23 pointer = uri.substr(pointer_separator + 1);
24
25
26 std::size_t pos =
pointer.size() - 1;
27 do {
29 if (pos == std::string::npos)
30 break;
31
32 if (pos >=
pointer.size() - 2) {
33 pos--;
34 continue;
35 }
36
37 std::string hex =
pointer.substr(pos + 1, 2);
38 char ascii = static_cast<char>(std::strtoul(hex.c_str(), nullptr, 16));
39 pointer.replace(pos, 3, 1, ascii);
40
41 pos--;
42 } while (1);
43 }
44
45 auto location = uri.substr(0, pointer_separator);
46
48
49
52
53
57
58 } else {
59
60
61 std::size_t pos = 0;
62 auto proto =
location.find(
"://", pos);
63 if (proto != std::string::npos) {
64
66
68 pos = 3 + proto;
69
74 }
75 }
76
78
79
81 throw std::invalid_argument(
"Cannot add a path (" +
path +
") to an URN URI (" +
urn_ +
")");
82
85 else if (pos == 0) {
86 auto last_slash =
path_.rfind(
'/');
88 } else
90 }
91 }
92
95
98 else
100}
const std::string & authority() const
const std::string & path() const
const json::json_pointer & pointer() const
◆ url()
◆ operator<
Definition at line 115 of file json-schema.hpp.
116 {
118 }
std::tuple< std::string, std::string, std::string, std::string, std::string > as_tuple() const
◆ operator<<
| std::ostream & operator<< |
( |
std::ostream & | os, |
|
|
const json_uri & | u ) |
|
friend |
Definition at line 132 of file json-uri.cpp.
133{
135}
std::string to_string() const
◆ operator==
◆ authority_
◆ identifier_
◆ path_
◆ pointer_
◆ scheme_
◆ urn_
The documentation for this class was generated from the following files: