@@ -45,6 +45,31 @@ namespace web {
45
45
uri_components () : m_path(_XPLATSTR(" /" )), m_port(-1 )
46
46
{}
47
47
48
+ uri_components (const uri_components &other) :
49
+ m_scheme (other.m_scheme),
50
+ m_host (other.m_host),
51
+ m_user_info (other.m_user_info),
52
+ m_path (other.m_path),
53
+ m_query (other.m_query),
54
+ m_fragment (other.m_fragment),
55
+ m_port (other.m_port)
56
+ {}
57
+
58
+ uri_components & operator =(const uri_components &other)
59
+ {
60
+ if (this != &other)
61
+ {
62
+ m_scheme = other.m_scheme ;
63
+ m_host = other.m_host ;
64
+ m_user_info = other.m_user_info ;
65
+ m_path = other.m_path ;
66
+ m_query = other.m_query ;
67
+ m_fragment = other.m_fragment ;
68
+ m_port = other.m_port ;
69
+ }
70
+ return *this ;
71
+ }
72
+
48
73
uri_components (uri_components &&other) _noexcept :
49
74
m_scheme (std::move(other.m_scheme)),
50
75
m_host (std::move(other.m_host)),
@@ -103,25 +128,25 @@ namespace web {
103
128
};
104
129
105
130
// / <summary>
106
- // / A flexible, protocol independent uri implementation.
131
+ // / A flexible, protocol independent URI implementation.
107
132
// /
108
- // / URI instances are immutable. Querying the various fields on an emtpy uri will return empty strings. Querying
109
- // / various diagnostic members on an empty uri will return false.
133
+ // / URI instances are immutable. Querying the various fields on an emtpy URI will return empty strings. Querying
134
+ // / various diagnostic members on an empty URI will return false.
110
135
// / </summary>
111
136
// / <remarks>
112
- // / This implementation accepts both uris ('http://msn.com/path') and uri relative-references
137
+ // / This implementation accepts both URIs ('http://msn.com/path') and URI relative-references
113
138
// / ('/path?query#frag').
114
139
// /
115
140
// / This implementation does not provide any scheme-specific handling -- an example of this
116
- // / would be the following: 'http://path1/path'. This is a valid uri , but it's not a valid
141
+ // / would be the following: 'http://path1/path'. This is a valid URI , but it's not a valid
117
142
// / http-uri -- that is, it's syntactically correct but does not conform to the requirements
118
143
// / of the http scheme (http requires a host).
119
144
// / We could provide this by allowing a pluggable 'scheme' policy-class, which would provide
120
- // / extra capability for validating and canonicalizing a uri according to scheme, and would
121
- // / introduce a layer of type-safety for uris of differing schemes, and thus differing semantics.
145
+ // / extra capability for validating and canonicalizing a URI according to scheme, and would
146
+ // / introduce a layer of type-safety for URIs of differing schemes, and thus differing semantics.
122
147
// /
123
- // / One issue with implementing a scheme-independent uri facility is that of comparing for equality.
124
- // / For instance, these uris are considered equal 'http://msn.com', 'http://msn.com:80'. That is --
148
+ // / One issue with implementing a scheme-independent URI facility is that of comparing for equality.
149
+ // / For instance, these URIs are considered equal 'http://msn.com', 'http://msn.com:80'. That is --
125
150
// / the 'default' port can be either omitted or explicit. Since we don't have a way to map a scheme
126
151
// / to it's default port, we don't have a way to know these are equal. This is just one of a class of
127
152
// / issues with regard to scheme-specific behavior.
@@ -190,9 +215,9 @@ namespace web {
190
215
_ASYNCRTIMP static std::map<utility::string_t , utility::string_t > __cdecl split_query (const utility::string_t &query);
191
216
192
217
// / <summary>
193
- // / Validates a string as a uri .
218
+ // / Validates a string as a URI .
194
219
// / </summary>
195
- // / <param name="uri_string">The uri string to be validated.</param>
220
+ // / <param name="uri_string">The URI string to be validated.</param>
196
221
// / <returns><c>true</c> if the given string represents a valid URI, <c>false</c> otherwise.</returns>
197
222
_ASYNCRTIMP static bool __cdecl validate (const utility::string_t &uri_string);
198
223
@@ -202,19 +227,40 @@ namespace web {
202
227
uri () { m_uri = _XPLATSTR (" /" );};
203
228
204
229
// / <summary>
205
- // / Creates a uri from the given encoded string. This will throw an exception if the string
206
- // / does not contain a valid uri . Use uri::validate if processing user-input.
230
+ // / Creates a URI from the given encoded string. This will throw an exception if the string
231
+ // / does not contain a valid URI . Use uri::validate if processing user-input.
207
232
// / </summary>
208
233
// / <param name="uri_string">A pointer to an encoded string to create the URI instance.</param>
209
234
_ASYNCRTIMP uri (const utility::char_t *uri_string);
210
235
211
236
// / <summary>
212
- // / Creates a uri from the given encoded string. This will throw an exception if the string
213
- // / does not contain a valid uri . Use uri::validate if processing user-input.
237
+ // / Creates a URI from the given encoded string. This will throw an exception if the string
238
+ // / does not contain a valid URI . Use uri::validate if processing user-input.
214
239
// / </summary>
215
- // / <param name="uri_string">An encoded uri string to create the URI instance.</param>
240
+ // / <param name="uri_string">An encoded URI string to create the URI instance.</param>
216
241
_ASYNCRTIMP uri (const utility::string_t &uri_string);
217
242
243
+ // / <summary>
244
+ // / Copy constructor.
245
+ // / </summary>
246
+ uri (const uri &other) :
247
+ m_uri (other.m_uri),
248
+ m_components (other.m_components)
249
+ {}
250
+
251
+ // / <summary>
252
+ // / Copy assignment operator.
253
+ // / </summary>
254
+ uri & operator =(const uri &other)
255
+ {
256
+ if (this != &other)
257
+ {
258
+ m_uri = other.m_uri ;
259
+ m_components = other.m_components ;
260
+ }
261
+ return *this ;
262
+ }
263
+
218
264
// / <summary>
219
265
// / Move constructor.
220
266
// / </summary>
@@ -287,11 +333,11 @@ namespace web {
287
333
// / <summary>
288
334
// / Gets the path, query, and fragment portion of this uri, which may be empty.
289
335
// / </summary>
290
- // / <returns>The new uri object with the path, query and fragment portion of this uri .</returns>
336
+ // / <returns>The new URI object with the path, query and fragment portion of this URI .</returns>
291
337
_ASYNCRTIMP uri resource () const ;
292
338
293
339
// / <summary>
294
- // / An empty uri specifies no components, and serves as a default value
340
+ // / An empty URI specifies no components, and serves as a default value
295
341
// / </summary>
296
342
bool is_empty () const
297
343
{
@@ -346,37 +392,37 @@ namespace web {
346
392
}
347
393
348
394
// / <summary>
349
- // / An "authority" uri is one with only a scheme, optional userinfo, hostname, and (optional) port.
395
+ // / An "authority" URI is one with only a scheme, optional userinfo, hostname, and (optional) port.
350
396
// / </summary>
351
- // / <returns><c>true</c> if this is an "authority" uri , <c>false</c> otherwise.</returns>
397
+ // / <returns><c>true</c> if this is an "authority" URI , <c>false</c> otherwise.</returns>
352
398
bool is_authority () const
353
399
{
354
400
return !is_empty () && is_path_empty () && query ().empty () && fragment ().empty ();
355
401
}
356
402
357
403
// / <summary>
358
- // / Returns whether the other uri has the same authority as this one
404
+ // / Returns whether the other URI has the same authority as this one
359
405
// / </summary>
360
- // / <param name="other">The uri to compare the authority with.</param>
361
- // / <returns><c>true</c> if both the uri 's have the same authority, <c>false</c> otherwise.</returns>
406
+ // / <param name="other">The URI to compare the authority with.</param>
407
+ // / <returns><c>true</c> if both the URI 's have the same authority, <c>false</c> otherwise.</returns>
362
408
bool has_same_authority (const uri &other) const
363
409
{
364
410
return !is_empty () && this ->authority () == other.authority ();
365
411
}
366
412
367
413
// / <summary>
368
- // / Returns whether the path portion of this uri is empty
414
+ // / Returns whether the path portion of this URI is empty
369
415
// / </summary>
370
- // / <returns><c>true</c> if the path portion of this uri is empty, <c>false</c> otherwise.</returns>
416
+ // / <returns><c>true</c> if the path portion of this URI is empty, <c>false</c> otherwise.</returns>
371
417
bool is_path_empty () const
372
418
{
373
419
return path ().empty () || path () == _XPLATSTR (" /" );
374
420
}
375
421
376
422
// / <summary>
377
- // / Returns the full (encoded) uri as a string.
423
+ // / Returns the full (encoded) URI as a string.
378
424
// / </summary>
379
- // / <returns>The full encoded uri string.</returns>
425
+ // / <returns>The full encoded URI string.</returns>
380
426
utility::string_t to_string () const
381
427
{
382
428
return m_uri;
0 commit comments