SpecRegex  0.5.0
A GPU-accelerated regex library
sp::regex::MatchRange Struct Reference

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 MatchRangeoperator+= (int offset)
 Add an offset to the match range. More...
 
constexpr MatchRangeoperator-= (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
 

Detailed Description

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 <<.

See also
sp::regex::Regex::Match

Constructor & Destructor Documentation

◆ MatchRange() [1/2]

constexpr sp::regex::MatchRange::MatchRange ( )
constexpr

Construct a MatchRange representing no match.

◆ MatchRange() [2/2]

constexpr sp::regex::MatchRange::MatchRange ( int  s,
int  e 
)
constexpr

Construct a MatchRange from s to e.

Parameters
sThe first character in the range.
eThe first character not in the range.

Member Function Documentation

◆ operator bool()

constexpr sp::regex::MatchRange::operator bool ( ) const
constexpr

True iff the corresponding capture group participated in the match.

◆ operator Vec< int, 2 >()

constexpr sp::regex::MatchRange::operator Vec< int, 2 > ( ) const
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.

◆ operator+=()

constexpr MatchRange & sp::regex::MatchRange::operator+= ( int  offset)
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.

◆ size()

constexpr int sp::regex::MatchRange::size ( ) const
constexpr

Get the number of bytes in the match.