ANNA Suite  2020b
Multipurpose development suite for Telco applications
RegularExpression.hpp
Go to the documentation of this file.
1 // ANNA - Anna is Not Nothingness Anymore //
2 // //
3 // (c) Copyright 2005-2015 Eduardo Ramos Testillano & Francisco Ruiz Rayo //
4 // //
5 // See project site at http://redmine.teslayout.com/projects/anna-suite //
6 // See accompanying file LICENSE or copy at http://www.teslayout.com/projects/public/anna.LICENSE //
7 
8 
9 #ifndef anna_core_util_RegularExpression_hpp
10 #define anna_core_util_RegularExpression_hpp
11 
12 
13 // STL
14 #include <string>
15 
16 // C
17 #include <regex.h>
18 
20 
21 
22 namespace anna {
23 
28 
29  std::string a_pattern;
30 
31  bool a_compiled;
32  regex_t a_preg;
33 
34 
35  void freeRegex() ;
36  void compile() noexcept(false);
37 
38 public:
39 
40  RegularExpression(const std::string & pattern = "") : a_pattern(pattern), a_compiled(false) {};
41  ~RegularExpression() { freeRegex(); }
42 
43 
44  // set
45 
51  void setPattern(const std::string & pattern) ;
52 
53 
54  // get
55 
61  const std::string & getPattern(void) const { return a_pattern; }
62 
63 
64  // helpers
70  bool isLike(const std::string & value) ;
71 
75  bool match(const std::string & value) { return isLike(value); }
76 
84  bool operator == (const RegularExpression & re) const;
85 
93  bool operator < (const RegularExpression & re) const;
94 };
95 
96 };
97 
98 
99 #endif
bool match(const std::string &value)
Definition: RegularExpression.hpp:75
bool isLike(const std::string &value)
Definition: RegularExpression.hpp:27
void setPattern(const std::string &pattern)
bool operator<(const RegularExpression &re) const
bool operator==(const RegularExpression &re) const
Definition: app.hpp:12
~RegularExpression()
Definition: RegularExpression.hpp:41
const std::string & getPattern(void) const
Definition: RegularExpression.hpp:61
RegularExpression(const std::string &pattern="")
Definition: RegularExpression.hpp:40