bes Updated for version 3.21.1
The Backend Server (BES) is the lower two tiers of the Hyrax data server
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
 Where does the pattern match.
 
int search (const std::string &s, int &matchlen) const
 Where 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 has 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 88 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 113 of file BESRegex.h.

◆ BESRegex() [2/3]

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

initialize a BESRegex with a C++ string

Definition at line 115 of file BESRegex.h.

◆ BESRegex() [3/3]

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

Definition at line 117 of file BESRegex.h.

◆ ~BESRegex()

BESRegex::~BESRegex ( )

Definition at line 57 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.

Look for a match to the regular expression in 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 70 of file BESRegex.cc.

◆ match() [2/2]

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

Does the pattern match.

Look for a match to the regular expression in the string.

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

Definition at line 105 of file BESRegex.cc.

◆ pattern()

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

Definition at line 125 of file BESRegex.h.

◆ search() [1/2]

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

Where does the pattern match.

Search for a match to the regex in 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, which return the start position of the longest match.

Definition at line 127 of file BESRegex.cc.

◆ search() [2/2]

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

Where does the pattern match.

Search for a match to the regex in the string.

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 179 of file BESRegex.cc.


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