libdap Updated for version 3.20.11
libdap4 is an implementation of OPeNDAP's DAP protocol.
libdap::Regex Class Reference

Regular expression matching. More...

#include <GNURegex.h>

Public Member Functions

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

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 56 of file GNURegex.h.

Constructor & Destructor Documentation

◆ Regex() [1/3]

libdap::Regex::Regex ( const char *  s)
inlineexplicit

initialize a Regex with a C string

Definition at line 79 of file GNURegex.h.

◆ Regex() [2/3]

libdap::Regex::Regex ( const char *  s,
int   
)
inline
Deprecated:

Definition at line 81 of file GNURegex.h.

◆ Regex() [3/3]

libdap::Regex::Regex ( const std::string &  s)
inlineexplicit

nitialize a Regex with a C++ string

Definition at line 83 of file GNURegex.h.

◆ ~Regex()

libdap::Regex::~Regex ( )

Definition at line 110 of file GNURegex.cc.

Member Function Documentation

◆ match() [1/2]

int libdap::Regex::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 141 of file GNURegex.cc.

◆ match() [2/2]

int libdap::Regex::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 181 of file GNURegex.cc.

◆ search() [1/2]

int libdap::Regex::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 206 of file GNURegex.cc.

◆ search() [2/2]

int libdap::Regex::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 264 of file GNURegex.cc.


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