Skip to content

Commit b02b1b5

Browse files
committed
More details docs
1 parent c444ffd commit b02b1b5

File tree

2 files changed

+80
-10
lines changed

2 files changed

+80
-10
lines changed

docs/api.rst

Lines changed: 79 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ API
33

44
.. class:: ctll::fixed_string
55

6-
*Some documentation*
6+
A compile-time fixed string.
77

88
Example: ::
99

@@ -15,21 +15,91 @@ API
1515

1616
.. class:: template<class Iterator, class... Captures> ctre::regex_results
1717

18-
.. function:: template<size_t Id> constexpr auto get()
19-
template<class Id> constexpr auto get()
18+
.. type:: char_type = typename std::iterator_traits<Iterator>::value_type
2019

21-
Returns the capture specified by ``Id``.
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+
//TODO I can't seem to get named captures to work
33+
m.get<2>(); //123
34+
}
2235

2336
.. function:: constexpr size_t size()
2437

2538
Returns the number of captures in this result object.
2639

27-
.. function:: template<class... Args> constexpr ctre::regex_results<deduced> match(Args&&... args)
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+
.. function:: constexpr auto operator*() const noexcept
57+
constexpr auto operator*() noexcept
58+
59+
TODO I can't tell what these are supposed to do.
60+
61+
.. struct:: template<size_t Id, typename Name = void> captured_content
62+
63+
.. struct:: template <typename Iterator> storage
2864

29-
*Some documentation*
65+
.. function:: constexpr auto begin() const noexcept
66+
constexpr auto end() const noexcept
3067

31-
.. function:: template<class... Args> constexpr ctre::regex_results<deduced> search(Args&&... args)
68+
Returns the begin or end iterator for the captured content.
3269

33-
*Some documentation*
70+
.. function:: constexpr operator bool() const noexcept
3471

35-
*More functions and types*
72+
Returns whether the match was successful.
73+
74+
.. function:: constexpr auto size() const noexcept
75+
76+
Returns the number of characters in the capture.
77+
78+
.. function:: constexpr operator std::basic_string_view<char_type>() const noexcept
79+
constexpr std::basic_string_view<char_type> to_view() const noexcept
80+
constexpr std::basic_string_view<char_type> view() const noexcept
81+
82+
Converts the capture to a string view.
83+
84+
.. function:: constexpr explicit operator std::basic_string<char_type>() const noexcept
85+
constexpr std::basic_string<char_type> to_string() const noexcept
86+
constexpr std::basic_string<char_type> str() const noexcept
87+
88+
Converts the capture to a string view.
89+
90+
.. function:: constexpr static size_t get_id() noexcept
91+
92+
Returns ``Id``
93+
94+
.. function:: template<auto & RE, class... Args> constexpr ctre::regex_results<deduced> match(Args&&... args)
95+
template<ctll::fixed_string RE, class... Args> constexpr ctre::regex_results<deduced> match(Args&&... args)
96+
97+
Matches ``RE`` against the whole input.
98+
``Args...`` must be either a string-like object with ``begin`` and ``end`` member functions, or a pair of forward iterators.
99+
100+
.. function:: template<auto & RE, class... Args> constexpr ctre::regex_results<deduced> search(Args&&... args)
101+
template<ctll::fixed_string RE, class... Args> constexpr ctre::regex_results<deduced> search(Args&&... args)
102+
103+
Searches for a match somewhere within the input.
104+
``Args...`` must be either a string-like object with ``begin`` and ``end`` member functions, or a pair of forward iterators.
105+

docs/regex_syntax.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,4 @@ The library supports most of the `PCRE <pcre.org>`_ syntax with a few exceptions
1818
- subroutines
1919
- unicode grapheme cluster (\\X)
2020

21-
*more detailed regex syntax information could go here*
21+
TODO more detailed regex information

0 commit comments

Comments
 (0)