WvStreams
Public Types | Public Member Functions | Static Public Member Functions | Static Public Attributes | Protected Attributes | List of all members
WvGlob Class Reference

WvGlob – Unified support for filename globbing. ! More...

#include <wvglob.h>

Inheritance diagram for WvGlob:
Inheritance graph
[legend]

Public Types

enum  CFlags {
  BASIC = 0, EXTENDED = REG_EXTENDED, ICASE = REG_ICASE, NOSUB = REG_NOSUB,
  NEWLINE = REG_NEWLINE
}
 Flags that affect interpretation of the regex; used in Regex() and set() More...
 
enum  EFlags { NOTBOL = REG_NOTBOL, NOTEOL = REG_NOTEOL }
 Flags that affect matching of regex. More...
 

Public Member Functions

 WvGlob ()
 Construct an empty glob object. More...
 
 WvGlob (WvStringParm glob)
 Construct an glob object for the given pattern.
 
bool set (WvStringParm glob)
 Replace the current regex to match with a new one. More...
 
bool match (WvStringParm string, WVREGEX_REGS_DECL) const
 Match a given string against the compiled regular expression. More...
 
bool match (WvStringParm string, int eflags, WVREGEX_REGS_DECL) const
 Match a given string against the compiled regular expression. More...
 
void seterr (WvStringParm specialerr)
 
void seterr (WVSTRING_FORMAT_DECL)
 
void seterr (const WvErrorBase &err)
 
bool set (WvStringParm regex, int cflags=default_cflags)
 Replace the current regex to match with a new one. More...
 
bool continuable_match (WvStringParm string, int &match_start, int &match_end, WVREGEX_REGS_DECL) const
 Match a given string against the compiled regular expression, capturing the start and end positions of the matching string. More...
 
bool continuable_match (WvStringParm string, int eflags, int &match_start, int &match_end, WVREGEX_REGS_DECL) const
 Match a given string against the compiled regular expression, capturing the start and end positions of the matching string. More...
 
virtual bool isok () const
 By default, returns true if geterr() == 0. More...
 
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. More...
 
virtual WvString errstr () const
 
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.
 

Static Public Member Functions

static WvString glob_to_regex (WvStringParm glob, WvString *errstr)
 Convert a glob string to its regex equvilent. More...
 
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
 Internal use only.
 

Protected Attributes

int errnum
 
WvString errstring
 

Detailed Description

WvGlob – Unified support for filename globbing. !

Definition at line 15 of file wvglob.h.

Member Enumeration Documentation

◆ CFlags

enum WvRegex::CFlags
inherited

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

Definition at line 112 of file wvregex.h.

◆ EFlags

enum WvRegex::EFlags
inherited

Flags that affect matching of regex.

Used in match() and continuable_match()

Definition at line 130 of file wvregex.h.

Constructor & Destructor Documentation

◆ WvGlob()

WvGlob::WvGlob ( )

Construct an empty glob object.

Matches will always fail until set() is called with a valid glob pattern.

Definition at line 9 of file wvglob.cc.

Member Function Documentation

◆ set() [1/2]

bool WvGlob::set ( WvStringParm  glob)

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 18 of file wvglob.cc.

References WvErrorBase::isok(), WvRegex::set(), and WvErrorBase::seterr().

Referenced by WvGlob().

◆ glob_to_regex()

WvString WvGlob::glob_to_regex ( WvStringParm  glob,
WvString errstr 
)
static

Convert a glob string to its regex equvilent.

All wildcards (*, ?, {x,y,z}) are wrapped in parens for capturing into registers

Definition at line 287 of file wvglob.cc.

References WvString::edit().

◆ match() [1/2]

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

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;
if (re.match(line, match))
wvout->print("Matching substring is '%s'\n", match);

Definition at line 183 of file wvregex.h.

◆ match() [2/2]

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

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 wvregex.h.

◆ set() [2/2]

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

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 set(), and WvRegex::WvRegex().

◆ continuable_match() [1/2]

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

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 wvregex.h.

Referenced by strcoll_split().

◆ continuable_match() [2/2]

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

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 wvregex.h.

◆ isok()

virtual bool WvErrorBase::isok ( ) const
inlinevirtualinherited

By default, returns true if geterr() == 0.

Might be overridden so that isok() == false even though no error code has been specified.

Reimplemented in IWvStream, WvEncoderStream, WvReadLineStream, WvTCPConn, WvNullListener, WvFdStream, WvLog, WvStream, WvStreamClone, WvSSLStream, WvDBusServer, WvDSAKey, WvTimeStream, WvBufStream, WvListener, WvTimeoutStream, WvIStreamList, and _WvConStream.

Definition at line 39 of file wverror.h.

Referenced by WvListener::isok(), WvStream::isok(), and set().

◆ geterr()

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 WvStreamClone, and WvDBusServer.

Definition at line 48 of file wverror.h.

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


The documentation for this class was generated from the following files:
WvString
WvString is an implementation of a simple and efficient printable-string class.
Definition: wvstring.h:329
WvRegex::match
bool match(WvStringParm string, WVREGEX_REGS_DECL) const
Match a given string against the compiled regular expression.
Definition: wvregex.h:183