Represents the range of bytes matched by a single capture group. More...
#include <MatchRange.hpp>
Public Member Functions | |
constexpr | MatchRange () |
Construct a MatchRange representing no match. More... | |
constexpr | MatchRange (int s, int e) |
Construct a MatchRange from s to e . More... | |
constexpr | operator bool () const |
True iff the corresponding capture group participated in the match. More... | |
constexpr | operator Vec< int, 2 > () const |
Implicitly convert to sp::Vec<int, 2> . More... | |
constexpr int | size () const |
Get the number of bytes in the match. More... | |
constexpr MatchRange & | operator+= (int offset) |
Add an offset to the match range. More... | |
constexpr MatchRange & | operator-= (int offset) |
constexpr MatchRange | operator+ (int offset) const |
constexpr MatchRange | operator- (int offset) const |
constexpr bool | operator== (const MatchRange &other) const |
constexpr bool | operator!= (const MatchRange &other) const |
Public Attributes | |
uint32_t | start |
uint32_t | end |
Represents the range of bytes matched by a single capture group.
The "whole match" range is regarded as being the zeroth capture group.
Note: Can be printed to std::iostream
via <<
.
|
constexpr |
Construct a MatchRange
representing no match.
|
constexpr |
Construct a MatchRange
from s
to e
.
s | The first character in the range. |
e | The first character not in the range. |
|
constexpr |
True iff the corresponding capture group participated in the match.
|
constexpr |
Implicitly convert to sp::Vec<int, 2>
.
This allows MatchRange
to be passed directly to sp::StringView::substr()
to cut out matched portions of the string.
|
constexpr |
Add an offset to the match range.
This is useful if a MatchRange
is obtained for a substring, and it needs to be updated to be a MatchRange
that is for the whole string.
|
constexpr |
Get the number of bytes in the match.