Doxygen
Loading...
Searching...
No Matches
reg::SubMatch Class Reference

Object representing the match results of a capture range. More...

#include <src/regex.h>

Public Member Functions

 SubMatch (std::string_view str)
 Creates a match for a single capture range given a non-owning pointer to the string.
 
size_t position () const
 Returns the position in the string at which the match starts.
 
size_t length () const
 Returns the length of the matching part.
 
std::string str () const
 Returns the matching part as a string.
 

Private Member Functions

void setStart (size_t pos)
 
void setEnd (size_t pos)
 
void setMatch (size_t pos, size_t len)
 

Private Attributes

size_t m_pos = std::string::npos
 
size_t m_len = std::string::npos
 
std::string_view m_str
 

Friends

class Match
 

Detailed Description

Object representing the match results of a capture range.

Definition at line 118 of file regex.h.

Constructor & Destructor Documentation

◆ SubMatch()

reg::SubMatch::SubMatch ( std::string_view str)
inline

Creates a match for a single capture range given a non-owning pointer to the string.

Definition at line 122 of file regex.h.

122: m_str(str) {}
std::string_view m_str
Definition regex.h:140
std::string str() const
Returns the matching part as a string.
Definition regex.h:131

References m_str, and str().

Member Function Documentation

◆ length()

size_t reg::SubMatch::length ( ) const
inline

Returns the length of the matching part.

Definition at line 128 of file regex.h.

128{ return m_len; }
size_t m_len
Definition regex.h:139

References m_len.

◆ position()

size_t reg::SubMatch::position ( ) const
inline

Returns the position in the string at which the match starts.

Definition at line 125 of file regex.h.

125{ return m_pos; }
size_t m_pos
Definition regex.h:138

References m_pos.

◆ setEnd()

void reg::SubMatch::setEnd ( size_t pos)
inlineprivate

Definition at line 136 of file regex.h.

136{ m_len=pos-m_pos; }

References m_len, and m_pos.

◆ setMatch()

void reg::SubMatch::setMatch ( size_t pos,
size_t len )
inlineprivate

Definition at line 137 of file regex.h.

137{ m_pos=pos; m_len=len; }

References m_len, and m_pos.

Referenced by reg::Match::prefix(), and reg::Match::suffix().

◆ setStart()

void reg::SubMatch::setStart ( size_t pos)
inlineprivate

Definition at line 135 of file regex.h.

135{ m_pos=pos; }

References m_pos.

◆ str()

std::string reg::SubMatch::str ( ) const
inline

Returns the matching part as a string.

Definition at line 131 of file regex.h.

131{ return std::string{m_str.substr(m_pos,m_len)}; }

References m_len, m_pos, and m_str.

Referenced by SubMatch().

Friends And Related Symbol Documentation

◆ Match

friend class Match
friend

Definition at line 134 of file regex.h.

References Match.

Referenced by Match.

Member Data Documentation

◆ m_len

size_t reg::SubMatch::m_len = std::string::npos
private

Definition at line 139 of file regex.h.

Referenced by length(), setEnd(), setMatch(), and str().

◆ m_pos

size_t reg::SubMatch::m_pos = std::string::npos
private

Definition at line 138 of file regex.h.

Referenced by position(), setEnd(), setMatch(), setStart(), and str().

◆ m_str

std::string_view reg::SubMatch::m_str
private

Definition at line 140 of file regex.h.

Referenced by str(), and SubMatch().


The documentation for this class was generated from the following file: