The Gaudi Framework  v30r3 (a5ef0a68)
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 <boost/regex.hpp>
7 #include <string>
8 
9 /*
10  * Gaudi namespace declaration
11  */
12 namespace Gaudi
13 {
14  namespace Utils
15  {
16  // ========================================================================
25  namespace RegEx
26  {
27  class matchList
28  {
30 
31  public:
32  template <typename C>
33  matchList( const C& c )
34  {
35  m_regs.reserve( c.size() );
37  []( typename C::const_reference i ) { return boost::regex{i}; } );
38  }
39 
40  bool Or( const std::string& test ) const
41  {
42  return std::any_of( std::begin( m_regs ), std::end( m_regs ),
43  [&]( const boost::regex& r ) { return boost::regex_match( test, r ); } );
44  }
45  bool And( const std::string& test ) const
46  {
47  return std::all_of( std::begin( m_regs ), std::end( m_regs ),
48  [&]( const boost::regex& r ) { return boost::regex_match( test, r ); } );
49  }
50  };
51 
60  template <typename T>
61  bool matchOr( const std::string& test, const T& regexps )
62  {
63  // compares the string in test, to the regexps in a container
64  //
65  return std::any_of( std::begin( regexps ), std::end( regexps ), [&]( typename T::const_reference i ) {
66  return boost::regex_match( test, boost::regex{i} );
67  } );
68  }
69 
78  template <typename T>
79  bool matchAnd( const std::string& test, const T& regexps )
80  {
81  // compares the string in test, to the regexps in a container
82  //
83  return std::all_of( std::begin( regexps ), std::end( regexps ), [&]( 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:40
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:61
T end(T...args)
STL class.
bool And(const std::string &test) const
Definition: RegEx.h:45
T begin(T...args)
T back_inserter(T...args)
std::vector< boost::regex > m_regs
Definition: RegEx.h:29
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:79
T transform(T...args)
Helper functions to set/get the application return code.
Definition: __init__.py:1
T reserve(T...args)