![]() |
JPCRE2
10.32.01
C++ wrapper for PCRE2 library
|
Provides public constructors to create RegexMatch objects. More...
#include <jpcre2.hpp>
Public Member Functions | |
RegexMatch () | |
Default constructor. More... | |
RegexMatch (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... | |
RegexMatch (RegexMatch const &rm) | |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ... More... | |
virtual RegexMatch & | operator= (RegexMatch const &rm) |
Overloaded copy-assignment operator. More... | |
RegexMatch (RegexMatch &&rm) | |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ... More... | |
virtual RegexMatch & | operator= (RegexMatch &&rm) |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ... More... | |
virtual | ~RegexMatch () |
Destructor Frees all internal memories that were used. More... | |
virtual RegexMatch & | reset () |
Reset all class variables to its default (initial) state including memory. More... | |
virtual RegexMatch & | clear () |
Clear all class variables (may retain some memory for further use). More... | |
virtual RegexMatch & | resetErrors () |
reset match related errors to zero. 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 RegexMatch & | setRegexObject (Regex const *r) |
Set the associated regex object. More... | |
virtual RegexMatch & | setNumberedSubstringVector (VecNum *v) |
Set a pointer to the numbered substring vector. More... | |
virtual RegexMatch & | setNamedSubstringVector (VecNas *v) |
Set a pointer to the named substring vector. More... | |
virtual RegexMatch & | setNameToNumberMapVector (VecNtN *v) |
Set a pointer to the name to number map vector. More... | |
virtual RegexMatch & | setMatchStartOffsetVector (VecOff *v) |
Set the pointer to a vector to store the offsets where matches start in the subject. More... | |
virtual RegexMatch & | setMatchEndOffsetVector (VecOff *v) |
Set the pointer to a vector to store the offsets where matches end in the subject. More... | |
virtual RegexMatch & | setSubject (String const &s) |
Set the subject string for match. More... | |
virtual RegexMatch & | setSubject (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... | |
virtual RegexMatch & | setModifier (Modifier const &s) |
Set the modifier (resets all JPCRE2 and PCRE2 options) by calling RegexMatch::changeModifier(). More... | |
virtual RegexMatch & | setModifierTable (ModifierTable const *mdt) |
Set a custom modifier table to be used. More... | |
virtual RegexMatch & | setJpcre2Option (Uint x) |
Set JPCRE2 option for match (resets all) More... | |
virtual RegexMatch & | setPcre2Option (Uint x) |
Set PCRE2 option match (overwrite existing option) More... | |
virtual RegexMatch & | setFindAll (bool x) |
Set whether to perform global match. More... | |
virtual RegexMatch & | setFindAll () |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ... More... | |
virtual RegexMatch & | setStartOffset (PCRE2_SIZE offset) |
Set offset from where match starts. More... | |
virtual RegexMatch & | setMatchContext (MatchContext *match_context) |
Set the match context. More... | |
virtual MatchContext * | getMatchContext () |
Return pointer to the match context that was previously set with setMatchContext(). More... | |
virtual RegexMatch & | setMatchDataBlock (MatchData *madt) |
Set the match data block to be used. 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... | |
virtual RegexMatch & | changeModifier (Modifier const &mod, bool x) |
Parse modifier and add/remove equivalent PCRE2 and JPCRE2 options. More... | |
virtual RegexMatch & | changeJpcre2Option (Uint opt, bool x) |
Add or remove a JPCRE2 option. More... | |
virtual RegexMatch & | changePcre2Option (Uint opt, bool x) |
Add or remove a PCRE2 option. More... | |
virtual RegexMatch & | addModifier (Modifier const &mod) |
Parse modifier string and add equivalent PCRE2 and JPCRE2 options. More... | |
virtual RegexMatch & | addJpcre2Option (Uint x) |
Add option to existing JPCRE2 options for match. More... | |
virtual RegexMatch & | addPcre2Option (Uint x) |
Add option to existing PCRE2 options for match. More... | |
virtual SIZE_T | match (void) |
Perform match operation using info from class variables and return the match count and store the results in specified vectors. More... | |
Provides public constructors to create RegexMatch objects.
Every RegexMatch object should be associated with a Regex object. This class stores a pointer to its' associated Regex object, thus when the content of the associated Regex object is changed, there will be no need to set the pointer again.
Examples:
|
inline |
Default constructor.
|
inline |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ...
Creates a RegexMatch object associating a Regex object. Underlying data is not modified.
r | pointer to a Regex object |
|
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.
rm | Reference to RegexMatch object |
|
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.
rm | rvalue reference to a RegexMatch object |
|
inlinevirtual |
Destructor Frees all internal memories that were used.
|
inlinevirtual |
Add option to existing JPCRE2 options for match.
x | Option value |
Reimplemented in jpcre2::select< Char_T, Map >::MatchEvaluator.
Referenced by jpcre2::select< Char_T, Map >::MatchEvaluator::addJpcre2Option().
|
inlinevirtual |
Parse modifier string and add equivalent PCRE2 and JPCRE2 options.
This is just a wrapper of the original function RegexMatch::changeModifier()
mod | Modifier string. |
Reimplemented in jpcre2::select< Char_T, Map >::MatchEvaluator.
References jpcre2::select< Char_T, Map >::RegexMatch::changeModifier().
Referenced by jpcre2::select< Char_T, Map >::MatchEvaluator::addModifier().
|
inlinevirtual |
Add option to existing PCRE2 options for match.
x | Option value |
Reimplemented in jpcre2::select< Char_T, Map >::MatchEvaluator.
Referenced by jpcre2::select< Char_T, Map >::MatchEvaluator::addPcre2Option().
|
inlinevirtual |
Add or remove a JPCRE2 option.
opt | JPCRE2 option value |
x | Add the option if it's true, remove otherwise. |
Reimplemented in jpcre2::select< Char_T, Map >::MatchEvaluator.
Referenced by jpcre2::select< Char_T, Map >::MatchEvaluator::changeJpcre2Option().
|
inlinevirtual |
Parse modifier and add/remove equivalent PCRE2 and JPCRE2 options.
This function does not initialize or re-initialize options. If you want to set options from scratch, initialize them to 0 before calling this function. If invalid modifier is detected, then the error number for the RegexMatch object will be jpcre2::ERROR::INVALID_MODIFIER and error offset will be the modifier character. You can get the message with RegexMatch::getErrorMessage() function.
mod | Modifier string. |
x | Whether to add or remove option |
Reimplemented in jpcre2::select< Char_T, Map >::MatchEvaluator.
References jpcre2::ModifierTable::toMatchOption().
Referenced by jpcre2::select< Char_T, Map >::RegexMatch::addModifier(), jpcre2::select< Char_T, Map >::MatchEvaluator::changeModifier(), and jpcre2::select< Char_T, Map >::RegexMatch::setModifier().
|
inlinevirtual |
Add or remove a PCRE2 option.
opt | PCRE2 option value |
x | Add the option if it's true, remove otherwise. |
Reimplemented in jpcre2::select< Char_T, Map >::MatchEvaluator.
Referenced by jpcre2::select< Char_T, Map >::MatchEvaluator::changePcre2Option(), and jpcre2::select< Char_T, Map >::MatchEvaluator::match().
|
inlinevirtual |
Clear all class variables (may retain some memory for further use).
Data in the vectors will retain (as it's external) You will need to pass vector pointers again after calling this function to get match results.
Reimplemented in jpcre2::select< Char_T, Map >::MatchEvaluator.
References jpcre2::select< Char_T, Map >::RegexMatch::clear().
Referenced by jpcre2::select< Char_T, Map >::RegexMatch::clear(), jpcre2::select< Char_T, Map >::MatchEvaluator::clear(), and jpcre2::select< Char_T, Map >::RegexMatch::setSubject().
|
inlinevirtual |
Returns the last error message.
References jpcre2::select< Char_T, Map >::getErrorMessage().
|
inlinevirtual |
Returns the last error number.
|
inlinevirtual |
Returns the last error offset.
|
inlinevirtual |
Get JPCRE2 option.
|
inlinevirtual |
Return pointer to the match context that was previously set with setMatchContext().
Handling memory is the callers' responsibility.
|
inlinevirtual |
Get the pointer to the match data block that was set previously with setMatchData() Handling memory is the callers' responsibility.
|
inlinevirtual |
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.
|
inlinevirtual |
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.
|
inlinevirtual |
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.
References jpcre2::ModifierTable::fromMatchOption().
|
inlinevirtual |
Get the modifier table that is set,.
|
inlinevirtual |
Get pointer to named substring vector.
|
inlinevirtual |
Get pointer to name to number map vector.
|
inlinevirtual |
Get pointer to numbered substring vector.
|
inlinevirtual |
Get PCRE2 option.
|
inlinevirtual |
|
inlinevirtual |
Get offset from where match will start in the subject.
|
inlinevirtual |
|
inlinevirtual |
Get pointer to subject string.
Data can not be changed with this pointer.
|
virtual |
Perform match operation using info from class variables and return the match count and store the results in specified vectors.
Note: This function uses pcre2_match() function to do the match.
Reimplemented in jpcre2::select< Char_T, Map >::MatchEvaluator.
Referenced by jpcre2::select< Char_T, Map >::MatchEvaluator::match().
|
inlinevirtual |
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. 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.
rm | rvalue reference to a RegexMatch object |
|
inlinevirtual |
Overloaded copy-assignment operator.
rm | RegexMatch object |
|
inlinevirtual |
Reset all class variables to its default (initial) state including memory.
Data in the vectors will retain (as it's external) You will need to pass vector pointers again after calling this function to get match results.
Reimplemented in jpcre2::select< Char_T, Map >::MatchEvaluator.
Referenced by jpcre2::select< Char_T, Map >::MatchEvaluator::reset().
|
inlinevirtual |
reset match related errors to zero.
If you want to examine the error status of a function call in the method chain, add this function just before your target function so that the error is set to zero before that target function is called, and leave everything out after the target function so that there will be no additional errors from other function calls.
Reimplemented in jpcre2::select< Char_T, Map >::MatchEvaluator.
Referenced by jpcre2::select< Char_T, Map >::MatchEvaluator::resetErrors().
|
inlinevirtual |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ...
This function just calls RegexMatch::setFindAll(bool x) with true
as the parameter
Reimplemented in jpcre2::select< Char_T, Map >::MatchEvaluator.
Referenced by jpcre2::select< Char_T, Map >::MatchEvaluator::setFindAll().
|
inlinevirtual |
Set whether to perform global match.
x | True or False |
Reimplemented in jpcre2::select< Char_T, Map >::MatchEvaluator.
References jpcre2::FIND_ALL.
|
inlinevirtual |
Set JPCRE2 option for match (resets all)
x | Option value |
Reimplemented in jpcre2::select< Char_T, Map >::MatchEvaluator.
Referenced by jpcre2::select< Char_T, Map >::MatchEvaluator::setJpcre2Option().
|
inlinevirtual |
Set the match context.
You can create match context using the native PCRE2 API. The memory is not handled by RegexMatch object and not freed. User will be responsible for freeing the memory of the match context.
match_context | Pointer to the match context. |
Reimplemented in jpcre2::select< Char_T, Map >::MatchEvaluator.
Referenced by jpcre2::select< Char_T, Map >::MatchEvaluator::setMatchContext().
|
inlinevirtual |
Set the match data block to be used.
The memory is not handled by RegexMatch object and not freed. User will be responsible for freeing the memory of the match data block.
madt | Pointer to a match data block. |
Reimplemented in jpcre2::select< Char_T, Map >::MatchEvaluator.
Referenced by jpcre2::select< Char_T, Map >::MatchEvaluator::setMatchDataBlock().
|
inlinevirtual |
Set the pointer to a vector to store the offsets where matches end in the subject.
Null pointer unsets it.
v | Pointer to a VecOff vector (std::vector<size_t>) |
|
inlinevirtual |
Set the pointer to a vector to store the offsets where matches start in the subject.
Null pointer unsets it.
v | Pointer to a jpcre2::VecOff vector (std::vector<size_t>) |
|
inlinevirtual |
Set the modifier (resets all JPCRE2 and PCRE2 options) by calling RegexMatch::changeModifier().
Re-initializes the option bits for PCRE2 and JPCRE2 options, then parses the modifier to set their equivalent options.
s | Modifier string. |
Reimplemented in jpcre2::select< Char_T, Map >::MatchEvaluator.
References jpcre2::select< Char_T, Map >::RegexMatch::changeModifier().
Referenced by jpcre2::select< Char_T, Map >::MatchEvaluator::setModifier().
|
inlinevirtual |
Set a custom modifier table to be used.
mdt | pointer to ModifierTable object. |
Reimplemented in jpcre2::select< Char_T, Map >::MatchEvaluator.
Referenced by jpcre2::select< Char_T, Map >::MatchEvaluator::setModifierTable().
|
inlinevirtual |
Set a pointer to the named substring vector.
Null pointer unsets it.
This vector will be populated with named captured groups.
v | pointer to the named substring vector |
|
inlinevirtual |
Set a pointer to the name to number map vector.
Null pointer unsets it.
This vector will be populated with name to number map for captured groups.
v | pointer to the name to number map vector |
|
inlinevirtual |
Set a pointer to the numbered substring vector.
Null pointer unsets it.
This vector will be filled with numbered (indexed) captured groups.
v | pointer to the numbered substring vector |
|
inlinevirtual |
Set PCRE2 option match (overwrite existing option)
x | Option value |
Reimplemented in jpcre2::select< Char_T, Map >::MatchEvaluator.
Referenced by jpcre2::select< Char_T, Map >::MatchEvaluator::setPcre2Option().
|
inlinevirtual |
Set the associated regex object.
Null pointer unsets it. Underlying data is not modified.
r | Pointer to a Regex object. |
Reimplemented in jpcre2::select< Char_T, Map >::MatchEvaluator.
Referenced by jpcre2::select< Char_T, Map >::MatchEvaluator::setRegexObject().
|
inlinevirtual |
Set offset from where match starts.
When FIND_ALL is set, a global match would not be performed on all positions on the subject, rather it will be performed from the start offset and onwards.
offset | Start offset |
Reimplemented in jpcre2::select< Char_T, Map >::MatchEvaluator.
Referenced by jpcre2::select< Char_T, Map >::MatchEvaluator::setStartOffset().
|
inlinevirtual |
Set the subject string for match.
This makes a copy of the subject string.
s | Subject string |
Reimplemented in jpcre2::select< Char_T, Map >::MatchEvaluator.
Referenced by jpcre2::select< Char_T, Map >::MatchEvaluator::setSubject().
|
inlinevirtual |
This is an overloaded member function, provided for convenience. It differs from the above function only in what argument(s) it accepts. ...
Works with the original without modifying it. Null pointer unsets the subject.
s | Pointer to subject string |
Reimplemented in jpcre2::select< Char_T, Map >::MatchEvaluator.
References jpcre2::select< Char_T, Map >::RegexMatch::clear().