bes Updated for version 3.20.13
BESRegex Class Reference

Regular expression matching. More...

#include <BESRegex.h>

Collaboration diagram for BESRegex:
Collaboration graph

Public Member Functions

 BESRegex (const char *s)
 initialize a BESRegex with a C string
 
 BESRegex (const char *s, int)
 
 BESRegex (const std::string &s)
 initialize a BESRegex with a C++ string
 
int match (const char *s, int len, int pos=0) const
 Does the pattern match.
 
int match (const std::string &s) const
 Does the pattern match.
 
std::string pattern () const
 
int search (const char *s, int len, int &matchlen, int pos=0) const
 How much of the string does the pattern match.
 
int search (const std::string &s, int &matchlen) const
 How much of the string does the pattern match.
 

Detailed Description

Regular expression matching.

This class provides an interface that mimics the libgnu C++ library that was used with the first version of libdap (c. 1993). It can been re-implemented several times, this last time using the C++-11 regex class. We found this was faster than the unix regex_t (man(3)) that was being used.

Note
Make sure to compile the regular expressions only when really needed (e.g., make Regex instances const, etc., when possible) since it is an expensive operation
Author
James Gallagher jgall.nosp@m.aghe.nosp@m.r@ope.nosp@m.ndap.nosp@m..org

Definition at line 52 of file BESRegex.h.

Constructor & Destructor Documentation

◆ BESRegex() [1/3]

BESRegex::BESRegex ( const char *  s)
inlineexplicit

initialize a BESRegex with a C string

Definition at line 77 of file BESRegex.h.

◆ BESRegex() [2/3]

BESRegex::BESRegex ( const char *  s,
int   
)
inline
Deprecated:

Definition at line 79 of file BESRegex.h.

◆ BESRegex() [3/3]

BESRegex::BESRegex ( const std::string &  s)
inlineexplicit

initialize a BESRegex with a C++ string

Definition at line 81 of file BESRegex.h.

◆ ~BESRegex()

BESRegex::~BESRegex ( )

Definition at line 96 of file BESRegex.cc.

Member Function Documentation

◆ match() [1/2]

int BESRegex::match ( const char *  s,
int  len,
int  pos = 0 
) const

Does the pattern match.

Does the regular expression match the string?

Parameters
sThe string
lenThe length of string to consider
posStart looking at this position in the string
Returns
The number of characters that match, -1 if there's no match.

Definition at line 127 of file BESRegex.cc.

◆ match() [2/2]

int BESRegex::match ( const std::string &  s) const

Does the pattern match.

Search for a match to the regex.

Parameters
sThe target for the search
Returns
The length of the matching substring, or -1 if no match was found

Definition at line 167 of file BESRegex.cc.

◆ pattern()

std::string BESRegex::pattern ( ) const
inline

Definition at line 89 of file BESRegex.h.

◆ search() [1/2]

int BESRegex::search ( const char *  s,
int  len,
int matchlen,
int  pos = 0 
) const

How much of the string does the pattern match.

Does the regular expression match the string?

Parameters
sThe string
lenThe length of string to consider
matchlenReturn the length of the matched portion in this value-result parameter.
posStart looking at this position in the string
Returns
The start position of the first match. This is different from POSIX regular expressions, whcih return the start position of the longest match.

Definition at line 192 of file BESRegex.cc.

◆ search() [2/2]

int BESRegex::search ( const std::string &  s,
int matchlen 
) const

How much of the string does the pattern match.

Search for a match to the regex.

Parameters
sThe target for the search
matchlenThe number of characters that matched
Returns
The starting position of the first set of matching characters

Definition at line 250 of file BESRegex.cc.


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