Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.atnf.csiro.au/computing/software/casacore/casacore-1.2.0/doc/html/RegexBase_8h_source.html
Дата изменения: Unknown
Дата индексирования: Mon Feb 14 20:19:13 2011
Кодировка:

Поисковые слова: п п р р р р р р п п п п п п п п
casacore: casa/BasicSL/RegexBase.h Source File

RegexBase.h

Go to the documentation of this file.
00001 //# RegexBase.h: Abstract interface class to regular expressions for String
00002 //# Copyright (C) 2001
00003 //# Associated Universities, Inc. Washington DC, USA.
00004 //#
00005 //# This library is free software; you can redistribute it and/or modify it
00006 //# under the terms of the GNU Library General Public License as published by
00007 //# the Free Software Foundation; either version 2 of the License, or (at your
00008 //# option) any later version.
00009 //#
00010 //# This library is distributed in the hope that it will be useful, but WITHOUT
00011 //# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
00012 //# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Library General Public
00013 //# License for more details.
00014 //#
00015 //# You should have received a copy of the GNU Library General Public License
00016 //# along with this library; if not, write to the Free Software Foundation,
00017 //# Inc., 675 Massachusetts Ave, Cambridge, MA 02139, USA.
00018 //#
00019 //# Correspondence concerning AIPS++ should be addressed as follows:
00020 //#        Internet email: aips2-request@nrao.edu.
00021 //#        Postal address: AIPS++ Project Office
00022 //#                        National Radio Astronomy Observatory
00023 //#                        520 Edgemont Road
00024 //#                        Charlottesville, VA 22903-2475 USA
00025 //#
00026 //#
00027 //# $Id: RegexBase.h 20551 2009-03-25 00:11:33Z Malte.Marquarding $
00028 
00029 #ifndef CASA_REGEXBASE_H
00030 #define CASA_REGEXBASE_H
00031 
00032 //# Includes
00033 #include <casa/aips.h>
00034 #include <casa/BasicSL/String.h>
00035 
00036 namespace casa { //# NAMESPACE CASA - BEGIN
00037 
00038 //# Forward declarations
00039 
00040 // <summary>
00041 // Abstract interface class to regular expressions for String
00042 // </summary>
00043 
00044 // <use visibility=local>
00045 
00046 // <reviewed reviewer="Friso Olnon" date="1995/03/20" tests="tRegex" demos="">
00047 // </reviewed>
00048 
00049 // <prerequisite>
00050 //   <li> Regular expression syntax
00051 //   <li> <linkto class=String>String</linkto> class
00052 // </prerequisite>
00053 //
00054 //
00055 // <synopsis>
00056 // This class provides a standard abstract interface to regular expression
00057 // classes. This interface class is used in the String class, to enable
00058 // the use of different actual regular expression classes.<br>
00059 // Actual regular expression classes should define the following
00060 // implementation (in addition, of course, to the standard constructors and
00061 // assignments):
00062 // <dl>
00063 //  <dt> String::size_type find(const Char *s, String::size_type len,
00064 //               Int &matchlen, String::size_type pos=0) const;
00065 //  <dd> Test if the regular expression occurs in string <src>s</src>.
00066 // The return value gives the position of the first substring
00067 // matching the regular expression (or String::npos if no match).
00068 // The length of that substring is returned in <src>matchlen</src>.
00069 // The string has <src>len</src> characters and the test starts at
00070 // position <src>pos</src>. The string may contain null characters.
00071 // </dl>
00072 // The base class provides also default implementations of a few other methods
00073 // used in the String classes' aips++ extensions. These implementations
00074 // can, of course, be overwritten with more efficient specialised ones if
00075 // necessary:
00076 // <dl>
00077 //  <dt>  String::size_type match(const Char *s,
00078 //               String::size_type len, String::size_type pos=0) const;
00079 //  <dd> Test if the regular expression matches string <src>s</src>.
00080 // The return value gives the length of the matching string part,
00081 // or String::npos if there is no match, or in case of an internal error.
00082 // The string has <src>len</src> characters and the test starts at
00083 // position <src>pos</src>. The string may contain null characters.
00084 // The default implementation checks if the regular expression is found
00085 // at position <src>pos</src> and with length (<src>len-pos</src>.
00086 //  <dt> String::size_type rfind(const Char *s, String::size_type len,
00087 //               Int &matchlen, String::size_type pos=npos) const;
00088 //  <dd> Test if the regular expression occurs in string <src>s</src>,
00089 //       searching reversed.
00090 // The return value gives the position of the first substring
00091 // matching the regular expression (or String::npos if no match).
00092 // The length of that substring is returned in <src>matchlen</src>.
00093 // The string has <src>len</src> characters and the test starts at
00094 // position <src>pos</src> (or at end of string).
00095 // The string may contain null characters. The default implementation
00096 // starts checking for the regular expression at <src>pos</src> (or at
00097 // the end of the string if that is less), and loops until it is
00098 // found. Looping is by decrementing the search position until begin of
00099 // string.
00100 //  <dt> String::size_type search(const Char *s, String::size_type len,
00101 //               Int &matchlen, Int pos=0) const;
00102 //  <dd> Test if the regular expression occurs in string <src>s</src>.
00103 // The return value gives the position of the first substring
00104 // matching the regular expression (or String::npos if no match).
00105 // The length of that substring is returned in <src>matchlen</src>.
00106 // The string has <src>len</src> characters and the test starts at
00107 // position <src>pos</src>. The string may contain null characters.
00108 // Following the special rule for aips++ string methods extensions:
00109 // a negative position will indicate a reverse find. The default implementation
00110 // checks for the sign of <src>pos</src> and calls either <src>find</src>
00111 // or <src>rfind</src>.
00112 // </dl>
00113 //
00114 // It is advisable to provide (static) methods to create strings from
00115 // patterns and v.v., including file search patterns. See
00116 // <linkto class=Regex>Regex</linkto> for an example.
00117 // </synopsis>
00118 //
00119 // <example>
00120 //  See examples in appropriate regular expression implementation
00121 // (e.g. <linkto class=Regex>Regex</linkto>)
00122 // </example>
00123 //
00124 // <motivation>
00125 //  To allow for different regular expression classes in String matches
00126 // </motivation>
00127 //
00128 // <todo asof="2001/05/22">
00129 //   <li> nothing I know of
00130 // </todo>
00131 
00132 class RegexBase {
00133  public:
00134   //# Constructors
00135   // Destructor
00136   virtual ~RegexBase();
00137   //# Member functions
00138   // Search string <src>s</src> of length <src>len</src>, starting at position
00139   // <src>pos</src>. Returned is the address of the first character of
00140   // the substring found (or <src>String::npos</src> if not found). The
00141   // matched length is returned in <src>matchlen</src>
00142   virtual String::size_type find(const Char *s, String::size_type len,
00143                                  Int &matchlen,
00144                                  String::size_type pos=0) const=0;
00145   // Match the string <src>s</src> of length <src>len</src> starting at
00146   // position <src>pos</src>. Return the first matched character pointer, or
00147   // <src>String::npos</src> if no match.
00148   virtual String::size_type match(const Char *s,
00149                                   String::size_type len,
00150                                   String::size_type pos=0) const;
00151   // Do an rfind() on the string <src>s</src> of length <src>len</src>
00152   // starting at position <src>pos</src>. Return the position matched, or
00153   // <src>String::npos</src>
00154   virtual String::size_type rfind(const Char *s, String::size_type len,
00155                                   Int &matchlen,
00156                                   String::size_type pos=String::npos) const;
00157   // Search string <src>s</src> of length <src>len</src>, starting at position
00158   // <src>pos</src>. Returned is the address of the first character of
00159   // the substring found (or <src>String::npos</src> if not found). The
00160   // matched length is returned in <src>matchlen</src>. If <src>pos<0</src>
00161   // do a reverse find.
00162   virtual String::size_type search(const Char *s, String::size_type len,
00163                                    Int &matchlen,
00164                                    Int pos=0) const;
00165  private:
00166 
00167 };
00168 
00169 
00170 } //# NAMESPACE CASA - END
00171 
00172 #endif
00173 
00174 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines