SpecRegex  0.5.0
A GPU-accelerated regex library
sp::regex::RegexMatch< ParsedRegex > Class Template Reference

Represents one match of an sp::regex::Regex with all its capture groups. More...

#include <RegexMatch.hpp>

Inheritance diagram for sp::regex::RegexMatch< ParsedRegex >:
[legend]

Public Member Functions

constexpr RegexMatch (const RegexMatch &)=default
 
constexpr RegexMatchoperator= (const RegexMatch &)=default
 
template<typename Name >
MatchRangegetGroup ()
 Access a capture group by name. More...
 
template<typename Name >
const MatchRangegetGroup () const
 
constexpr operator bool () const
 Truthy if a match was found for the whole regex. More...
 
constexpr RegexMatchoperator+= (int offset)
 Offset all non-enum ranges in this match by the given amount. More...
 
constexpr RegexMatch operator+ (int offset) const
 
constexpr RegexMatchoperator-= (int offset)
 
constexpr RegexMatch operator- (int offset) const
 
- Public Member Functions inherited from sp::Vec< MatchRange, ParsedRegex::NumGroups >
constexpr int size () const
 
constexpr Vec (E head, Es... tail)
 
constexpr Vec (const T(&arr)[InSize])
 
constexpr iterator begin ()
 
constexpr const_iterator begin () const
 
constexpr iterator end ()
 
constexpr const_iterator end () const
 
__host__ std::vector< T > toVector ()
 
constexpr auto toTuple ()
 
constexpr T & operator[] (int i)
 
constexpr const T & operator[] (int i) const
 
constexpr BareValueType read (int i) const
 
constexpr T & get ()
 
constexpr const T & get () const
 
constexpr bool operator== (const Vec< Q, OtherSize > &other) const
 
constexpr auto map (const Op &op=Op{}) const
 
constexpr Vec< T, Size > operator- () const
 
constexpr Vec< T, Size > & operator= (const Q &value)
 
constexpr void replace (T from, T to)
 
constexpr T reduce (Op op=Op{}) const
 
constexpr Vec< T, NewSize > slice (int start) const
 
constexpr void splice (int I, const Vec< T, InSize > &in)
 
constexpr sp::Vec< T, Size+Len > insert (const sp::Vec< T, Len > &newValues) const
 
constexpr auto insert (const T &newValue) const
 
constexpr sp::Vec< T, Size > reverse () const
 
constexpr auto erase () const
 
constexpr auto eraseLast () const
 
constexpr auto eraseFirst () const
 
 operator T () const
 

Additional Inherited Members

- Static Public Member Functions inherited from sp::Vec< MatchRange, ParsedRegex::NumGroups >
static __host__ Vec< T, Size > fromVector (const std::vector< T > &vector)
 
static constexpr Vec< T, Size > fromTuple (const std::tuple< Ts... > &tuple)
 
static constexpr Vec< IT, sizeof...(Ints)> fromIntegerSequence (sp::integer_sequence< IT, Ints... >)
 
static constexpr Vec< T, Size > copiesOf (const T &value)
 

Detailed Description

template<typename ParsedRegex>
class sp::regex::RegexMatch< ParsedRegex >

Represents one match of an sp::regex::Regex with all its capture groups.

RegexMatch inherits from sp::Vec, and each of its members is a MatchRange corresponding to a capture group, with the convention that group 0 represents the whole match. You may use all the usual sp::Vec operators to interact with it.

Template Parameters
ParsedRegex- sp::regex::Regex::Parsed - The type of the parsed Regex pattern, containing information including how many capture groups it has, whether it has anchored starts or ends, etc.

Member Function Documentation

◆ getGroup()

template<typename ParsedRegex >
template<typename Name >
MatchRange & sp::regex::RegexMatch< ParsedRegex >::getGroup ( )

Access a capture group by name.

This is not for accessing groups by number. That can be done using operator[].

Template Parameters
NameA static string giving the name of the group you want to access.

◆ operator bool()

template<typename ParsedRegex >
constexpr sp::regex::RegexMatch< ParsedRegex >::operator bool ( ) const
constexpr

Truthy if a match was found for the whole regex.

Submatches may or may not be truthy, depending on if capture group results were requested and, if so, which groups participated in the match.

◆ operator+=()

template<typename ParsedRegex >
constexpr RegexMatch & sp::regex::RegexMatch< ParsedRegex >::operator+= ( int  offset)
constexpr

Offset all non-enum ranges in this match by the given amount.