8
8
#ifndef NETWORK_URI_INC
9
9
#define NETWORK_URI_INC
10
10
11
+ /* *
12
+ * \file
13
+ * \brief Contains the uri the class.
14
+ */
15
+
11
16
#include < iterator>
12
17
#include < algorithm>
13
18
#include < functional>
@@ -41,18 +46,53 @@ namespace network {
41
46
} // namespace detail
42
47
#endif // !defined(DOXYGEN_SHOULD_SKIP_THIS)
43
48
49
+ /* *
50
+ * \enum uri_comparison_level
51
+ * \brief Defines the steps on the URI comparison ladder.
52
+ */
44
53
enum class uri_comparison_level {
45
54
string_comparison,
46
55
syntax_based,
47
56
scheme_based,
48
57
};
49
58
59
+ /* *
60
+ * \ingroup uri
61
+ * \class uri_builder network/uri/uri_builder.hpp network/uri.hpp
62
+ * \brief A class that allows complex uri objects to be constructed.
63
+ * \sa uri
64
+ */
50
65
class uri_builder ;
51
66
52
67
/* *
53
68
* \ingroup uri
54
69
* \class uri network/uri/uri.hpp network/uri.hpp
55
- * \brief A class that parses a URI string into its component parts.
70
+ * \brief A class that parses a URI (Uniform Resource Identifier)
71
+ * into its component parts.
72
+ *
73
+ * This class conforms to a URI as defined by RFC 3986, RFC 3987 and
74
+ * RFC 2732, including scoped IDs. It provides member functions for
75
+ * normalizing, comparing and resolving URIs.
76
+ *
77
+ * A URI has the syntax:
78
+ *
79
+ * \code
80
+ * [scheme:][user_info@][host][:port][path][?query][#fragment]
81
+ * \endcode
82
+ *
83
+ * Example:
84
+ *
85
+ * \code
86
+ * network::uri instance("http://cpp-netlib.org/");
87
+ * assert(instance.is_absolute());
88
+ * assert(!instance.is_opaque());
89
+ * assert(instance.scheme());
90
+ * assert("http" == *instance.scheme());
91
+ * assert(instance.host());
92
+ * assert("cpp-netlib.org" == *instance.host());
93
+ * assert(instance.path());
94
+ * assert("/" == *instance.path());
95
+ * \endcode
56
96
*/
57
97
class NETWORK_URI_DECL uri {
58
98
@@ -198,33 +238,32 @@ namespace network {
198
238
* \brief Returns the URI scheme.
199
239
* \return The scheme, if it exists, or boost::none.
200
240
*/
201
- boost::optional<string_view> scheme () const NETWORK_URI_NOEXCEPT ;
241
+ boost::optional<string_view> scheme () const ;
202
242
203
243
/* *
204
244
* \brief Returns the URI user info.
205
245
* \return The user info, if it exists, or boost::none.
206
246
*/
207
- boost::optional<string_view> user_info () const NETWORK_URI_NOEXCEPT ;
247
+ boost::optional<string_view> user_info () const ;
208
248
209
249
/* *
210
250
* \brief Returns the URI host.
211
251
* \return The host, if it exists, or boost::none.
212
252
*/
213
- boost::optional<string_view> host () const NETWORK_URI_NOEXCEPT ;
253
+ boost::optional<string_view> host () const ;
214
254
215
255
/* *
216
256
* \brief Returns the URI port.
217
257
* \return The port, if it exists, or boost::none.
218
258
*/
219
- boost::optional<string_view> port () const NETWORK_URI_NOEXCEPT ;
259
+ boost::optional<string_view> port () const ;
220
260
221
261
/* *
222
262
* \brief Returns the URI port as an integer.
223
263
* \return The port, if it exists, or boost::none.
224
264
*/
225
265
template <typename IntT>
226
- boost::optional<IntT> port (typename std::is_integral<IntT>::type * =
227
- 0 ) const NETWORK_URI_NOEXCEPT {
266
+ boost::optional<IntT> port (typename std::is_integral<IntT>::type * = 0 ) const {
228
267
if (auto p = port ()) {
229
268
try {
230
269
return static_cast <IntT>(
@@ -241,25 +280,25 @@ namespace network {
241
280
* \brief Returns the URI path.
242
281
* \return The path, if it exists, or boost::none.
243
282
*/
244
- boost::optional<string_view> path () const NETWORK_URI_NOEXCEPT ;
283
+ boost::optional<string_view> path () const ;
245
284
246
285
/* *
247
286
* \brief Returns the URI query.
248
287
* \return The query, if it exists, or boost::none.
249
288
*/
250
- boost::optional<string_view> query () const NETWORK_URI_NOEXCEPT ;
289
+ boost::optional<string_view> query () const ;
251
290
252
291
/* *
253
292
* \brief Returns the URI fragment.
254
293
* \return The fragment, if it exists, or boost::none.
255
294
*/
256
- boost::optional<string_view> fragment () const NETWORK_URI_NOEXCEPT ;
295
+ boost::optional<string_view> fragment () const ;
257
296
258
297
/* *
259
298
* \brief Returns the URI authority.
260
299
* \return The authority, if it exists, or boost::none.
261
300
*/
262
- boost::optional<string_view> authority () const NETWORK_URI_NOEXCEPT ;
301
+ boost::optional<string_view> authority () const ;
263
302
264
303
#if !defined(_MSC_VER)
265
304
/* *
@@ -332,14 +371,14 @@ namespace network {
332
371
* \brief Checks if the uri is absolute, i.e. it has a scheme.
333
372
* \returns \c true if it is absolute, \c false if it is relative.
334
373
*/
335
- bool is_absolute () const NETWORK_URI_NOEXCEPT ;
374
+ bool is_absolute () const ;
336
375
337
376
/* *
338
377
* \brief Checks if the uri is opaque, i.e. if it doesn't have an
339
378
* authority.
340
379
* \returns \c true if it is opaque, \c false if it is hierarchical.
341
380
*/
342
- bool is_opaque () const NETWORK_URI_NOEXCEPT ;
381
+ bool is_opaque () const ;
343
382
344
383
/* *
345
384
* \brief Normalizes a uri object at a given level in the
@@ -357,7 +396,7 @@ namespace network {
357
396
* \returns A relative reference of this URI against the base.
358
397
* \throws std::bad_alloc
359
398
*/
360
- uri make_relative (const uri &other ) const ;
399
+ uri make_relative (const uri &base ) const ;
361
400
362
401
#if !defined(DOXYGEN_SHOULD_SKIP_THIS)
363
402
uri make_reference (const uri &base) const { return make_relative (base); }
@@ -508,39 +547,81 @@ namespace network {
508
547
detail::uri_parts<string_type::iterator> uri_parts_;
509
548
};
510
549
511
- template < class Source >
512
- inline uri make_uri ( const Source &source,
513
- std::error_code &ec) NETWORK_URI_NOEXCEPT {
514
- return uri (source, ec);
515
- }
516
-
550
+ /* *
551
+ * \brief \c uri factory function.
552
+ * \param first The first element in a string sequence.
553
+ * \param last The end + 1th element in a string sequence.
554
+ * \param ec Error code set if the sequence is not a valid URI.
555
+ */
517
556
template <class InputIter >
518
557
inline uri make_uri (InputIter first, InputIter last,
519
- std::error_code &ec) NETWORK_URI_NOEXCEPT {
558
+ std::error_code &ec) {
520
559
return uri (first, last, ec);
521
560
}
522
561
523
- void swap (uri &lhs, uri &rhs) NETWORK_URI_NOEXCEPT;
562
+ /* *
563
+ * \brief \c uri factory function.
564
+ * \param source A source string that is to be parsed as a URI.
565
+ * \param ec Error code set if the source is not a valid URI.
566
+ */
567
+ template <class Source >
568
+ inline uri make_uri (const Source &source,
569
+ std::error_code &ec) {
570
+ return uri (source, ec);
571
+ }
524
572
525
- bool operator ==(const uri &lhs, const uri &rhs);
573
+ /* *
574
+ * \brief Swaps one uri object with another.
575
+ */
576
+ void swap (uri &lhs, uri &rhs) NETWORK_URI_NOEXCEPT;
577
+
578
+ /* *
579
+ * \brief Equality operator for the \c uri.
580
+ */
581
+ bool operator ==(const uri &lhs, const uri &rhs) NETWORK_URI_NOEXCEPT;
526
582
527
- bool operator ==(const uri &lhs, const char *rhs);
583
+ /* *
584
+ * \brief Equality operator for the \c uri.
585
+ */
586
+ bool operator ==(const uri &lhs, const char *rhs) NETWORK_URI_NOEXCEPT;
528
587
529
- inline bool operator ==(const char *lhs, const uri &rhs) { return rhs == lhs; }
588
+ /* *
589
+ * \brief Equality operator for the \c uri.
590
+ */
591
+ inline bool operator ==(const char *lhs, const uri &rhs) NETWORK_URI_NOEXCEPT {
592
+ return rhs == lhs;
593
+ }
530
594
531
- inline bool operator !=(const uri &lhs, const uri &rhs) {
595
+ /* *
596
+ * \brief Inequality operator for the \c uri.
597
+ */
598
+ inline bool operator !=(const uri &lhs, const uri &rhs) NETWORK_URI_NOEXCEPT {
532
599
return !(lhs == rhs);
533
600
}
534
601
535
- bool operator <(const uri &lhs, const uri &rhs);
602
+ /* *
603
+ * \brief Less-than operator for the \c uri.
604
+ */
605
+ bool operator <(const uri &lhs, const uri &rhs) NETWORK_URI_NOEXCEPT ;
536
606
537
- inline bool operator >(const uri &lhs, const uri &rhs) { return rhs < lhs; }
607
+ /* *
608
+ * \brief Greater-than operator for the \c uri.
609
+ */
610
+ inline bool operator >(const uri &lhs, const uri &rhs) NETWORK_URI_NOEXCEPT {
611
+ return rhs < lhs;
612
+ }
538
613
539
- inline bool operator <=(const uri &lhs, const uri &rhs) {
614
+ /* *
615
+ * \brief Less-than-or-equal-to operator for the \c uri.
616
+ */
617
+ inline bool operator <=(const uri &lhs, const uri &rhs) NETWORK_URI_NOEXCEPT {
540
618
return !(rhs < lhs);
541
619
}
542
620
543
- inline bool operator >=(const uri &lhs, const uri &rhs) {
621
+ /* *
622
+ * \brief Greater-than-or-equal-to operator for the \c uri.
623
+ */
624
+ inline bool operator >=(const uri &lhs, const uri &rhs) NETWORK_URI_NOEXCEPT {
544
625
return !(lhs < rhs);
545
626
}
546
627
} // namespace network
0 commit comments