JPCRE2  10.31.02
C++ wrapper for PCRE2 library
jpcre2::select< Char_T, Map >::MatchEvaluator Class Reference

This class inherits RegexMatch and provides a similar functionality. More...

#include <jpcre2.hpp>

Public Member Functions

 MatchEvaluator ()
 Default constructor. More...
 
 MatchEvaluator (Regex const *r)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ... More...
 
 MatchEvaluator (typename MatchEvaluatorCallback< void *, void *, void *>::Callback mef)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ... More...
 
 MatchEvaluator (typename MatchEvaluatorCallback< NumSub const &, void *, void *>::Callback mef)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ... More...
 
 MatchEvaluator (typename MatchEvaluatorCallback< NumSub const &, MapNas const &, void *>::Callback mef)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ... More...
 
 MatchEvaluator (typename MatchEvaluatorCallback< NumSub const &, void *, MapNtN const &>::Callback mef)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ... More...
 
 MatchEvaluator (typename MatchEvaluatorCallback< NumSub const &, MapNas const &, MapNtN const &>::Callback mef)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ... More...
 
 MatchEvaluator (typename MatchEvaluatorCallback< void *, MapNas const &, void *>::Callback mef)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ... More...
 
 MatchEvaluator (typename MatchEvaluatorCallback< void *, MapNas const &, MapNtN const &>::Callback mef)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ... More...
 
 MatchEvaluator (typename MatchEvaluatorCallback< void *, void *, MapNtN const &>::Callback mef)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ... More...
 
 MatchEvaluator (MatchEvaluator const &me)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ... More...
 
MatchEvaluatoroperator= (MatchEvaluator const &me)
 Overloaded copy-assignment operator. More...
 
 MatchEvaluator (MatchEvaluator &&me)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ... More...
 
MatchEvaluatoroperator= (MatchEvaluator &&me)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ... More...
 
MatchEvaluatorsetCallback (typename MatchEvaluatorCallback< void *, void *, void *>::Callback mef)
 Member function to set a callback function with no vector reference. More...
 
MatchEvaluatorsetCallback (typename MatchEvaluatorCallback< NumSub const &, void *, void *>::Callback mef)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ... More...
 
MatchEvaluatorsetCallback (typename MatchEvaluatorCallback< NumSub const &, MapNas const &, void *>::Callback mef)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ... More...
 
MatchEvaluatorsetCallback (typename MatchEvaluatorCallback< NumSub const &, void *, MapNtN const &>::Callback mef)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ... More...
 
MatchEvaluatorsetCallback (typename MatchEvaluatorCallback< NumSub const &, MapNas const &, MapNtN const &>::Callback mef)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ... More...
 
MatchEvaluatorsetCallback (typename MatchEvaluatorCallback< void *, MapNas const &, void *>::Callback mef)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ... More...
 
MatchEvaluatorsetCallback (typename MatchEvaluatorCallback< void *, MapNas const &, MapNtN const &>::Callback mef)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ... More...
 
MatchEvaluatorsetCallback (typename MatchEvaluatorCallback< void *, void *, MapNtN const &>::Callback mef)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ... More...
 
MatchEvaluatorclearMatchData ()
 Clear match data. More...
 
MatchEvaluatorresetMatchData ()
 Reset match data to initial state. More...
 
MatchEvaluatorreset ()
 Reset MatchEvaluator to initial state including memory. More...
 
MatchEvaluatorclear ()
 Clears MatchEvaluator. More...
 
MatchEvaluatorresetErrors ()
 Call RegexMatch::resetErrors(). More...
 
MatchEvaluatorsetRegexObject (Regex const *r)
 Call RegexMatch::setRegexObject(r). More...
 
MatchEvaluatorsetSubject (String const &s)
 Call RegexMatch::setSubject(String const &s). More...
 
MatchEvaluatorsetSubject (String const *s)
 This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. More...
 
MatchEvaluatorsetModifier (Modifier const &s)
 Call RegexMatch::setModifier(Modifier const& s). More...
 
MatchEvaluatorsetModifierTable (ModifierTable const *mdt)
 Call RegexMatch::setModifierTable(ModifierTable const * s). More...
 
MatchEvaluatorsetJpcre2Option (Uint x)
 Call RegexMatch::setJpcre2Option(Uint x). More...
 
MatchEvaluatorsetPcre2Option (Uint x)
 Call RegexMatch::setPcre2Option (Uint x). More...
 
MatchEvaluatorsetFindAll (bool x)
 Call RegexMatch::setFindAll(bool x). More...
 
MatchEvaluatorsetFindAll ()
 Call RegexMatch::setFindAll(). More...
 
MatchEvaluatorsetStartOffset (PCRE2_SIZE offset)
 Call RegexMatch::setStartOffset (PCRE2_SIZE offset). More...
 
MatchEvaluatorsetMatchContext (MatchContext *match_context)
 Call RegexMatch::setMatchContext(MatchContext *match_context). More...
 
MatchEvaluatorsetMatchDataBlock (MatchData *mdt)
 Call RegexMatch::setMatchDataBlock(MatchContext * mdt);. More...
 
MatchEvaluatorsetBufferSize (PCRE2_SIZE x)
 Set the buffer size that will be used by pcre2_substitute (replace()). More...
 
PCRE2_SIZE getBufferSize ()
 Get the initial buffer size that is being used by internal function pcre2_substitute. More...
 
MatchEvaluatorchangeModifier (Modifier const &mod, bool x)
 Call RegexMatch::changeModifier(Modifier const& mod, bool x). More...
 
MatchEvaluatorchangeJpcre2Option (Uint opt, bool x)
 Call RegexMatch::changeJpcre2Option(Uint opt, bool x). More...
 
MatchEvaluatorchangePcre2Option (Uint opt, bool x)
 Call RegexMatch::changePcre2Option(Uint opt, bool x). More...
 
MatchEvaluatoraddModifier (Modifier const &mod)
 Call RegexMatch::addModifier(Modifier const& mod). More...
 
MatchEvaluatoraddJpcre2Option (Uint x)
 Call RegexMatch::addJpcre2Option(Uint x). More...
 
MatchEvaluatoraddPcre2Option (Uint x)
 Call RegexMatch::addPcre2Option(Uint x). More...
 
SIZE_T match (void)
 Perform match and return the match count. More...
 
String nreplace (bool do_match=true, Uint jro=0, SIZE_T *counter=0)
 Perform regex replace with this match evaluator. More...
 
String replace (bool do_match=true, Uint ro=0, SIZE_T *counter=0)
 PCRE2 compatible replace function that uses this MatchEvaluator. More...
 
virtual int getErrorNumber () const
 Returns the last error number. More...
 
virtual int getErrorOffset () const
 Returns the last error offset. More...
 
virtual String getErrorMessage () const
 Returns the last error message. More...
 
virtual String getSubject () const
 Get subject string (by value). More...
 
virtual String const * getSubjectPointer () const
 Get pointer to subject string. More...
 
virtual std::string getModifier () const
 Calculate modifier string from PCRE2 and JPCRE2 options and return it. More...
 
virtual ModifierTable const * getModifierTable ()
 Get the modifier table that is set,. More...
 
virtual Uint getPcre2Option () const
 Get PCRE2 option. More...
 
virtual Uint getJpcre2Option () const
 Get JPCRE2 option. More...
 
virtual PCRE2_SIZE getStartOffset () const
 Get offset from where match will start in the subject. More...
 
virtual VecOff const * getMatchStartOffsetVector () const
 Get pre-set match start offset vector pointer. More...
 
virtual VecOff const * getMatchEndOffsetVector () const
 Get pre-set match end offset vector pointer. More...
 
virtual Regex const * getRegexObject () const
 Get a pointer to the associated Regex object. More...
 
virtual VecNum const * getNumberedSubstringVector () const
 Get pointer to numbered substring vector. More...
 
virtual VecNas const * getNamedSubstringVector () const
 Get pointer to named substring vector. More...
 
virtual VecNtN const * getNameToNumberMapVector () const
 Get pointer to name to number map vector. More...
 
virtual MatchContext * getMatchContext ()
 Return pointer to the match context that was previously set with setMatchContext(). More...
 
virtual MatchData * getMatchDataBlock ()
 Get the pointer to the match data block that was set previously with setMatchData() Handling memory is the callers' responsibility. More...
 

Detailed Description

template<typename Char_T, template< typename... > class Map = std::map>
class jpcre2::select< Char_T, Map >::MatchEvaluator

This class inherits RegexMatch and provides a similar functionality.

All public member functions from RegexMatch class are publicly available except the following:

  • setNumberedSubstringVector
  • setNamedSubstringVector
  • setNameToNumberMapVector
  • setMatchStartOffsetVector
  • setMatchEndOffsetVector

The use of above functions is not allowed as the vectors are created according to the callback function you pass.

Each constructor of this class takes a callback function as argument (see MatchEvaluatorCallback).

It provides a MatchEvaluator::nreplace() function to perform replace operation using native JPCRE2 approach and MatchEvaluator::replace() function for PCRE2 compatible replace operation.

An instance of this class can also be passed with RegexReplace::nreplace() or RegexReplace::replace() function to perform replacement according to this match evaluator.

Match data is stored in vectors, and the vectors are populated according to the callback functions. Populated vector data is never deleted but they get overwritten. Vector data can be manually zeroed out by calling MatchEvaluator::clearMatchData(). If the capacities of those match vectors are desired to to be shrinked too instead of just clearing them, use MatchEvaluator::resetMatchData() instead.

Re-usability of Match Data

A match data populated with a callback function that takes only a jp::NumSub vector is not compatible with the data created according to callback function with a jp::MapNas vector. Because, for this later callback, jp::MapNas data is required but is not available (only jp::NumSub is available). In such cases, previous Match data can not be used to perform a new replacment operation with this second callback function.

To populate the match vectors, one must call the MatchEvaluator::match() or MatchEvaluator::nreplace() function, they will populate vectors with match data according to call back function.

Example:

jp::String callback5(NumSub const &m, void*, MapNtn const &n){
return m[0];
}
jp::String callback4(void*, void*, MapNtn const &n){
return std::to_string(n.at("name")); //position of group 'name'.
}
jp::String callback2(void*, MapNas const &m, void*){
return m.at('name'); //substring by name
}
me.setRegexObject(&re).setSubject("string").setCallback(callback5).nreplace();
//In above, nreplace() populates jp::NumSub and jp::MapNtn with match data.
me.setCallback(callback4).nreplace(false);
//the above uses previous match result (note the 'false') which is OK,
//because, callback4 requires jp::MapNtn which was made available in the previous operation.
//but the following is not OK: (assertion failure)
me.setCallback(callback2).nreplace(false);
//because, callback2 requires jp::MapNas data which is not available.
//now, this is OK:
me.setCallback(callback2).nreplace();
//because, it will recreate those match data including this one (jp::MapNas).

Replace options

MatchEvaluator can not take replace options. Replace options are taken directly by the replace functions: nreplace() and replace().

Using as a match object

As it's just a subclass of RegexMatch, it can do all the things that RegexMatch can do, with some restrictions:

  • matching options are modified to strip off bad options according to replacement (PCRE2_PARTIAL_HARD|PCRE2_PARTIAL_SOFT).
  • match depends on the callback function. Only those vectors will be populated that are implemented by the callback functions so far (multiple callback function will set multiple match data vectors.)
  • match vectors are internal to this class, you can not set them manually (without callback function). (you can get pointers to these vectors with getNumberedSubstringVector() and related functions).
See also
MatchEvaluatorCallback
RegexReplace::nreplace()

Constructor & Destructor Documentation

◆ MatchEvaluator() [1/12]

template<typename Char_T, template< typename... > class Map = std::map>
jpcre2::select< Char_T, Map >::MatchEvaluator::MatchEvaluator ( )
inlineexplicit

Default constructor.

Sets callback::erase as the callback function. Removes matched part/s from the subject string if the callback is not changed.

jp::Regex re("\s*string");
std::cout<<
.setSubject("I am a string");
//The above will delete ' string' from the subject
//thus the result will be 'I am a'

◆ MatchEvaluator() [2/12]

template<typename Char_T, template< typename... > class Map = std::map>
jpcre2::select< Char_T, Map >::MatchEvaluator::MatchEvaluator ( Regex const *  r)
inlineexplicit

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ...

Constructor taking a Regex object pointer. It sets the associated Regex object and initializes the MatchEvaluator object with callback::erase callback function. Underlying data is not modified.

Parameters
rconstant Regex pointer.

◆ MatchEvaluator() [3/12]

template<typename Char_T, template< typename... > class Map = std::map>
jpcre2::select< Char_T, Map >::MatchEvaluator::MatchEvaluator ( typename MatchEvaluatorCallback< void *, void *, void *>::Callback  mef)
inlineexplicit

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ...

Constructor taking a callback function. It calls a corresponding MatchEvaluator::setCallback() function to set the callback function.

Parameters
mefCallback function.

◆ MatchEvaluator() [4/12]

template<typename Char_T, template< typename... > class Map = std::map>
jpcre2::select< Char_T, Map >::MatchEvaluator::MatchEvaluator ( typename MatchEvaluatorCallback< NumSub const &, void *, void *>::Callback  mef)
inlineexplicit

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ...

It calls a corresponding MatchEvaluator::setCallback() function to set the callback function.

Parameters
mefCallback function.

◆ MatchEvaluator() [5/12]

template<typename Char_T, template< typename... > class Map = std::map>
jpcre2::select< Char_T, Map >::MatchEvaluator::MatchEvaluator ( typename MatchEvaluatorCallback< NumSub const &, MapNas const &, void *>::Callback  mef)
inlineexplicit

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ...

It calls a corresponding MatchEvaluator::setCallback() function to set the callback function.

Parameters
mefCallback function.

◆ MatchEvaluator() [6/12]

template<typename Char_T, template< typename... > class Map = std::map>
jpcre2::select< Char_T, Map >::MatchEvaluator::MatchEvaluator ( typename MatchEvaluatorCallback< NumSub const &, void *, MapNtN const &>::Callback  mef)
inlineexplicit

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ...

It calls a corresponding MatchEvaluator::setCallback() function to set the callback function.

Parameters
mefCallback function.

◆ MatchEvaluator() [7/12]

template<typename Char_T, template< typename... > class Map = std::map>
jpcre2::select< Char_T, Map >::MatchEvaluator::MatchEvaluator ( typename MatchEvaluatorCallback< NumSub const &, MapNas const &, MapNtN const &>::Callback  mef)
inlineexplicit

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ...

It calls a corresponding MatchEvaluator::setCallback() function to set the callback function.

Parameters
mefCallback function.

◆ MatchEvaluator() [8/12]

template<typename Char_T, template< typename... > class Map = std::map>
jpcre2::select< Char_T, Map >::MatchEvaluator::MatchEvaluator ( typename MatchEvaluatorCallback< void *, MapNas const &, void *>::Callback  mef)
inlineexplicit

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ...

It calls a corresponding MatchEvaluator::setCallback() function to set the callback function.

Parameters
mefCallback function.

◆ MatchEvaluator() [9/12]

template<typename Char_T, template< typename... > class Map = std::map>
jpcre2::select< Char_T, Map >::MatchEvaluator::MatchEvaluator ( typename MatchEvaluatorCallback< void *, MapNas const &, MapNtN const &>::Callback  mef)
inlineexplicit

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ...

It calls a corresponding MatchEvaluator::setCallback() function to set the callback function.

Parameters
mefCallback function.

◆ MatchEvaluator() [10/12]

template<typename Char_T, template< typename... > class Map = std::map>
jpcre2::select< Char_T, Map >::MatchEvaluator::MatchEvaluator ( typename MatchEvaluatorCallback< void *, void *, MapNtN const &>::Callback  mef)
inlineexplicit

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ...

It calls a corresponding MatchEvaluator::setCallback() function to set the callback function.

Parameters
mefCallback function.

◆ MatchEvaluator() [11/12]

template<typename Char_T, template< typename... > class Map = std::map>
jpcre2::select< Char_T, Map >::MatchEvaluator::MatchEvaluator ( MatchEvaluator const &  me)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ...

Copy constructor.

Parameters
meReference to MatchEvaluator object

◆ MatchEvaluator() [12/12]

template<typename Char_T, template< typename... > class Map = std::map>
jpcre2::select< Char_T, Map >::MatchEvaluator::MatchEvaluator ( MatchEvaluator &&  me)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ...

Move constructor. This constructor steals resources from the argument. It leaves the argument in a valid but indeterminate sate. The indeterminate state can be returned to normal by calling reset() on that object.

Parameters
mervalue reference to a MatchEvaluator object

Member Function Documentation

◆ addJpcre2Option()

template<typename Char_T, template< typename... > class Map = std::map>
MatchEvaluator& jpcre2::select< Char_T, Map >::MatchEvaluator::addJpcre2Option ( Uint  x)
inlinevirtual

Call RegexMatch::addJpcre2Option(Uint x).

Parameters
xJPCRE2 option.
Returns
A reference to the calling MatchEvaluator object.

Reimplemented from jpcre2::select< Char_T, Map >::RegexMatch.

◆ addModifier()

template<typename Char_T, template< typename... > class Map = std::map>
MatchEvaluator& jpcre2::select< Char_T, Map >::MatchEvaluator::addModifier ( Modifier const &  mod)
inlinevirtual

Call RegexMatch::addModifier(Modifier const& mod).

Parameters
modmodifier string.
Returns
A reference to the calling MatchEvaluator object.

Reimplemented from jpcre2::select< Char_T, Map >::RegexMatch.

◆ addPcre2Option()

template<typename Char_T, template< typename... > class Map = std::map>
MatchEvaluator& jpcre2::select< Char_T, Map >::MatchEvaluator::addPcre2Option ( Uint  x)
inlinevirtual

Call RegexMatch::addPcre2Option(Uint x).

Parameters
xPCRE2 option.
Returns
A reference to the calling MatchEvaluator object.

Reimplemented from jpcre2::select< Char_T, Map >::RegexMatch.

◆ changeJpcre2Option()

template<typename Char_T, template< typename... > class Map = std::map>
MatchEvaluator& jpcre2::select< Char_T, Map >::MatchEvaluator::changeJpcre2Option ( Uint  opt,
bool  x 
)
inlinevirtual

Call RegexMatch::changeJpcre2Option(Uint opt, bool x).

Parameters
optJPCRE2 option
xtrue (add) or false (remove).
Returns
A reference to the calling MatchEvaluator object.

Reimplemented from jpcre2::select< Char_T, Map >::RegexMatch.

◆ changeModifier()

template<typename Char_T, template< typename... > class Map = std::map>
MatchEvaluator& jpcre2::select< Char_T, Map >::MatchEvaluator::changeModifier ( Modifier const &  mod,
bool  x 
)
inlinevirtual

Call RegexMatch::changeModifier(Modifier const& mod, bool x).

Parameters
modmodifier string.
xtrue (add) or false (remove).
Returns
A reference to the calling MatchEvaluator object.

Reimplemented from jpcre2::select< Char_T, Map >::RegexMatch.

◆ changePcre2Option()

template<typename Char_T, template< typename... > class Map = std::map>
MatchEvaluator& jpcre2::select< Char_T, Map >::MatchEvaluator::changePcre2Option ( Uint  opt,
bool  x 
)
inlinevirtual

Call RegexMatch::changePcre2Option(Uint opt, bool x).

Parameters
optPCRE2 option.
xtrue (add) or false (remove).
Returns
A reference to the calling MatchEvaluator object.

Reimplemented from jpcre2::select< Char_T, Map >::RegexMatch.

◆ clear()

template<typename Char_T, template< typename... > class Map = std::map>
MatchEvaluator& jpcre2::select< Char_T, Map >::MatchEvaluator::clear ( )
inlinevirtual

Clears MatchEvaluator.

Returns everything to initial state (some memory may retain for further and faster use).

Returns
A reference to the calling MatchEvaluator object.

Reimplemented from jpcre2::select< Char_T, Map >::RegexMatch.

Referenced by jpcre2::select< Char_T, Map >::MatchEvaluator::clearMatchData().

+ Here is the caller graph for this function:

◆ clearMatchData()

template<typename Char_T, template< typename... > class Map = std::map>
MatchEvaluator& jpcre2::select< Char_T, Map >::MatchEvaluator::clearMatchData ( )
inline

Clear match data.

It clears all match data from all vectors (without shrinking). For shrinking the vectors, use resetMatchData() A call to match() or nreplace() will be required to produce match data again.

Returns
A reference to the calling MatchEvaluator object.

References jpcre2::select< Char_T, Map >::MatchEvaluator::clear().

+ Here is the call graph for this function:

◆ getBufferSize()

template<typename Char_T, template< typename... > class Map = std::map>
PCRE2_SIZE jpcre2::select< Char_T, Map >::MatchEvaluator::getBufferSize ( )
inline

Get the initial buffer size that is being used by internal function pcre2_substitute.

Returns
buffer_size

◆ getErrorMessage()

template<typename Char_T, template< typename... > class Map = std::map>
virtual String jpcre2::select< Char_T, Map >::RegexMatch::getErrorMessage ( ) const
inlinevirtualinherited

Returns the last error message.

Returns
Last error message

References jpcre2::select< Char_T, Map >::getErrorMessage().

+ Here is the call graph for this function:

◆ getErrorNumber()

template<typename Char_T, template< typename... > class Map = std::map>
virtual int jpcre2::select< Char_T, Map >::RegexMatch::getErrorNumber ( ) const
inlinevirtualinherited

Returns the last error number.

Returns
Last error number

◆ getErrorOffset()

template<typename Char_T, template< typename... > class Map = std::map>
virtual int jpcre2::select< Char_T, Map >::RegexMatch::getErrorOffset ( ) const
inlinevirtualinherited

Returns the last error offset.

Returns
Last error offset

◆ getJpcre2Option()

template<typename Char_T, template< typename... > class Map = std::map>
virtual Uint jpcre2::select< Char_T, Map >::RegexMatch::getJpcre2Option ( ) const
inlinevirtualinherited

Get JPCRE2 option.

Returns
JPCRE2 options for math operation
See also
Regex::getJpcre2Option()
RegexReplace::getJpcre2Option()

◆ getMatchContext()

template<typename Char_T, template< typename... > class Map = std::map>
virtual MatchContext* jpcre2::select< Char_T, Map >::RegexMatch::getMatchContext ( )
inlinevirtualinherited

Return pointer to the match context that was previously set with setMatchContext().

Handling memory is the callers' responsibility.

Returns
pointer to the match context (default: null).

◆ getMatchDataBlock()

template<typename Char_T, template< typename... > class Map = std::map>
virtual MatchData* jpcre2::select< Char_T, Map >::RegexMatch::getMatchDataBlock ( )
inlinevirtualinherited

Get the pointer to the match data block that was set previously with setMatchData() Handling memory is the callers' responsibility.

Returns
pointer to the match data (default: null).

◆ getMatchEndOffsetVector()

template<typename Char_T, template< typename... > class Map = std::map>
virtual VecOff const* jpcre2::select< Char_T, Map >::RegexMatch::getMatchEndOffsetVector ( ) const
inlinevirtualinherited

Get pre-set match end offset vector pointer.

The pointer must be set with RegexMatch::setMatchEndOffsetVector() beforehand for this to work i.e it is just a convenience method to get the pre-set vector pointer.

Returns
pointer to the const end offset vector

◆ getMatchStartOffsetVector()

template<typename Char_T, template< typename... > class Map = std::map>
virtual VecOff const* jpcre2::select< Char_T, Map >::RegexMatch::getMatchStartOffsetVector ( ) const
inlinevirtualinherited

Get pre-set match start offset vector pointer.

The pointer must be set with RegexMatch::setMatchStartOffsetVector() beforehand for this to work i.e it is just a convenience method to get the pre-set vector pointer.

Returns
pointer to the const match start offset vector

◆ getModifier()

template<typename Char_T, template< typename... > class Map = std::map>
virtual std::string jpcre2::select< Char_T, Map >::RegexMatch::getModifier ( ) const
inlinevirtualinherited

Calculate modifier string from PCRE2 and JPCRE2 options and return it.

Do remember that modifiers (or PCRE2 and JPCRE2 options) do not change or get initialized as long as you don't do that explicitly. Calling RegexMatch::setModifier() will re-set them.

Mixed or combined modifier.

Some modifier may include other modifiers i.e they have the same meaning of some modifiers combined together. For example, the 'n' modifier includes the 'u' modifier and together they are equivalent to PCRE2_UTF | PCRE2_UCP. When you set a modifier like this, both options get set, and when you remove the 'n' modifier (with RegexMatch::changeModifier()), both will get removed.

Returns
Calculated modifier string (std::string)
See also
Regex::getModifier()
RegexReplace::getModifier()

References jpcre2::ModifierTable::fromMatchOption().

+ Here is the call graph for this function:

◆ getModifierTable()

template<typename Char_T, template< typename... > class Map = std::map>
virtual ModifierTable const* jpcre2::select< Char_T, Map >::RegexMatch::getModifierTable ( )
inlinevirtualinherited

Get the modifier table that is set,.

Returns
pointer to constant ModifierTable.

◆ getNamedSubstringVector()

template<typename Char_T, template< typename... > class Map = std::map>
virtual VecNas const* jpcre2::select< Char_T, Map >::RegexMatch::getNamedSubstringVector ( ) const
inlinevirtualinherited

Get pointer to named substring vector.

Returns
Pointer to const named substring vector.

◆ getNameToNumberMapVector()

template<typename Char_T, template< typename... > class Map = std::map>
virtual VecNtN const* jpcre2::select< Char_T, Map >::RegexMatch::getNameToNumberMapVector ( ) const
inlinevirtualinherited

Get pointer to name to number map vector.

Returns
Pointer to const name to number map vector.

◆ getNumberedSubstringVector()

template<typename Char_T, template< typename... > class Map = std::map>
virtual VecNum const* jpcre2::select< Char_T, Map >::RegexMatch::getNumberedSubstringVector ( ) const
inlinevirtualinherited

Get pointer to numbered substring vector.

Returns
Pointer to const numbered substring vector.

◆ getPcre2Option()

template<typename Char_T, template< typename... > class Map = std::map>
virtual Uint jpcre2::select< Char_T, Map >::RegexMatch::getPcre2Option ( ) const
inlinevirtualinherited

Get PCRE2 option.

Returns
PCRE2 option for match operation
See also
Regex::getPcre2Option()
RegexReplace::getPcre2Option()

◆ getRegexObject()

template<typename Char_T, template< typename... > class Map = std::map>
virtual Regex const* jpcre2::select< Char_T, Map >::RegexMatch::getRegexObject ( ) const
inlinevirtualinherited

Get a pointer to the associated Regex object.

If no actual Regex object is associated, null is returned.

Returns
A pointer to the associated constant Regex object or null.

◆ getStartOffset()

template<typename Char_T, template< typename... > class Map = std::map>
virtual PCRE2_SIZE jpcre2::select< Char_T, Map >::RegexMatch::getStartOffset ( ) const
inlinevirtualinherited

Get offset from where match will start in the subject.

Returns
Start offset

◆ getSubject()

template<typename Char_T, template< typename... > class Map = std::map>
virtual String jpcre2::select< Char_T, Map >::RegexMatch::getSubject ( ) const
inlinevirtualinherited

Get subject string (by value).

Returns
subject string
See also
RegexReplace::getSubject()

◆ getSubjectPointer()

template<typename Char_T, template< typename... > class Map = std::map>
virtual String const* jpcre2::select< Char_T, Map >::RegexMatch::getSubjectPointer ( ) const
inlinevirtualinherited

Get pointer to subject string.

Data can not be changed with this pointer.

Returns
constant subject string pointer
See also
RegexReplace::getSubjectPointer()

◆ match()

template<typename Char_T, template< typename... > class Map = std::map>
SIZE_T jpcre2::select< Char_T, Map >::MatchEvaluator::match ( void  )
inlinevirtual

Perform match and return the match count.

This function strips off matching options (PCRE2_PARTIAL_HARD|PCRE2_PARTIAL_SOFT) that are considered bad options for replacement operation and then calls RegexMatch::match() to perform the match.

Returns
match count.

Reimplemented from jpcre2::select< Char_T, Map >::RegexMatch.

◆ nreplace()

template<typename Char_T , template< typename... > class Map>
jpcre2::select< Char_T, Map >::String jpcre2::select< Char_T, Map >::MatchEvaluator::nreplace ( bool  do_match = true,
Uint  jro = 0,
SIZE_T counter = 0 
)

Perform regex replace with this match evaluator.

This is a JPCRE2 native replace function (thus the name nreplace). It uses the MatchEvaluatorCallback function that was set with a constructor or MatchEvaluator::setCallback() function to generate the replacement strings on the fly. The string returned by the callback function will be treated as literal and will not go through any further processing.

This function performs a new match everytime it is called unless it is passed with a boolean false as the first argument. To use existing match data that was created by a previous MatchEvaluator::nreplace() or MatchEvaluator::match(), call this function with boolean false as the first argument.

Complexity

  1. Changes in replace related option takes effect without a re-match.
  2. Changes in match related option (e.g start offset) needs a re-match to take effect.
  3. To re-use existing match data, callback function must be compatible with the data, otherwise assertion error.
  4. If the associated Regex object or subject string changes, a new match must be performed, trying to use the existing match data in such cases is undefined behavior.
Parameters
do_matchPerform a new matching operation if true, otherwise use existing match data.
jroJPCRE2 replace options.
counterPointer to a counter to store the number of replacement done.
Returns
resultant string after replace.
See also
MatchEvaluator.
MatchEvaluatorCallback.

◆ operator=() [1/2]

template<typename Char_T, template< typename... > class Map = std::map>
MatchEvaluator& jpcre2::select< Char_T, Map >::MatchEvaluator::operator= ( MatchEvaluator const &  me)
inline

Overloaded copy-assignment operator.

Parameters
meMatchEvaluator object
Returns
A reference to the calling MatchEvaluator object.

◆ operator=() [2/2]

template<typename Char_T, template< typename... > class Map = std::map>
MatchEvaluator& jpcre2::select< Char_T, Map >::MatchEvaluator::operator= ( MatchEvaluator &&  me)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ...

Overloaded move-assignment operator. It steals resources from the argument. It leaves the argument in a valid but indeterminate sate. The indeterminate state can be returned to normal by calling reset() on that object.

Parameters
mervalue reference to a MatchEvaluator object
Returns
A reference to the calling MatchEvaluator object.
See also
MatchEvaluator(MatchEvaluator&& me)

◆ replace()

template<typename Char_T , template< typename... > class Map>
jpcre2::select< Char_T, Map >::String jpcre2::select< Char_T, Map >::MatchEvaluator::replace ( bool  do_match = true,
Uint  ro = 0,
SIZE_T counter = 0 
)

PCRE2 compatible replace function that uses this MatchEvaluator.

Performs regex replace with pcre2_substitute function by generating the replacement strings dynamically with MatchEvaluator callback. The string returned by callback function is processed by internal pcre2_substitute, thus allowing all options that are provided by PCRE2 itself.

This function performs a new match everytime it is called unless it is passed with a boolean false as the first argument.

Complexity

  1. Changes in replace related option takes effect without a re-match.
  2. Changes in match related option (e.g start offset) needs a re-match to take effect.
  3. To re-use existing match data, callback function must be compatible with the data, otherwise assertion error.
  4. If the associated Regex object or subject string changes, a new match must be performed, trying to use the existing match data in such cases is undefined behavior.
Parameters
do_matchperform a new match if true, otherwise use existing data.
roreplace related PCRE2 options.
counterPointer to a counter to store the number of replacement done.
Returns
resultant string after replacement.

◆ reset()

template<typename Char_T, template< typename... > class Map = std::map>
MatchEvaluator& jpcre2::select< Char_T, Map >::MatchEvaluator::reset ( )
inlinevirtual

Reset MatchEvaluator to initial state including memory.

Returns
A reference to the calling MatchEvaluator object.

Reimplemented from jpcre2::select< Char_T, Map >::RegexMatch.

◆ resetErrors()

template<typename Char_T, template< typename... > class Map = std::map>
MatchEvaluator& jpcre2::select< Char_T, Map >::MatchEvaluator::resetErrors ( )
inlinevirtual

Call RegexMatch::resetErrors().

Returns
A reference to the calling MatchEvaluator object.

Reimplemented from jpcre2::select< Char_T, Map >::RegexMatch.

◆ resetMatchData()

template<typename Char_T, template< typename... > class Map = std::map>
MatchEvaluator& jpcre2::select< Char_T, Map >::MatchEvaluator::resetMatchData ( )
inline

Reset match data to initial state.

It deletes all match data from all vectors shrinking their capacity. A call to match() or nreplace() will be required to produce match data again.

Returns
A reference to the calling MatchEvaluator object.

◆ setBufferSize()

template<typename Char_T, template< typename... > class Map = std::map>
MatchEvaluator& jpcre2::select< Char_T, Map >::MatchEvaluator::setBufferSize ( PCRE2_SIZE  x)
inline

Set the buffer size that will be used by pcre2_substitute (replace()).

If buffer size proves to be enough to fit the resultant string from each match (not the total resultant string), it will yield one less call to pcre2_substitute for each match.

Parameters
xbuffer size.
Returns
A reference to the calling MatchEvaluator object.

◆ setCallback() [1/8]

template<typename Char_T, template< typename... > class Map = std::map>
MatchEvaluator& jpcre2::select< Char_T, Map >::MatchEvaluator::setCallback ( typename MatchEvaluatorCallback< void *, void *, void *>::Callback  mef)
inline

Member function to set a callback function with no vector reference.

Callback function is always overwritten. The implemented vectors are set to be filled with match data. Other vectors that were set previously, are not unset and thus they will be filled with match data too when match() or nreplace() is called.

Parameters
mefCallback function.
Returns
A reference to the calling MatchEvaluator object.

◆ setCallback() [2/8]

template<typename Char_T, template< typename... > class Map = std::map>
MatchEvaluator& jpcre2::select< Char_T, Map >::MatchEvaluator::setCallback ( typename MatchEvaluatorCallback< NumSub const &, void *, void *>::Callback  mef)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ...

Sets a callback function with a jp::NumSub vector. You will be working with a reference to the constant vector.

Parameters
mefCallback function.
Returns
A reference to the calling MatchEvaluator object.

◆ setCallback() [3/8]

template<typename Char_T, template< typename... > class Map = std::map>
MatchEvaluator& jpcre2::select< Char_T, Map >::MatchEvaluator::setCallback ( typename MatchEvaluatorCallback< NumSub const &, MapNas const &, void *>::Callback  mef)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ...

Sets a callback function with a jp::NumSub and jp::MapNas. You will be working with references of the constant vectors. For maps, you won't be able to use [] operator with reference to constant map, use at() instead:

map_nas["word"]; //wrong
map_nas.at("word"); //ok

If you want to use [] operator with maps, make a copy:

jp::MapNas mn = map_nas;
mn["word"]; //ok
Parameters
mefCallback function.
Returns
A reference to the calling MatchEvaluator object.

◆ setCallback() [4/8]

template<typename Char_T, template< typename... > class Map = std::map>
MatchEvaluator& jpcre2::select< Char_T, Map >::MatchEvaluator::setCallback ( typename MatchEvaluatorCallback< NumSub const &, void *, MapNtN const &>::Callback  mef)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ...

Sets a callback function with a jp::NumSub and jp::MapNtN. You will be working with references of the constant vectors. For maps, you won't be able to use [] operator with reference to constant map, use at() instead:

map_ntn["word"]; //wrong
map_ntn.at("word"); //ok

If you want to use [] operator with maps, make a copy:

jp::MapNtN mn = map_ntn;
mn["word"]; //ok
Parameters
mefCallback function.
Returns
A reference to the calling MatchEvaluator object.

◆ setCallback() [5/8]

template<typename Char_T, template< typename... > class Map = std::map>
MatchEvaluator& jpcre2::select< Char_T, Map >::MatchEvaluator::setCallback ( typename MatchEvaluatorCallback< NumSub const &, MapNas const &, MapNtN const &>::Callback  mef)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ...

Sets a callback function with a jp::NumSub, jp::MapNas, jp::MapNtN. You will be working with references of the constant vectors. For maps, you won't be able to use [] operator with reference to constant map, use at() instead:

map_nas["word"]; //wrong
map_nas.at("word"); //ok

If you want to use [] operator with maps, make a copy:

jp::MapNas mn = map_nas;
mn["word"]; //ok
Parameters
mefCallback function.
Returns
A reference to the calling MatchEvaluator object.

◆ setCallback() [6/8]

template<typename Char_T, template< typename... > class Map = std::map>
MatchEvaluator& jpcre2::select< Char_T, Map >::MatchEvaluator::setCallback ( typename MatchEvaluatorCallback< void *, MapNas const &, void *>::Callback  mef)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ...

Sets a callback function with a jp::MapNas. You will be working with reference of the constant vector. For maps, you won't be able to use [] operator with reference to constant map, use at() instead:

map_nas["word"]; //wrong
map_nas.at("word"); //ok

If you want to use [] operator with maps, make a copy:

jp::MapNas mn = map_nas;
mn["word"]; //ok
Parameters
mefCallback function.
Returns
A reference to the calling MatchEvaluator object.

◆ setCallback() [7/8]

template<typename Char_T, template< typename... > class Map = std::map>
MatchEvaluator& jpcre2::select< Char_T, Map >::MatchEvaluator::setCallback ( typename MatchEvaluatorCallback< void *, MapNas const &, MapNtN const &>::Callback  mef)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ...

Sets a callback function with a jp::MapNas, jp::MapNtN. You will be working with reference of the constant vector. For maps, you won't be able to use [] operator with reference to constant map, use at() instead:

map_nas["word"]; //wrong
map_nas.at("word"); //ok

If you want to use [] operator with maps, make a copy:

jp::MapNas mn = map_nas;
mn["word"]; //ok
Parameters
mefCallback function.
Returns
A reference to the calling MatchEvaluator object.

◆ setCallback() [8/8]

template<typename Char_T, template< typename... > class Map = std::map>
MatchEvaluator& jpcre2::select< Char_T, Map >::MatchEvaluator::setCallback ( typename MatchEvaluatorCallback< void *, void *, MapNtN const &>::Callback  mef)
inline

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ...

Sets a callback function with a jp::MapNtN. You will be working with references of the constant vectors. For maps, you won't be able to use [] operator with reference to constant map, use at() instead:

map_ntn["word"]; //wrong
map_ntn.at("word"); //ok

If you want to use [] operator with maps, make a copy:

jp::MapNtN mn = map_ntn;
mn["word"]; //ok
Parameters
mefCallback function.
Returns
A reference to the calling MatchEvaluator object.

◆ setFindAll() [1/2]

template<typename Char_T, template< typename... > class Map = std::map>
MatchEvaluator& jpcre2::select< Char_T, Map >::MatchEvaluator::setFindAll ( bool  x)
inlinevirtual

Call RegexMatch::setFindAll(bool x).

Parameters
xtrue if global match, false otherwise.
Returns
A reference to the calling MatchEvaluator object.

Reimplemented from jpcre2::select< Char_T, Map >::RegexMatch.

◆ setFindAll() [2/2]

template<typename Char_T, template< typename... > class Map = std::map>
MatchEvaluator& jpcre2::select< Char_T, Map >::MatchEvaluator::setFindAll ( )
inlinevirtual

Call RegexMatch::setFindAll().

Returns
A reference to the calling MatchEvaluator object.

Reimplemented from jpcre2::select< Char_T, Map >::RegexMatch.

◆ setJpcre2Option()

template<typename Char_T, template< typename... > class Map = std::map>
MatchEvaluator& jpcre2::select< Char_T, Map >::MatchEvaluator::setJpcre2Option ( Uint  x)
inlinevirtual

Call RegexMatch::setJpcre2Option(Uint x).

Parameters
xJPCRE2 option value.
Returns
A reference to the calling MatchEvaluator object.

Reimplemented from jpcre2::select< Char_T, Map >::RegexMatch.

◆ setMatchContext()

template<typename Char_T, template< typename... > class Map = std::map>
MatchEvaluator& jpcre2::select< Char_T, Map >::MatchEvaluator::setMatchContext ( MatchContext *  match_context)
inlinevirtual

Call RegexMatch::setMatchContext(MatchContext *match_context).

Parameters
match_contextpointer to match context.
Returns
A reference to the calling MatchEvaluator object.

Reimplemented from jpcre2::select< Char_T, Map >::RegexMatch.

◆ setMatchDataBlock()

template<typename Char_T, template< typename... > class Map = std::map>
MatchEvaluator& jpcre2::select< Char_T, Map >::MatchEvaluator::setMatchDataBlock ( MatchData *  mdt)
inlinevirtual

Call RegexMatch::setMatchDataBlock(MatchContext * mdt);.

Parameters
mdtpointer to match data block
Returns
A reference to the calling MatchEvaluator object.

Reimplemented from jpcre2::select< Char_T, Map >::RegexMatch.

◆ setModifier()

template<typename Char_T, template< typename... > class Map = std::map>
MatchEvaluator& jpcre2::select< Char_T, Map >::MatchEvaluator::setModifier ( Modifier const &  s)
inlinevirtual

Call RegexMatch::setModifier(Modifier const& s).

Parameters
smodifier string.
Returns
A reference to the calling MatchEvaluator object.

Reimplemented from jpcre2::select< Char_T, Map >::RegexMatch.

◆ setModifierTable()

template<typename Char_T, template< typename... > class Map = std::map>
MatchEvaluator& jpcre2::select< Char_T, Map >::MatchEvaluator::setModifierTable ( ModifierTable const *  mdt)
inlinevirtual

Call RegexMatch::setModifierTable(ModifierTable const * s).

Parameters
mdtpointer to ModifierTable object.
Returns
A reference to the calling MatchEvaluator object.

Reimplemented from jpcre2::select< Char_T, Map >::RegexMatch.

◆ setPcre2Option()

template<typename Char_T, template< typename... > class Map = std::map>
MatchEvaluator& jpcre2::select< Char_T, Map >::MatchEvaluator::setPcre2Option ( Uint  x)
inlinevirtual

Call RegexMatch::setPcre2Option (Uint x).

Parameters
xPCRE2 option value.
Returns
A reference to the calling MatchEvaluator object.

Reimplemented from jpcre2::select< Char_T, Map >::RegexMatch.

◆ setRegexObject()

template<typename Char_T, template< typename... > class Map = std::map>
MatchEvaluator& jpcre2::select< Char_T, Map >::MatchEvaluator::setRegexObject ( Regex const *  r)
inlinevirtual

Call RegexMatch::setRegexObject(r).

Parameters
rconstant Regex object pointer
Returns
A reference to the calling MatchEvaluator object.

Reimplemented from jpcre2::select< Char_T, Map >::RegexMatch.

◆ setStartOffset()

template<typename Char_T, template< typename... > class Map = std::map>
MatchEvaluator& jpcre2::select< Char_T, Map >::MatchEvaluator::setStartOffset ( PCRE2_SIZE  offset)
inlinevirtual

Call RegexMatch::setStartOffset (PCRE2_SIZE offset).

Parameters
offsetmatch start offset in the subject.
Returns
A reference to the calling MatchEvaluator object.

Reimplemented from jpcre2::select< Char_T, Map >::RegexMatch.

◆ setSubject() [1/2]

template<typename Char_T, template< typename... > class Map = std::map>
MatchEvaluator& jpcre2::select< Char_T, Map >::MatchEvaluator::setSubject ( String const &  s)
inlinevirtual

Call RegexMatch::setSubject(String const &s).

Parameters
ssubject string.
Returns
A reference to the calling MatchEvaluator object.

Reimplemented from jpcre2::select< Char_T, Map >::RegexMatch.

◆ setSubject() [2/2]

template<typename Char_T, template< typename... > class Map = std::map>
MatchEvaluator& jpcre2::select< Char_T, Map >::MatchEvaluator::setSubject ( String const *  s)
inlinevirtual

This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts.

Parameters
sconstant subject string by pointer
Returns
A reference to the calling MatchEvaluator object.

Reimplemented from jpcre2::select< Char_T, Map >::RegexMatch.