WvStreams
WvRegex Class Reference

WvRegex – Unified support for regular expressions. More...

#include <wvregex.h>

Inheritance diagram for WvRegex:

Public Types

enum  CFlags {
  BASIC = 0 , EXTENDED = REG_EXTENDED , ICASE = REG_ICASE , NOSUB = REG_NOSUB ,
  NEWLINE = REG_NEWLINE , BASIC = 0 , EXTENDED = REG_EXTENDED , ICASE = REG_ICASE ,
  NOSUB = REG_NOSUB , NEWLINE = REG_NEWLINE
}
enum  EFlags { NOTBOL = REG_NOTBOL , NOTEOL = REG_NOTEOL , NOTBOL = REG_NOTBOL , NOTEOL = REG_NOTEOL }
enum  CFlags {
  BASIC = 0 , EXTENDED = REG_EXTENDED , ICASE = REG_ICASE , NOSUB = REG_NOSUB ,
  NEWLINE = REG_NEWLINE , BASIC = 0 , EXTENDED = REG_EXTENDED , ICASE = REG_ICASE ,
  NOSUB = REG_NOSUB , NEWLINE = REG_NEWLINE
}
enum  EFlags { NOTBOL = REG_NOTBOL , NOTEOL = REG_NOTEOL , NOTBOL = REG_NOTBOL , NOTEOL = REG_NOTEOL }

Public Member Functions

 WvRegex ()
 WvRegex (WvStringParm regex, int cflags=default_cflags)
bool set (WvStringParm regex, int cflags=default_cflags)
bool match (WvStringParm string, WVREGEX_REGS_DECL) const
bool match (WvStringParm string, int eflags, WVREGEX_REGS_DECL) const
bool continuable_match (WvStringParm string, int &match_start, int &match_end, WVREGEX_REGS_DECL) const
bool continuable_match (WvStringParm string, int eflags, int &match_start, int &match_end, WVREGEX_REGS_DECL) const
 WvRegex ()
 WvRegex (WvStringParm regex, int cflags=default_cflags)
bool set (WvStringParm regex, int cflags=default_cflags)
bool match (WvStringParm string, WVREGEX_REGS_DECL) const
bool match (WvStringParm string, int eflags, WVREGEX_REGS_DECL) const
bool continuable_match (WvStringParm string, int &match_start, int &match_end, WVREGEX_REGS_DECL) const
bool continuable_match (WvStringParm string, int eflags, int &match_start, int &match_end, WVREGEX_REGS_DECL) const
virtual bool isok () const
 By default, returns true if geterr() == 0.
virtual bool isok () const
 By default, returns true if geterr() == 0.
virtual int geterr () const
 If isok() is false, return the system error number corresponding to the error, -1 for a special error string (which you can obtain with errstr()) or 0 on end of file.
virtual int geterr () const
 If isok() is false, return the system error number corresponding to the error, -1 for a special error string (which you can obtain with errstr()) or 0 on end of file.
virtual WvString errstr () const
virtual WvString errstr () const
void seterr (WvStringParm specialerr)
void seterr (WVSTRING_FORMAT_DECL)
void seterr (const WvErrorBase &err)
void seterr_both (int _errnum, WvStringParm specialerr)
void seterr_both (int _errnum, WVSTRING_FORMAT_DECL)
void seterr_both (int _errnum, WvStringParm specialerr)
void seterr_both (int _errnum, WVSTRING_FORMAT_DECL)
void noerr ()
 Reset our error state - there's no error condition anymore.
void noerr ()
 Reset our error state - there's no error condition anymore.

Static Public Member Functions

static WvString strerror (int errnum)
 A replacement for the operating system ::strerror() function that can map more kinds of error strings (especially in win32).
static WvString strerror (int errnum)
 A replacement for the operating system ::strerror() function that can map more kinds of error strings (especially in win32).

Static Public Attributes

static const int default_cflags = WvRegex::EXTENDED
static const int default_eflags = 0
static WvString __wvre_null_reg

Protected Attributes

int errnum
WvString errstring

Detailed Description

WvRegex – Unified support for regular expressions.

Supports matching compiled regular expressions and capturing substrings in registers. !

Definition at line 47 of file debian/libwvstreams-dev/usr/include/wvstreams/wvregex.h.

Member Enumeration Documentation

◆ CFlags [1/2]

Flags that affect interpretation of the regex; used in Regex() and set()

Definition at line 112 of file debian/libwvstreams-dev/usr/include/wvstreams/wvregex.h.

◆ EFlags [1/2]

Flags that affect matching of regex. Used in match() and continuable_match()

Definition at line 130 of file debian/libwvstreams-dev/usr/include/wvstreams/wvregex.h.

◆ CFlags [2/2]

Flags that affect interpretation of the regex; used in Regex() and set()

Definition at line 112 of file include/wvregex.h.

◆ EFlags [2/2]

Flags that affect matching of regex. Used in match() and continuable_match()

Definition at line 130 of file include/wvregex.h.

Constructor & Destructor Documentation

◆ WvRegex() [1/4]

WvRegex::WvRegex ( )
inline

Construct an empty regex object. Matches will always fail until set() is called with a valid regex.

Definition at line 148 of file debian/libwvstreams-dev/usr/include/wvstreams/wvregex.h.

Referenced by WvGlob::WvGlob(), and WvGlob::WvGlob().

◆ WvRegex() [2/4]

WvRegex::WvRegex ( WvStringParm regex,
int cflags = default_cflags )
inline

Construct a regex object, compiling the given regex

Parameters
regexThe new regular expression to match
cflagsCFlags used to compile the regular expression; the defaults are case sensitive, extended RE.

Definition at line 156 of file debian/libwvstreams-dev/usr/include/wvstreams/wvregex.h.

References set().

◆ ~WvRegex()

WvRegex::~WvRegex ( )

Definition at line 42 of file wvregex.cc.

◆ WvRegex() [3/4]

WvRegex::WvRegex ( )
inline

Construct an empty regex object. Matches will always fail until set() is called with a valid regex.

Definition at line 148 of file include/wvregex.h.

◆ WvRegex() [4/4]

WvRegex::WvRegex ( WvStringParm regex,
int cflags = default_cflags )
inline

Construct a regex object, compiling the given regex

Parameters
regexThe new regular expression to match
cflagsCFlags used to compile the regular expression; the defaults are case sensitive, extended RE.

Definition at line 156 of file include/wvregex.h.

References set().

Member Function Documentation

◆ set() [1/2]

bool WvRegex::set ( WvStringParm regex,
int cflags = default_cflags )

Replace the current regex to match with a new one.

Parameters
regexThe new regular expression to match
cflagsCFlags used to compile the regular expression; the defaults are case sensitive, extended RE.

Definition at line 27 of file wvregex.cc.

Referenced by WvGlob::set(), and WvRegex().

◆ match() [1/4]

bool WvRegex::match ( WvStringParm string,
WVREGEX_REGS_DECL  ) const
inline

Match a given string against the compiled regular expression

Parameters
stringThe string to match
(remaining)WvString registers to capture substring matches as specified in the RE
extern WvString line;
WvString match;
if (re.match(line, match))
wvout->print("Matching substring is '%s'\n", match);
WvString is an implementation of a simple and efficient printable-string class.

Definition at line 183 of file debian/libwvstreams-dev/usr/include/wvstreams/wvregex.h.

◆ match() [2/4]

bool WvRegex::match ( WvStringParm string,
int eflags,
WVREGEX_REGS_DECL  ) const
inline

Match a given string against the compiled regular expression

Parameters
stringThe string to match
eflagsEFlags that affect matching
(remaining)WvString registers to capture substring matches as specified in the RE

Definition at line 197 of file debian/libwvstreams-dev/usr/include/wvstreams/wvregex.h.

◆ continuable_match() [1/4]

bool WvRegex::continuable_match ( WvStringParm string,
int & match_start,
int & match_end,
WVREGEX_REGS_DECL  ) const
inline

Match a given string against the compiled regular expression, capturing the start and end positions of the matching string.

Parameters
stringThe string to match
match_startIf the match succeeds, the starting index of the match in string
match_endIf the match succeeds, the index of the character in string following the last character of the match
(remaining)WvString registers to capture substring matches as specified in the RE
extern WvString line;
int start = 0;
WvString match;
int match_start, match_end;
while (re.continuable_match(&line[start],
match_start, match_end, match))
{
wvout->print("Matching substring is '%s'@[%s,%s)\n",
match, match_start, match_end);
start += match_end;
}

Definition at line 230 of file debian/libwvstreams-dev/usr/include/wvstreams/wvregex.h.

Referenced by strcoll_split().

◆ continuable_match() [2/4]

bool WvRegex::continuable_match ( WvStringParm string,
int eflags,
int & match_start,
int & match_end,
WVREGEX_REGS_DECL  ) const
inline

Match a given string against the compiled regular expression, capturing the start and end positions of the matching string.

Parameters
stringThe string to match
eflagsEFlags that affect matching
match_startIf the match succeeds, the starting index of the match in string
match_endIf the match succeeds, the index of the character in string following the last character of the match
(remaining)WvString registers to capture substring matches as specified in the RE

Definition at line 250 of file debian/libwvstreams-dev/usr/include/wvstreams/wvregex.h.

◆ set() [2/2]

bool WvRegex::set ( WvStringParm regex,
int cflags = default_cflags )

Replace the current regex to match with a new one.

Parameters
regexThe new regular expression to match
cflagsCFlags used to compile the regular expression; the defaults are case sensitive, extended RE.

◆ match() [3/4]

bool WvRegex::match ( WvStringParm string,
WVREGEX_REGS_DECL  ) const
inline

Match a given string against the compiled regular expression

Parameters
stringThe string to match
(remaining)WvString registers to capture substring matches as specified in the RE
extern WvString line;
WvString match;
if (re.match(line, match))
wvout->print("Matching substring is '%s'\n", match);

Definition at line 183 of file include/wvregex.h.

◆ match() [4/4]

bool WvRegex::match ( WvStringParm string,
int eflags,
WVREGEX_REGS_DECL  ) const
inline

Match a given string against the compiled regular expression

Parameters
stringThe string to match
eflagsEFlags that affect matching
(remaining)WvString registers to capture substring matches as specified in the RE

Definition at line 197 of file include/wvregex.h.

◆ continuable_match() [3/4]

bool WvRegex::continuable_match ( WvStringParm string,
int & match_start,
int & match_end,
WVREGEX_REGS_DECL  ) const
inline

Match a given string against the compiled regular expression, capturing the start and end positions of the matching string.

Parameters
stringThe string to match
match_startIf the match succeeds, the starting index of the match in string
match_endIf the match succeeds, the index of the character in string following the last character of the match
(remaining)WvString registers to capture substring matches as specified in the RE
extern WvString line;
int start = 0;
WvString match;
int match_start, match_end;
while (re.continuable_match(&line[start],
match_start, match_end, match))
{
wvout->print("Matching substring is '%s'@[%s,%s)\n",
match, match_start, match_end);
start += match_end;
}

Definition at line 230 of file include/wvregex.h.

◆ continuable_match() [4/4]

bool WvRegex::continuable_match ( WvStringParm string,
int eflags,
int & match_start,
int & match_end,
WVREGEX_REGS_DECL  ) const
inline

Match a given string against the compiled regular expression, capturing the start and end positions of the matching string.

Parameters
stringThe string to match
eflagsEFlags that affect matching
match_startIf the match succeeds, the starting index of the match in string
match_endIf the match succeeds, the index of the character in string following the last character of the match
(remaining)WvString registers to capture substring matches as specified in the RE

Definition at line 250 of file include/wvregex.h.

◆ isok() [1/2]

◆ isok() [2/2]

virtual bool WvErrorBase::isok ( ) const
inlinevirtualinherited

◆ geterr() [1/2]

virtual int WvErrorBase::geterr ( ) const
inlinevirtualinherited

If isok() is false, return the system error number corresponding to the error, -1 for a special error string (which you can obtain with errstr()) or 0 on end of file.

If isok() is true, returns an undefined number.

Reimplemented in WvDBusServer, WvDBusServer, WvStreamClone, and WvStreamClone.

Definition at line 48 of file debian/libwvstreams-dev/usr/include/wvstreams/wverror.h.

Referenced by UniIniGen::commit(), UniFileSystemGen::get(), WvDBusServer::geterr(), WvStreamClone::geterr(), UniConfDaemon::listen(), UniIniGen::refresh(), and WvStream::seterr().

◆ geterr() [2/2]

virtual int WvErrorBase::geterr ( ) const
inlinevirtualinherited

If isok() is false, return the system error number corresponding to the error, -1 for a special error string (which you can obtain with errstr()) or 0 on end of file.

If isok() is true, returns an undefined number.

Reimplemented in WvDBusServer, WvDBusServer, WvStreamClone, and WvStreamClone.

Definition at line 48 of file include/wverror.h.

◆ errstr()

WvString WvErrorBase::errstr ( ) const
virtualinherited

Definition at line 127 of file wverror.cc.

◆ strerror()

WvString WvErrorBase::strerror ( int errnum)
staticinherited

A replacement for the operating system ::strerror() function that can map more kinds of error strings (especially in win32).

Definition at line 91 of file wverror.cc.

References strerror().

Referenced by WvLog::perror(), strerror(), WvSSLStream::uread(), and WvSSLStream::uwrite().

◆ seterr() [1/3]

void WvErrorBase::seterr ( WvStringParm specialerr)
inherited

Definition at line 159 of file wverror.cc.

◆ seterr() [2/3]

void WvErrorBase::seterr ( WVSTRING_FORMAT_DECL )
inlineinherited

◆ seterr() [3/3]

void WvErrorBase::seterr ( const WvErrorBase & err)
inherited

Definition at line 170 of file wverror.cc.

◆ seterr_both() [1/3]

void WvErrorBase::seterr_both ( int _errnum,
WvStringParm specialerr )
inherited

Definition at line 179 of file wverror.cc.

◆ seterr_both() [2/3]

void WvErrorBase::seterr_both ( int _errnum,
WVSTRING_FORMAT_DECL  )
inlineinherited

◆ seterr_both() [3/3]

void WvErrorBase::seterr_both ( int _errnum,
WVSTRING_FORMAT_DECL  )
inlineinherited

Definition at line 73 of file include/wverror.h.

◆ noerr() [1/2]

void WvErrorBase::noerr ( )
inlineinherited

Reset our error state - there's no error condition anymore.

Definition at line 78 of file debian/libwvstreams-dev/usr/include/wvstreams/wverror.h.

◆ noerr() [2/2]

void WvErrorBase::noerr ( )
inlineinherited

Reset our error state - there's no error condition anymore.

Definition at line 78 of file include/wverror.h.

Member Data Documentation

◆ default_cflags

const int WvRegex::default_cflags = WvRegex::EXTENDED
static

◆ default_eflags

const int WvRegex::default_eflags = 0
static

◆ __wvre_null_reg

WvString WvRegex::__wvre_null_reg
static

Internal use only

Definition at line 142 of file debian/libwvstreams-dev/usr/include/wvstreams/wvregex.h.

◆ errnum

int WvErrorBase::errnum
protectedinherited

◆ errstring

WvString WvErrorBase::errstring
protectedinherited

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