| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // | ||
| 2 | // Copyright (c) 2019 Vinnie Falco (vinnie.falco@gmail.com) | ||
| 3 | // Copyright (c) 2022 Alan de Freitas (alandefreitas@gmail.com) | ||
| 4 | // | ||
| 5 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | ||
| 6 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | ||
| 7 | // | ||
| 8 | // Official repository: https://github.com/boostorg/url | ||
| 9 | // | ||
| 10 | |||
| 11 | |||
| 12 | #include <boost/url/detail/config.hpp> | ||
| 13 | #include <boost/url/segments_encoded_base.hpp> | ||
| 14 | #include <boost/assert.hpp> | ||
| 15 | #include <ostream> | ||
| 16 | |||
| 17 | namespace boost { | ||
| 18 | namespace urls { | ||
| 19 | |||
| 20 | 1710 | segments_encoded_base:: | |
| 21 | iterator:: | ||
| 22 | iterator( | ||
| 23 | 1710 | detail::path_ref const& ref) noexcept | |
| 24 | 1710 | : it_(ref) | |
| 25 | { | ||
| 26 | 1710 | } | |
| 27 | |||
| 28 | 1417 | segments_encoded_base:: | |
| 29 | iterator:: | ||
| 30 | iterator( | ||
| 31 | detail::path_ref const& ref, | ||
| 32 | 1417 | int) noexcept | |
| 33 | 1417 | : it_(ref, 0) | |
| 34 | { | ||
| 35 | 1417 | } | |
| 36 | |||
| 37 | //------------------------------------------------ | ||
| 38 | // | ||
| 39 | // segments_encoded_base | ||
| 40 | // | ||
| 41 | //------------------------------------------------ | ||
| 42 | |||
| 43 | 1296 | segments_encoded_base:: | |
| 44 | segments_encoded_base( | ||
| 45 | 1296 | detail::path_ref const& ref) noexcept | |
| 46 | 1296 | : ref_(ref) | |
| 47 | { | ||
| 48 | 1296 | } | |
| 49 | |||
| 50 | //------------------------------------------------ | ||
| 51 | // | ||
| 52 | // Observers | ||
| 53 | // | ||
| 54 | //------------------------------------------------ | ||
| 55 | |||
| 56 | pct_string_view | ||
| 57 | 47 | segments_encoded_base:: | |
| 58 | buffer() const noexcept | ||
| 59 | { | ||
| 60 | 47 | return ref_.buffer(); | |
| 61 | } | ||
| 62 | |||
| 63 | bool | ||
| 64 | 373 | segments_encoded_base:: | |
| 65 | is_absolute() const noexcept | ||
| 66 | { | ||
| 67 | 373 | return ref_.buffer().starts_with('/'); | |
| 68 | } | ||
| 69 | |||
| 70 | bool | ||
| 71 | 582 | segments_encoded_base:: | |
| 72 | empty() const noexcept | ||
| 73 | { | ||
| 74 | 582 | return ref_.nseg() == 0; | |
| 75 | } | ||
| 76 | |||
| 77 | std::size_t | ||
| 78 | 413 | segments_encoded_base:: | |
| 79 | size() const noexcept | ||
| 80 | { | ||
| 81 | 413 | return ref_.nseg(); | |
| 82 | } | ||
| 83 | |||
| 84 | auto | ||
| 85 | 1710 | segments_encoded_base:: | |
| 86 | begin() const noexcept -> | ||
| 87 | iterator | ||
| 88 | { | ||
| 89 | 1710 | return iterator(ref_); | |
| 90 | } | ||
| 91 | |||
| 92 | auto | ||
| 93 | 1417 | segments_encoded_base:: | |
| 94 | end() const noexcept -> | ||
| 95 | iterator | ||
| 96 | { | ||
| 97 | 1417 | return iterator(ref_, 0); | |
| 98 | } | ||
| 99 | |||
| 100 | //------------------------------------------------ | ||
| 101 | |||
| 102 | std::ostream& | ||
| 103 | 15 | operator<<( | |
| 104 | std::ostream& os, | ||
| 105 | segments_encoded_base const& ps) | ||
| 106 | { | ||
| 107 |
1/2✓ Branch 2 taken 15 times.
✗ Branch 3 not taken.
|
15 | os << ps.buffer(); |
| 108 | 15 | return os; | |
| 109 | } | ||
| 110 | |||
| 111 | } // urls | ||
| 112 | } // boost | ||
| 113 | |||
| 114 |