|
| 1 | +API |
| 2 | +=== |
| 3 | + |
| 4 | +.. class:: ctll::fixed_string |
| 5 | + |
| 6 | + A compile-time fixed string. |
| 7 | + |
| 8 | + Example: :: |
| 9 | + |
| 10 | + static constexpr auto pattern = ctll::fixed_string{ "h.*" }; |
| 11 | + |
| 12 | + constexpr auto match(std::string_view sv) noexcept { |
| 13 | + return ctre::match<pattern>(sv); |
| 14 | + } |
| 15 | + |
| 16 | +.. class:: template<class Iterator, class... Captures> ctre::regex_results |
| 17 | + |
| 18 | + .. type:: char_type = typename std::iterator_traits<Iterator>::value_type |
| 19 | + |
| 20 | + The character type used by the ``Iterator``. |
| 21 | + |
| 22 | + .. function:: template<size_t Id> constexpr captured_content<Id, void>::storage<Iterator> get() |
| 23 | + template<class Name> constexpr captured_content<deduced, Name>::storage<Iterator> get() |
| 24 | + template<ctll::fixed_string Name> constexpr captured_content<deduced, Name>::storage<Iterator> get() |
| 25 | + |
| 26 | + Returns the capture specified by ``Id`` or ``Name``. ID ``0`` is the full match, ID ``1`` is the first capture group, ID ``2`` is the second, etc. |
| 27 | + Named groups are specified using ``(?<name>)``. |
| 28 | + |
| 29 | + Example: :: |
| 30 | + |
| 31 | + if (auto m = ctre::match<"(?<chars>[a-z]+)([0-9]+)">("abc123")) { |
| 32 | + m.get<"chars">(); //abc |
| 33 | + m.get<2>(); //123 |
| 34 | + } |
| 35 | + |
| 36 | + .. function:: constexpr size_t size() |
| 37 | + |
| 38 | + Returns the number of captures in this result object. |
| 39 | + |
| 40 | + .. function:: constexpr operator bool() const noexcept |
| 41 | + |
| 42 | + Returns whether the match was successful. |
| 43 | + |
| 44 | + .. function:: constexpr operator std::basic_string_view<char_type>() const noexcept |
| 45 | + constexpr std::basic_string_view<char_type> to_view() const noexcept |
| 46 | + constexpr std::basic_string_view<char_type> view() const noexcept |
| 47 | + |
| 48 | + Converts the match to a string view. |
| 49 | + |
| 50 | + .. function:: constexpr explicit operator std::basic_string<char_type>() const noexcept |
| 51 | + constexpr std::basic_string<char_type> to_string() const noexcept |
| 52 | + constexpr std::basic_string<char_type> str() const noexcept |
| 53 | + |
| 54 | + Converts the match to a string view. |
| 55 | + |
| 56 | +.. class:: template<size_t Id, typename Name = void> captured_content |
| 57 | + |
| 58 | + .. class:: template <typename Iterator> storage |
| 59 | + |
| 60 | + .. function:: constexpr auto begin() const noexcept |
| 61 | + constexpr auto end() const noexcept |
| 62 | + |
| 63 | + Returns the begin or end iterator for the captured content. |
| 64 | + |
| 65 | + .. function:: constexpr operator bool() const noexcept |
| 66 | + |
| 67 | + Returns whether the match was successful. |
| 68 | + |
| 69 | + .. function:: constexpr auto size() const noexcept |
| 70 | + |
| 71 | + Returns the number of characters in the capture. |
| 72 | + |
| 73 | + .. function:: constexpr operator std::basic_string_view<char_type>() const noexcept |
| 74 | + constexpr std::basic_string_view<char_type> to_view() const noexcept |
| 75 | + constexpr std::basic_string_view<char_type> view() const noexcept |
| 76 | + |
| 77 | + Converts the capture to a string view. |
| 78 | + |
| 79 | + .. function:: constexpr explicit operator std::basic_string<char_type>() const noexcept |
| 80 | + constexpr std::basic_string<char_type> to_string() const noexcept |
| 81 | + constexpr std::basic_string<char_type> str() const noexcept |
| 82 | + |
| 83 | + Converts the capture to a string view. |
| 84 | + |
| 85 | + .. function:: constexpr static size_t get_id() noexcept |
| 86 | + |
| 87 | + Returns ``Id`` |
| 88 | + |
| 89 | +.. function:: template<auto & RE, class... Args> constexpr ctre::regex_results<deduced> match(Args&&... args) |
| 90 | + template<ctll::fixed_string RE, class... Args> constexpr ctre::regex_results<deduced> match(Args&&... args) |
| 91 | + |
| 92 | + Matches ``RE`` against the whole input. |
| 93 | + ``Args...`` must be either a string-like object with ``begin`` and ``end`` member functions, or a pair of forward iterators. |
| 94 | + |
| 95 | +.. function:: template<auto & RE, class... Args> constexpr ctre::regex_results<deduced> search(Args&&... args) |
| 96 | + template<ctll::fixed_string RE, class... Args> constexpr ctre::regex_results<deduced> search(Args&&... args) |
| 97 | + |
| 98 | + Searches for a match somewhere within the input. |
| 99 | + ``Args...`` must be either a string-like object with ``begin`` and ``end`` member functions, or a pair of forward iterators. |
| 100 | + |
0 commit comments