wex v23.10.0
Public Types | Public Member Functions | List of all members
wex::regex_part Class Reference

This class offers partial regular expression matching, as supported by the boost regex classes. More...

#include <wex/core/regex-part.h>

Public Types

enum  match_t {
  MATCH_NONE , MATCH_ERROR , MATCH_PART , MATCH_HISTORY ,
  MATCH_FULL
}
 The match types. More...
 

Public Member Functions

 regex_part (const std::string &regex, boost::regex::flag_type flags=boost::regex::ECMAScript)
 Constructor.
 
const std::string & error () const
 Returns the error (in case MATCH_ERROR).
 
match_t match (char c)
 Regular expression match using a single char at a time, possibly continuing a previous match.
 
match_t match_type () const
 Returns the match type.
 
const std::string & regex () const
 Returns the regex.
 
void reset ()
 Resets matching to start again.
 
const std::string & text () const
 Returns the current text (all chars that matched).
 

Detailed Description

This class offers partial regular expression matching, as supported by the boost regex classes.

For example a regex: *+ Settings *+ and incomplete text '* Set' would not match a normal std::regex, this class matches all *, * , * Set, * Settings *, where the first 3 would return a MATCH_PART, and the last a MATCH_FULL.

Member Enumeration Documentation

◆ match_t

The match types.

Enumerator
MATCH_NONE 

the current text does not match at all, even partly

MATCH_ERROR 

the regex part gives a regex error during parsing

MATCH_PART 

the current text matches part of regex part

MATCH_HISTORY 

the current text matches part of regex part, last char not

MATCH_FULL 

the current text matches all regex part

Constructor & Destructor Documentation

◆ regex_part()

wex::regex_part::regex_part ( const std::string &  regex,
boost::regex::flag_type  flags = boost::regex::ECMAScript 
)
inline

Constructor.

Parameters
regexthe regular expression string
flagsthe regex flags

Member Function Documentation

◆ match()

wex::regex_part::match_t wex::regex_part::match ( char  c)
inline

Regular expression match using a single char at a time, possibly continuing a previous match.

Returns the match_t:

  • MATCH_PART: The resulting text from this and all previous chars do match
  • MATCH_FULL: The text matches the complete regex
  • MATCH_NONE: There is no match
  • MATCH_ERROR: There is a regex error, available using error() Non ascii chars are ignored.