Logo ROOT   6.10/09
Reference Guide
TRegexp.h
Go to the documentation of this file.
1 // @(#)root/base:$Id$
2 // Author: Fons Rademakers 04/08/95
3 
4 /*************************************************************************
5  * Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
6  * All rights reserved. *
7  * *
8  * For the licensing terms see $ROOTSYS/LICENSE. *
9  * For the list of contributors see $ROOTSYS/README/CREDITS. *
10  *************************************************************************/
11 
12 #ifndef ROOT_TRegexp
13 #define ROOT_TRegexp
14 
15 
16 //////////////////////////////////////////////////////////////////////////
17 // //
18 // TRegexp //
19 // //
20 // Declarations for regular expression class. //
21 // //
22 //////////////////////////////////////////////////////////////////////////
23 
24 #include "Rtypes.h"
25 
26 #include "Match.h"
27 
28 class TString;
29 
30 
31 class TRegexp {
32 
33 public:
34  enum EStatVal { kOK = 0, kIllegal, kNomem, kToolong };
35 
36 private:
37  Pattern_t *fPattern; // Compiled pattern
38  EStatVal fStat; // Status
39  static const unsigned fgMaxpat; // Max length of compiled pattern
40 
41  void CopyPattern(const TRegexp& re);
42  void GenPattern(const char *re);
43  const char *MakeWildcard(const char *re);
44 
45 public:
46  TRegexp(const char *re, Bool_t wildcard = kFALSE);
47  TRegexp(const TString& re);
48  TRegexp(const TRegexp& re);
49  virtual ~TRegexp();
50 
51  TRegexp& operator=(const TRegexp& re);
52  TRegexp& operator=(const TString& re); // Recompiles pattern
53  TRegexp& operator=(const char *re); // Recompiles pattern
54  Ssiz_t Index(const TString& str, Ssiz_t *len, Ssiz_t start=0) const;
55  EStatVal Status(); // Return & clear status
56 
57  ClassDef(TRegexp,0) // Regular expression class
58 };
59 
60 #endif
TRegexp(const char *re, Bool_t wildcard=kFALSE)
Create a regular expression from the input string.
Definition: TRegexp.cxx:51
Pattern_t * fPattern
Definition: TRegexp.h:37
EStatVal
Definition: TRegexp.h:34
TRegexp & operator=(const TRegexp &re)
Assignment operator.
Definition: TRegexp.cxx:86
Regular expression class.
Definition: TRegexp.h:31
Basic string class.
Definition: TString.h:129
bool Bool_t
Definition: RtypesCore.h:59
void GenPattern(const char *re)
Generate the regular expression pattern.
Definition: TRegexp.cxx:118
#define ClassDef(name, id)
Definition: Rtypes.h:297
unsigned short Pattern_t
Definition: Match.h:26
EStatVal fStat
Definition: TRegexp.h:38
const char * MakeWildcard(const char *re)
This routine transforms a wildcarding regular expression into a general regular expression used for p...
Definition: TRegexp.cxx:145
const Bool_t kFALSE
Definition: RtypesCore.h:92
int Ssiz_t
Definition: RtypesCore.h:63
void CopyPattern(const TRegexp &re)
Copy the regular expression pattern.
Definition: TRegexp.cxx:128
virtual ~TRegexp()
Destructor.
Definition: TRegexp.cxx:78
Ssiz_t Index(const TString &str, Ssiz_t *len, Ssiz_t start=0) const
Find the first occurrence of the regexp in string and return the position, or -1 if there is no match...
Definition: TRegexp.cxx:209
EStatVal Status()
Check status of regexp.
Definition: TRegexp.cxx:231
static const unsigned fgMaxpat
Definition: TRegexp.h:39