Nebula
Toggle main menu visibility
Loading...
Searching...
No Matches
urn.h
Go to the documentation of this file.
1
#pragma once
2
//------------------------------------------------------------------------------
14
#include "
core/types.h
"
15
#include "
util/string.h
"
16
#include "
util/dictionary.h
"
17
18
//------------------------------------------------------------------------------
19
namespace
IO
20
{
21
class
URN
22
{
23
public
:
25
URN
();
27
URN
(
const
Util::String
& s);
29
URN
(
const
char
* s);
31
URN
(
const
URN
& rhs);
33
void
operator=
(
const
URN
& rhs);
35
bool
operator==
(
const
URN
& rhs)
const
;
37
bool
operator!=
(
const
URN
& rhs)
const
;
38
40
void
Set
(
const
Util::String
& s);
42
Util::String
AsString
()
const
;
43
45
bool
IsEmpty
()
const
;
47
bool
IsValid
()
const
;
49
void
Clear
();
51
void
SetNamespace
(
const
Util::String
& s);
53
const
Util::String
&
GetNamespace
()
const
;
55
void
SetSpecific
(
const
Util::String
& s);
57
const
Util::String
&
GetSpecific
()
const
;
59
void
SetQuery
(
const
Util::String
& s);
61
const
Util::String
&
GetQuery
()
const
;
63
void
SetFragment
(
const
Util::String
& s);
65
const
Util::String
&
GetFragment
()
const
;
66
private
:
68
bool
Split
(
const
Util::String
& s);
70
Util::String
Build
()
const
;
71
72
bool
isEmpty
;
73
Util::String
nid
;
74
Util::String
nss
;
75
Util::String
query
;
76
Util::String
fragment
;
77
};
78
79
//------------------------------------------------------------------------------
82
inline
83
URN::URN
() :
84
isEmpty
(true)
85
{
86
// empty
87
}
88
89
//------------------------------------------------------------------------------
92
inline
93
URN::URN
(
const
Util::String
& s) :
94
isEmpty
(true)
95
{
96
bool
validUrn = this->
Split
(s);
97
n_assert2
(validUrn, s.
AsCharPtr
());
98
}
99
100
//------------------------------------------------------------------------------
103
inline
104
URN::URN
(
const
char
* s) :
105
isEmpty
(true)
106
{
107
bool
validUrn = this->
Split
(s);
108
n_assert2
(validUrn, s);
109
}
110
111
//------------------------------------------------------------------------------
114
inline
115
URN::URN
(
const
URN
& rhs) :
116
isEmpty
(rhs.
isEmpty
),
117
nid
(rhs.
nid
),
118
nss
(rhs.
nss
),
119
query
(rhs.
query
),
120
fragment
(rhs.
fragment
)
121
{
122
// empty
123
}
124
125
//------------------------------------------------------------------------------
128
inline
129
void
130
URN::operator=
(
const
URN
& rhs)
131
{
132
this->
isEmpty
= rhs.
isEmpty
;
133
this->
nid
= rhs.
nid
;
134
this->
nss
= rhs.
nss
;
135
this->
query
= rhs.
query
;
136
this->
fragment
= rhs.
fragment
;
137
}
138
139
//------------------------------------------------------------------------------
142
inline
143
bool
144
URN::operator==
(
const
URN
& rhs)
const
145
{
146
if
(this->
isEmpty
&& rhs.
isEmpty
)
147
{
148
return
true
;
149
}
150
return
((this->
nid
== rhs.
nid
) &&
151
(this->nss == rhs.
nss
) &&
152
(this->query == rhs.
query
) &&
153
(this->fragment == rhs.
fragment
));
154
}
155
156
//------------------------------------------------------------------------------
159
inline
160
bool
161
URN::operator!=
(
const
URN
& rhs)
const
162
{
163
return
!(*
this
== rhs);
164
}
165
166
//------------------------------------------------------------------------------
169
inline
170
bool
171
URN::IsEmpty
()
const
172
{
173
return
this->
isEmpty
;
174
}
175
176
//------------------------------------------------------------------------------
179
inline
180
bool
181
URN::IsValid
()
const
182
{
183
return
!this->
isEmpty
;
184
}
185
186
//------------------------------------------------------------------------------
189
inline
190
void
191
URN::Clear
()
192
{
193
this->
isEmpty
=
true
;
194
this->
nid
.Clear();
195
this->
nss
.Clear();
196
this->
query
.Clear();
197
this->
fragment
.Clear();
198
}
199
200
//------------------------------------------------------------------------------
203
inline
204
Util::String
205
URN::AsString
()
const
206
{
207
return
this->
Build
();
208
}
209
210
//------------------------------------------------------------------------------
213
inline
214
void
215
IO::URN::Set
(
const
Util::String
& s)
216
{
217
this->
Split
(s);
218
}
219
220
//------------------------------------------------------------------------------
223
inline
224
void
225
IO::URN::SetNamespace
(
const
Util::String
& s)
226
{
227
this->
isEmpty
=
false
;
228
this->
nid
= s;
229
}
230
231
//------------------------------------------------------------------------------
234
inline
235
const
Util::String
&
236
IO::URN::GetNamespace
()
const
237
{
238
return
this->
nid
;
239
}
240
241
//------------------------------------------------------------------------------
244
inline
245
void
246
IO::URN::SetSpecific
(
const
Util::String
& s)
247
{
248
this->
isEmpty
=
false
;
249
this->
nss
= s;
250
}
251
252
//------------------------------------------------------------------------------
255
inline
256
const
Util::String
&
257
IO::URN::GetSpecific
()
const
258
{
259
return
this->
nss
;
260
}
261
262
//------------------------------------------------------------------------------
265
inline
266
void
267
IO::URN::SetQuery
(
const
Util::String
& s)
268
{
269
this->
isEmpty
=
false
;
270
this->
query
= s;
271
}
272
273
//------------------------------------------------------------------------------
276
inline
277
const
Util::String
&
278
IO::URN::GetQuery
()
const
279
{
280
return
this->
query
;
281
}
282
283
//------------------------------------------------------------------------------
286
inline
287
void
288
IO::URN::SetFragment
(
const
Util::String
& s)
289
{
290
this->
isEmpty
=
false
;
291
this->
fragment
= s;
292
}
293
294
//------------------------------------------------------------------------------
297
inline
298
const
Util::String
&
299
IO::URN::GetFragment
()
const
300
{
301
return
this->
fragment
;
302
}
303
304
}
// namespace IO
305
//------------------------------------------------------------------------------
308
IO::URN
operator
""
_urn(
const
char
* c, std::size_t s);
309
310
//------------------------------------------------------------------------------
311
IO::URN
A URN (Uniform Resource Name) is a URI (Uniform Resource Identifier) that uses the "urn" scheme.
Definition
urn.h:22
IO::URN::IsEmpty
bool IsEmpty() const
return true if the URI is empty
Definition
urn.h:171
IO::URN::Set
void Set(const Util::String &s)
set complete URI string
Definition
urn.h:215
IO::URN::Split
bool Split(const Util::String &s)
split string into components
Definition
urn.cc:32
IO::URN::GetSpecific
const Util::String & GetSpecific() const
get Specific component (can be empty)
Definition
urn.h:257
IO::URN::SetSpecific
void SetSpecific(const Util::String &s)
set Specific component
Definition
urn.h:246
IO::URN::SetFragment
void SetFragment(const Util::String &s)
set fragment component
Definition
urn.h:288
IO::URN::query
Util::String query
Definition
urn.h:75
IO::URN::nss
Util::String nss
Definition
urn.h:74
IO::URN::SetQuery
void SetQuery(const Util::String &s)
set query component
Definition
urn.h:267
IO::URN::Build
Util::String Build() const
build string from components
Definition
urn.cc:106
IO::URN::nid
Util::String nid
Definition
urn.h:73
IO::URN::fragment
Util::String fragment
Definition
urn.h:76
IO::URN::Clear
void Clear()
clear the URI
Definition
urn.h:191
IO::URN::GetNamespace
const Util::String & GetNamespace() const
get Namespace component
Definition
urn.h:236
IO::URN::GetQuery
const Util::String & GetQuery() const
get query component (can be empty)
Definition
urn.h:278
IO::URN::IsValid
bool IsValid() const
return true if the URI is not empty
Definition
urn.h:181
IO::URN::GetFragment
const Util::String & GetFragment() const
get fragment component (can be empty)
Definition
urn.h:299
IO::URN::AsString
Util::String AsString() const
return as concatenated string
Definition
urn.h:205
IO::URN::SetNamespace
void SetNamespace(const Util::String &s)
set Namespace component
Definition
urn.h:225
IO::URN::operator!=
bool operator!=(const URN &rhs) const
inequality operator
Definition
urn.h:161
IO::URN::URN
URN()
default constructor
Definition
urn.h:83
IO::URN::operator=
void operator=(const URN &rhs)
assignmnent operator
Definition
urn.h:130
IO::URN::operator==
bool operator==(const URN &rhs) const
equality operator
Definition
urn.h:144
IO::URN::isEmpty
bool isEmpty
Definition
urn.h:72
n_assert2
#define n_assert2(exp, msg)
Definition
debug.h:51
dictionary.h
IO
Instances of wrapped stream classes.
Definition
multiplayerfeatureunit.cc:324
string.h
Util.String
Nebula's universal string class.
Definition
String.cs:8
Util.String::AsCharPtr
const char * AsCharPtr() const
return contents as character pointer
Definition
string.h:572
types.h
code
foundation
io
urn.h
Generated on
for Nebula. Dark theme by
Tilen Majerle
. All rights reserved.