Документ взят из кэша поисковой машины. Адрес
оригинального документа
: http://www.atnf.csiro.au/computing/software/casacore/casacore-1.2.0/doc/html/classcasa_1_1RegexBase.html
Дата изменения: Unknown Дата индексирования: Mon Feb 14 21:23:51 2011 Кодировка: Поисковые слова: п п п п п п п п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п р п |
Abstract interface class to regular expressions for String. More...
#include <RegexBase.h>
Public Member Functions | |
virtual | ~RegexBase () |
Destructor. | |
virtual String::size_type | find (const Char *s, String::size_type len, Int &matchlen, String::size_type pos=0) const =0 |
Search string s of length len , starting at position pos . | |
virtual String::size_type | match (const Char *s, String::size_type len, String::size_type pos=0) const |
Match the string s of length len starting at position pos . | |
virtual String::size_type | rfind (const Char *s, String::size_type len, Int &matchlen, String::size_type pos=String::npos) const |
Do an rfind() on the string s of length len starting at position pos . | |
virtual String::size_type | search (const Char *s, String::size_type len, Int &matchlen, Int pos=0) const |
Search string s of length len , starting at position pos . |
Abstract interface class to regular expressions for String.
Internal
This class provides a standard abstract interface to regular expression classes. This interface class is used in the String class, to enable the use of different actual regular expression classes.
Actual regular expression classes should define the following implementation (in addition, of course, to the standard constructors and assignments):
s
. The return value gives the position of the first substring matching the regular expression (or String::npos if no match). The length of that substring is returned in matchlen
. The string has len
characters and the test starts at position pos
. The string may contain null characters. The base class provides also default implementations of a few other methods used in the String classes' aips++ extensions. These implementations can, of course, be overwritten with more efficient specialised ones if necessary:
s
. The return value gives the length of the matching string part, or String::npos if there is no match, or in case of an internal error. The string has len
characters and the test starts at position pos
. The string may contain null characters. The default implementation checks if the regular expression is found at position pos
and with length (len-pos
. s
, searching reversed. The return value gives the position of the first substring matching the regular expression (or String::npos if no match). The length of that substring is returned in matchlen
. The string has len
characters and the test starts at position pos
(or at end of string). The string may contain null characters. The default implementation starts checking for the regular expression at pos
(or at the end of the string if that is less), and loops until it is found. Looping is by decrementing the search position until begin of string. s
. The return value gives the position of the first substring matching the regular expression (or String::npos if no match). The length of that substring is returned in matchlen
. The string has len
characters and the test starts at position pos
. The string may contain null characters. Following the special rule for aips++ string methods extensions: a negative position will indicate a reverse find. The default implementation checks for the sign of pos
and calls either find
or rfind
. It is advisable to provide (static) methods to create strings from patterns and v.v., including file search patterns. See Regex for an example.
See examples in appropriate regular expression implementation (e.g. Regex )
To allow for different regular expression classes in String matches
Definition at line 132 of file RegexBase.h.
virtual casa::RegexBase::~RegexBase | ( | ) | [virtual] |
Destructor.
virtual String::size_type casa::RegexBase::find | ( | const Char * | s, | |
String::size_type | len, | |||
Int & | matchlen, | |||
String::size_type | pos = 0 | |||
) | const [pure virtual] |
Search string s
of length len
, starting at position pos
.
Returned is the address of the first character of the substring found (or String::npos
if not found). The matched length is returned in matchlen
Implemented in casa::Regex.
virtual String::size_type casa::RegexBase::match | ( | const Char * | s, | |
String::size_type | len, | |||
String::size_type | pos = 0 | |||
) | const [virtual] |
Match the string s
of length len
starting at position pos
.
Return the first matched character pointer, or String::npos
if no match.
Reimplemented in casa::Regex.
virtual String::size_type casa::RegexBase::rfind | ( | const Char * | s, | |
String::size_type | len, | |||
Int & | matchlen, | |||
String::size_type | pos = String::npos | |||
) | const [virtual] |
Do an rfind() on the string s
of length len
starting at position pos
.
Return the position matched, or String::npos
virtual String::size_type casa::RegexBase::search | ( | const Char * | s, | |
String::size_type | len, | |||
Int & | matchlen, | |||
Int | pos = 0 | |||
) | const [virtual] |
Search string s
of length len
, starting at position pos
.
Returned is the address of the first character of the substring found (or String::npos
if not found). The matched length is returned in matchlen
. If pos<0
do a reverse find.
Reimplemented in casa::Regex.