| Line | Branch | Exec | Source |
|---|---|---|---|
| 1 | // | ||
| 2 | // Copyright (c) 2023 Alan de Freitas (alandefreitas@gmail.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 | #include "../matches.hpp" | ||
| 11 | |||
| 12 | namespace boost { | ||
| 13 | namespace urls { | ||
| 14 | |||
| 15 | auto | ||
| 16 | 196 | matches_base:: | |
| 17 | at( size_type pos ) const | ||
| 18 | -> const_reference | ||
| 19 | { | ||
| 20 |
2/2✓ Branch 1 taken 120 times.
✓ Branch 2 taken 76 times.
|
196 | if (pos < size()) |
| 21 | { | ||
| 22 | 120 | return matches()[pos]; | |
| 23 | } | ||
| 24 | 76 | boost::throw_exception( | |
| 25 | 152 | std::out_of_range("")); | |
| 26 | } | ||
| 27 | |||
| 28 | auto | ||
| 29 | 120 | matches_base:: | |
| 30 | operator[]( size_type pos ) const | ||
| 31 | -> const_reference | ||
| 32 | { | ||
| 33 |
1/2✗ Branch 1 not taken.
✓ Branch 2 taken 120 times.
|
120 | BOOST_ASSERT(pos < size()); |
| 34 | 120 | return matches()[pos]; | |
| 35 | } | ||
| 36 | |||
| 37 | auto | ||
| 38 | 312 | matches_base:: | |
| 39 | at( core::string_view id ) const | ||
| 40 | -> const_reference | ||
| 41 | { | ||
| 42 |
2/2✓ Branch 1 taken 488 times.
✓ Branch 2 taken 76 times.
|
564 | for (std::size_t i = 0; i < size(); ++i) |
| 43 | { | ||
| 44 |
2/2✓ Branch 2 taken 236 times.
✓ Branch 3 taken 252 times.
|
488 | if (ids()[i] == id) |
| 45 | 236 | return matches()[i]; | |
| 46 | } | ||
| 47 | 76 | boost::throw_exception( | |
| 48 | 152 | std::out_of_range("")); | |
| 49 | } | ||
| 50 | |||
| 51 | auto | ||
| 52 | 118 | matches_base:: | |
| 53 | operator[]( core::string_view id ) const | ||
| 54 | -> const_reference | ||
| 55 | { | ||
| 56 | 118 | return at(id); | |
| 57 | } | ||
| 58 | |||
| 59 | auto | ||
| 60 | 194 | matches_base:: | |
| 61 | find( core::string_view id ) const | ||
| 62 | -> const_iterator | ||
| 63 | { | ||
| 64 |
2/2✓ Branch 1 taken 304 times.
✓ Branch 2 taken 76 times.
|
380 | for (std::size_t i = 0; i < size(); ++i) |
| 65 | { | ||
| 66 |
2/2✓ Branch 2 taken 118 times.
✓ Branch 3 taken 186 times.
|
304 | if (ids()[i] == id) |
| 67 | 118 | return matches() + i; | |
| 68 | } | ||
| 69 | 76 | return matches() + size(); | |
| 70 | } | ||
| 71 | |||
| 72 | auto | ||
| 73 | 76 | matches_base:: | |
| 74 | begin() const | ||
| 75 | -> const_iterator | ||
| 76 | { | ||
| 77 | 76 | return &matches()[0]; | |
| 78 | } | ||
| 79 | |||
| 80 | auto | ||
| 81 | 270 | matches_base:: | |
| 82 | end() const | ||
| 83 | -> const_iterator | ||
| 84 | { | ||
| 85 | 270 | return &matches()[size()]; | |
| 86 | } | ||
| 87 | |||
| 88 | auto | ||
| 89 | 76 | matches_base:: | |
| 90 | empty() const noexcept | ||
| 91 | -> bool | ||
| 92 | { | ||
| 93 | 76 | return size() == 0; | |
| 94 | } | ||
| 95 | |||
| 96 | } // urls | ||
| 97 | } // boost | ||
| 98 | |||
| 99 |