All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
RegEx.h
Go to the documentation of this file.
1 #ifndef GAUDIUTILS_REGEX_H
2 #define GAUDIUTILS_REGEX_H
3 // ============================================================================
4 // Include files
5 // ============================================================================
6 #include <string>
7 #include <boost/regex.hpp>
8 
9 /*
10  * Gaudi namespace declaration
11  */
12 namespace Gaudi
13 {
14  namespace Utils
15  {
16  // ========================================================================
25  namespace RegEx
26  {
27  class matchList {
29  public:
30  template <typename C> matchList(const C& c) {
31  m_regs.reserve(c.size());
33  std::back_inserter(m_regs),
34  [](typename C::const_reference i) { return boost::regex{i}; } );
35  }
36 
37  bool Or(const std::string& test) const {
38  return std::any_of( std::begin(m_regs), std::end(m_regs),
39  [&](const boost::regex& r) {
40  return boost::regex_match(test, r);
41  });
42  }
43  bool And(const std::string& test) const {
44  return std::all_of( std::begin(m_regs), std::end(m_regs),
45  [&](const boost::regex& r) {
46  return boost::regex_match(test, r);
47  });
48  }
49 
50  };
51 
60  template <typename T> bool matchOr(const std::string & test, const T & regexps)
61  {
62  //compares the string in test, to the regexps in a container
63  //
64  return std::any_of( std::begin(regexps), std::end(regexps),
65  [&](typename T::const_reference i) {
66  return boost::regex_match(test, boost::regex{i});
67  });
68  }
69 
78  template <typename T> bool matchAnd(const std::string & test, const T & regexps)
79  {
80  //compares the string in test, to the regexps in a container
81  //
82  return std::all_of( std::begin(regexps), std::end(regexps),
83  [&](typename T::const_reference i) {
84  return boost::regex_match(test, boost::regex{i});
85  });
86  }
87  }
88  }
89 }
90 #endif
bool Or(const std::string &test) const
Definition: RegEx.h:37
bool matchOr(const std::string &test, const T &regexps)
return true if the string is in any of the regex&#39;s
Definition: RegEx.h:60
T end(T...args)
STL class.
bool And(const std::string &test) const
Definition: RegEx.h:43
T begin(T...args)
T back_inserter(T...args)
std::vector< boost::regex > m_regs
Definition: RegEx.h:28
T any_of(T...args)
bool matchAnd(const std::string &test, const T &regexps)
return true if the string is in all of the regex&#39;s
Definition: RegEx.h:78
T transform(T...args)
Helper functions to set/get the application return code.
Definition: __init__.py:1
T reserve(T...args)