wordReI.H
Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029 inline bool Foam::wordRe::meta(char c)
00030 {
00031 return regExp::meta(c);
00032 }
00033
00034
00035 inline bool Foam::wordRe::isPattern(const string& str)
00036 {
00037 return string::meta<regExp>(str);
00038 }
00039
00040
00041
00042
00043 inline Foam::wordRe::wordRe()
00044 :
00045 word(),
00046 re_()
00047 {}
00048
00049
00050 inline Foam::wordRe::wordRe(const wordRe& str)
00051 :
00052 word(str),
00053 re_()
00054 {
00055 if (str.isPattern())
00056 {
00057 compile();
00058 }
00059 }
00060
00061
00062 inline Foam::wordRe::wordRe(const word& str)
00063 :
00064 word(str),
00065 re_()
00066 {}
00067
00068
00069 inline Foam::wordRe::wordRe(const char* str, const compOption opt)
00070 :
00071 word(str, false),
00072 re_()
00073 {
00074 compile(opt);
00075 }
00076
00077
00078 inline Foam::wordRe::wordRe(const string& str, const compOption opt)
00079 :
00080 word(str, false),
00081 re_()
00082 {
00083 compile(opt);
00084 }
00085
00086
00087 inline Foam::wordRe::wordRe(const std::string& str, const compOption opt)
00088 :
00089 word(str, false),
00090 re_()
00091 {
00092 compile(opt);
00093 }
00094
00095
00096
00097
00098 inline bool Foam::wordRe::isPattern() const
00099 {
00100 return re_.exists();
00101 }
00102
00103
00104 inline bool Foam::wordRe::compile(const compOption opt) const
00105 {
00106 bool doCompile = false;
00107
00108 if (opt & wordRe::REGEXP)
00109 {
00110 doCompile = true;
00111 }
00112 else if (opt & wordRe::DETECT)
00113 {
00114 if (string::meta<regExp>(*this) || !string::valid<word>(*this))
00115 {
00116 doCompile = true;
00117 }
00118 }
00119 else if (opt & wordRe::NOCASE)
00120 {
00121 doCompile = true;
00122 }
00123
00124
00125 if (doCompile)
00126 {
00127 re_.set(*this, (opt & wordRe::NOCASE));
00128 }
00129 else
00130 {
00131 re_.clear();
00132 }
00133
00134 return re_.exists();
00135 }
00136
00137
00138 inline bool Foam::wordRe::compile() const
00139 {
00140 re_ = *this;
00141 return re_.exists();
00142 }
00143
00144
00145 inline bool Foam::wordRe::recompile() const
00146 {
00147 if (re_.exists())
00148 {
00149 re_ = *this;
00150 }
00151
00152 return re_.exists();
00153 }
00154
00155
00156 inline void Foam::wordRe::uncompile(const bool doStripInvalid) const
00157 {
00158 if (re_.clear())
00159 {
00160
00161 if (word::debug && doStripInvalid)
00162 {
00163 string::stripInvalid<word>
00164 (
00165 const_cast<word&>(static_cast<const word&>(*this))
00166 );
00167 }
00168 }
00169 }
00170
00171
00172 inline void Foam::wordRe::clear()
00173 {
00174 word::clear();
00175 re_.clear();
00176 }
00177
00178
00179 inline bool Foam::wordRe::match(const string& str, bool literalMatch) const
00180 {
00181 if (literalMatch || !re_.exists())
00182 {
00183
00184 return (*this == str);
00185 }
00186 else
00187 {
00188
00189 return re_.match(str);
00190 }
00191 }
00192
00193
00194 inline Foam::string Foam::wordRe::quotemeta() const
00195 {
00196 return string::quotemeta<regExp>(*this);
00197 }
00198
00199
00200 inline void Foam::wordRe::set(const std::string& str, const compOption opt)
00201 {
00202 string::operator=(str);
00203 compile(opt);
00204 }
00205
00206
00207 inline void Foam::wordRe::set(const char* str, const compOption opt)
00208 {
00209 string::operator=(str);
00210 compile(opt);
00211 }
00212
00213
00214
00215
00216 inline const Foam::wordRe& Foam::wordRe::operator=(const wordRe& str)
00217 {
00218 string::operator=(str);
00219
00220 if (str.isPattern())
00221 {
00222 compile();
00223 }
00224 else
00225 {
00226 re_.clear();
00227 }
00228 return *this;
00229 }
00230
00231
00232 inline const Foam::wordRe& Foam::wordRe::operator=(const word& str)
00233 {
00234 word::operator=(str);
00235 re_.clear();
00236 return *this;
00237 }
00238
00239
00240 inline const Foam::wordRe& Foam::wordRe::operator=(const string& str)
00241 {
00242 string::operator=(str);
00243 compile(DETECT);
00244 return *this;
00245 }
00246
00247
00248 inline const Foam::wordRe& Foam::wordRe::operator=(const std::string& str)
00249 {
00250 string::operator=(str);
00251 compile(DETECT);
00252 return *this;
00253 }
00254
00255
00256 inline const Foam::wordRe& Foam::wordRe::operator=(const char* str)
00257 {
00258 string::operator=(str);
00259 compile(DETECT);
00260 return *this;
00261 }
00262
00263
00264
Copyright © 2000-2009 OpenCFD Ltd