Rewrite NTS Framework.
[sim/o1-interface.git] / ntsimulator / regxstring / regxstring.cpp
1 /*************************************************************************\r
2 *\r
3 * Licensed under the Apache License, Version 2.0 (the "License");\r
4 * you may not use this file except in compliance with the License.\r
5 * You may obtain a copy of the License at\r
6 *\r
7 *     http://www.apache.org/licenses/LICENSE-2.0\r
8 *\r
9 * Unless required by applicable law or agreed to in writing, software\r
10 * distributed under the License is distributed on an "AS IS" BASIS,\r
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\r
12 * See the License for the specific language governing permissions and\r
13 * limitations under the License.\r
14 ***************************************************************************/\r
15 \r
16 #include "regxstring_impl.h"\r
17 #include "regxstring.h"\r
18 \r
19 CRegxString::CRegxString(const char * regx)\r
20     : impl_(0)\r
21 {\r
22     ParseRegx(regx);\r
23 }\r
24 \r
25 CRegxString::~CRegxString()\r
26 {\r
27     if(impl_)\r
28         delete impl_;\r
29 }\r
30 \r
31 void CRegxString::ParseRegx(const char * regx,const Config * config)\r
32 {\r
33     if(!regx)\r
34         return;\r
35     if(!impl_)\r
36         impl_ = new REGXSTRING_NS::__CRegxString;\r
37     impl_->ParseRegx(regx,config);\r
38 }\r
39 \r
40 const char * CRegxString::Regx() const\r
41 {\r
42     return (impl_ ? impl_->Regx().c_str() : 0);\r
43 }\r
44 \r
45 const char * CRegxString::RandString()\r
46 {\r
47     return (impl_ ? impl_->RandString().c_str() : 0);\r
48 }\r
49 const char * CRegxString::LastString() const\r
50 {\r
51     return (impl_ ? impl_->LastString().c_str() : 0);\r
52 }\r
53 \r
54 void CRegxString::Debug(std::ostream & out) const\r
55 {\r
56     if(impl_)\r
57         impl_->Debug(out);\r
58 }\r