| 1 | // |
| 2 | // Copyright (c) 2016-2019 Vinnie Falco (vinnie dot falco at gmail dot com) |
| 3 | // |
| 4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying |
| 5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) |
| 6 | // |
| 7 | // Official repository: https://github.com/boostorg/url |
| 8 | // |
| 9 | |
| 10 | #ifndef BOOST_URL_RFC_DETAIL_PORT_RULE_HPP |
| 11 | #define BOOST_URL_RFC_DETAIL_PORT_RULE_HPP |
| 12 | |
| 13 | #include "boost/url/detail/config.hpp" |
| 14 | #include "boost/url/error_types.hpp" |
| 15 | #include <boost/core/detail/string_view.hpp> |
| 16 | #include <cstdint> |
| 17 | |
| 18 | namespace boost { |
| 19 | namespace urls { |
| 20 | namespace detail { |
| 21 | |
| 22 | /** Rule for port |
| 23 | |
| 24 | @par BNF |
| 25 | @code |
| 26 | port = *DIGIT |
| 27 | @endcode |
| 28 | |
| 29 | @par Specification |
| 30 | @li <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.2" |
| 31 | >3.2.2. Host (rfc3986)</a> |
| 32 | |
| 33 | @see |
| 34 | @ref port_part_rule. |
| 35 | */ |
| 36 | struct port_rule |
| 37 | { |
| 38 | struct value_type |
| 39 | { |
| 40 | core::string_view str; |
| 41 | std::uint16_t number = 0; |
| 42 | bool has_number = false; |
| 43 | }; |
| 44 | |
| 45 | system::result<value_type> |
| 46 | parse( |
| 47 | char const*& it, |
| 48 | char const* end) const noexcept; |
| 49 | }; |
| 50 | |
| 51 | //------------------------------------------------ |
| 52 | |
| 53 | /** Rule for port-part |
| 54 | |
| 55 | @par BNF |
| 56 | @code |
| 57 | port-part = [ ":" port ] |
| 58 | |
| 59 | port = *DIGIT |
| 60 | @endcode |
| 61 | |
| 62 | @par Specification |
| 63 | @li <a href="https://datatracker.ietf.org/doc/html/rfc3986#section-3.2.2" |
| 64 | >3.2.2. Host (rfc3986)</a> |
| 65 | |
| 66 | @see |
| 67 | @ref port_rule. |
| 68 | */ |
| 69 | struct port_part_rule_t |
| 70 | { |
| 71 | struct value_type |
| 72 | { |
| 73 | bool has_port = false; |
| 74 | core::string_view port; |
| 75 | bool has_number = false; |
| 76 | std::uint16_t port_number = 0; |
| 77 | }; |
| 78 | |
| 79 | auto |
| 80 | parse( |
| 81 | char const*& it, |
| 82 | char const* end |
| 83 | ) const noexcept -> |
| 84 | system::result<value_type>; |
| 85 | }; |
| 86 | |
| 87 | constexpr port_part_rule_t port_part_rule{}; |
| 88 | |
| 89 | } // detail |
| 90 | } // urls |
| 91 | } // boost |
| 92 | |
| 93 | #endif |
| 94 | |