TF++, Miscellaneous classes and modules in C++:
regexx.cc
Go to the documentation of this file.
1 
36 #define TF_REGEXX_CC_VERSION \
37  "TF_REGEXX_CC V1.1"
38 
39 #include <tfxx/regexx.h>
40 
41 #ifdef OLDLIBREGEXX
42 #include<regexx.hh>
43 #ifndef REGEXX_HH
44 #error read wrong header
45 #endif
46 #else
47 #include<boost/regex.hpp>
48 #endif
49 
50 namespace tfxx {
51 
52  namespace string {
53 
54  namespace helper {
55 
59  regexxcontainer::regexxcontainer(const std::string& e) { }
62 
63 /*======================================================================*/
64 // use old libregexx
65 #ifdef OLDLIBREGEXX
66 
71  class myregexxcontainer:
73  public:
76  tfxx::string::helper::regexxcontainer()
77  { this->expression(std::string(".*")); }
79  myregexxcontainer(const std::string& e):
80  tfxx::string::helper::regexxcontainer(e)
81  { this->expression(e); }
83  virtual ~myregexxcontainer() { }
85  virtual void expression(const std::string& e)
86  { Mregex.expr(e); }
88  virtual std::string expression() const
89  { return(Mregex.expr()); }
91  virtual bool match(const std::string s)
92  {
93  Mregex.str(s);
94  return (Mregex.exec());
95  }
96  private:
97  ::regexx::Regexx Mregex;
98  }; // class myregexxcontainer
99 
100 /*======================================================================*/
101 // use libboost_regex
102 #else
103 
110  public:
113  tfxx::string::helper::regexxcontainer()
114  { this->expression(std::string(".*")); }
116  myregexxcontainer(const std::string& e):
117  tfxx::string::helper::regexxcontainer(e)
118  { this->expression(e); }
120  virtual ~myregexxcontainer() { }
122  virtual void expression(const std::string& e)
123  { Mregex.assign(e); }
125  virtual std::string expression() const
126  { return(Mregex.str()); }
128  virtual bool match(const std::string s)
129  { return(boost::regex_match(s, Mregex)); }
130  private:
131  boost::regex Mregex;
132  }; // class myregexxcontainer
133 
134 #endif
135 
136  } // namespace helper
137 
138 /*======================================================================*/
139 // common code
140 
145  regexx::regexx(const std::string& e)
149  { delete(Mcontainer); }
150 
151  } // namespace string
152 
153 } // namespace tfxx
154 
155 /* ----- END OF regexx.cc ----- */
regexx()
create instance.
Definition: regexx.cc:142
virtual std::string expression() const
return expression
Definition: regexx.cc:125
virtual bool match(const std::string s)
return true is s matches expression.
Definition: regexx.cc:128
tfxx::string::helper::regexxcontainer * Mcontainer
Definition: regexx.h:97
virtual ~myregexxcontainer()
create instance and set expression to e.
Definition: regexx.cc:120
virtual void expression(const std::string &e)
set expression to e.
Definition: regexx.cc:122
myregexxcontainer(const std::string &e)
create instance and set expression to e.
Definition: regexx.cc:116
~regexx()
remove instance.
Definition: regexx.cc:148
virtual ~regexxcontainer()
create instance and set expression to e.
Definition: regexx.cc:61
regexxcontainer()
create instance.
Definition: regexx.cc:57
myregexxcontainer()
create instance.
Definition: regexx.cc:112
Namespace containing all code of library libtfxx.