ALib C++ Library
Library Version: 2412 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
RegexMatcher Class Reference

Description:

This utility class wraps boost::regex library and interfaces ALib Strings with it.

The availability of the class is dependent on compiler symbol ALIB_FEAT_BOOST_REGEX which has to be true, and in parallel either ALIB_CHARACTERS_WIDE is false or ALIB_CHARACTERS_NATIVE_WCHAR equals true.

Method Compile accepts the pattern string and compiles it to boost::regex. Subsequent invocations of Match will then use the compiled regular expression for testing a given string.

The syntax of the regular expressions is compatible to Perl Regular Expressions .

Note
This is a very basic wrapper that supports just the bare minimum of the features available in the original boost::regex library. I.e, the expression syntax is fixed to be Perl-compatible and no string replacement features or even match positioning are available.

Definition at line 38 of file regexmatcher.hpp.

#include <regexmatcher.hpp>

Public Method Index:

 RegexMatcher (const String &pattern=NULL_STRING)
 
ALIB_API ~RegexMatcher ()
 Destructor.
 
ALIB_API void Compile (const String &pattern)
 
ALIB_API bool Match (const String &haystack)
 

Protected Field Index:

void * boostRegex = nullptr
 

Field Details:

◆ boostRegex

void* boostRegex = nullptr
protected

This is the internal regex matcher. Yes, a nasty reinterpret_cast is performed in the compilation unit. This is for avoiding the inclusion of external headers with ALib headers at the expense of an otherwise unnecessary heap allocation.

Definition at line 44 of file regexmatcher.hpp.

Constructor(s) / Destructor Details:

◆ RegexMatcher()

RegexMatcher ( const String & pattern = NULL_STRING)
inline

Constructs a RegexMatcher to work on a given string. Passes the optional parameters to method Compile.

Parameters
patternThe string pattern to match. Defaults to NULL_STRING to allow parameterless construction, with later invocation of Compile.

Definition at line 55 of file regexmatcher.hpp.

Here is the call graph for this function:

◆ ~RegexMatcher()

Destructor.

Definition at line 28 of file regexmatcher.cpp.

Method Details:

◆ Compile()

void Compile ( const String & pattern)

Resets this object to use the given pattern.

Parameters
patternThe string pattern to match.

Definition at line 34 of file regexmatcher.cpp.

Here is the call graph for this function:

◆ Match()

bool Match ( const String & haystack)

Tests if given haystack matches the actual pattern. If Compile was not invoked or an empty pattern string was given, true is returned.

Parameters
haystackThe string to test.
Returns
true if given haystack matches the actual pattern, false otherwise.

Definition at line 48 of file regexmatcher.cpp.

Here is the call graph for this function:

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