crawlserv++  [under development]
Application for crawling and analyzing textual content of websites.
crawlservpp::Wrapper::PCREMatch Class Reference

RAII wrapper for Perl-compatible regular expression matches. More...

#include <PCREMatch.hpp>

Construction and Destruction

 PCREMatch (pcre2_match_data *setPtr) noexcept
 Constructor setting the underlying regular expression. More...
 
virtual ~PCREMatch ()
 Destructor clearing the underlying regular expression if necessary. More...
 

Getters

pcre2_match_data * get () noexcept
 Gets a pointer to the underlying regular expression match. More...
 
const pcre2_match_data * getc () const noexcept
 Gets a const pointer to the underlying regular expression match. More...
 
bool valid () const noexcept
 Checks whether the underlying regular expression match is valid. More...
 

Cleanup

void clear () noexcept
 Clears the underlying regular expression match if necessary. More...
 

Copy and Move

The class is not copyable, only moveable.

 PCREMatch (PCREMatch &)=delete
 Deleted copy constructor. More...
 
PCREMatchoperator= (PCREMatch &)=delete
 Deleted copy assignment operator. More...
 
 PCREMatch (PCREMatch &&other) noexcept
 Move constructor. More...
 
PCREMatchoperator= (PCREMatch &&other) noexcept
 Move assignment operator. More...
 

Detailed Description

RAII wrapper for Perl-compatible regular expression matches.

Sets the RegEx match on construction and clears it on destruction, avoiding memory leaks.

At the moment, this class is used exclusively by the Query::Regex class.

For more information about the PCRE library used, visit its website.

Note
The class does not own the underlying pointer, but takes care of its deletion via API call.

Constructor & Destructor Documentation

◆ PCREMatch() [1/3]

crawlservpp::Wrapper::PCREMatch::PCREMatch ( pcre2_match_data *  setPtr)
inlineexplicitnoexcept

Constructor setting the underlying regular expression.

Parameters
setPtrThe pointer to a regular expression match to be used or nullptr to create an invalid match.
Note
The underlying pointer will be cleared in-class via API call.

◆ ~PCREMatch()

crawlservpp::Wrapper::PCREMatch::~PCREMatch ( )
inlinevirtual

Destructor clearing the underlying regular expression if necessary.

References clear().

◆ PCREMatch() [2/3]

crawlservpp::Wrapper::PCREMatch::PCREMatch ( PCREMatch )
delete

Deleted copy constructor.

◆ PCREMatch() [3/3]

crawlservpp::Wrapper::PCREMatch::PCREMatch ( PCREMatch &&  other)
inlinenoexcept

Move constructor.

Moves the regular expression match from the specified location into this instance of the class.

Note
The other match will be invalidated by this move.
Parameters
otherThe regular expression match to move from.
See also
valid

Member Function Documentation

◆ clear()

void crawlservpp::Wrapper::PCREMatch::clear ( )
inlinenoexcept

Clears the underlying regular expression match if necessary.

Referenced by operator=(), and ~PCREMatch().

◆ get()

pcre2_match_data * crawlservpp::Wrapper::PCREMatch::get ( )
inlinenoexcept

Gets a pointer to the underlying regular expression match.

Returns
A pointer to the underlying regular expression match.

Referenced by crawlservpp::Query::RegEx::getAll(), crawlservpp::Query::RegEx::getBool(), and crawlservpp::Query::RegEx::getFirst().

◆ getc()

const pcre2_match_data * crawlservpp::Wrapper::PCREMatch::getc ( ) const
inlinenoexcept

Gets a const pointer to the underlying regular expression match.

Returns
A const pointer to the underlying regular expression match.

◆ operator=() [1/2]

PCREMatch& crawlservpp::Wrapper::PCREMatch::operator= ( PCREMatch )
delete

Deleted copy assignment operator.

◆ operator=() [2/2]

PCREMatch & crawlservpp::Wrapper::PCREMatch::operator= ( PCREMatch &&  other)
inlinenoexcept

Move assignment operator.

Moves the regular expression match from the specified location into this instance of the class.

Note
The other match will be invalidated by this move.
Nothing will be done if used on itself.
Parameters
otherThe regular expression match to move from.
Returns
A reference to the instance containing the regular expression match after moving (i.e. *this).
See also
valid

References clear().

◆ valid()

bool crawlservpp::Wrapper::PCREMatch::valid ( ) const
inlinenoexcept

Checks whether the underlying regular expression match is valid.

Returns
True, if the regular expression match is valid. False otherwise.

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