| The Gaudi Framework v32r1 (f65d50dc)

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 namespace Utils {
14 // ========================================================================
23 namespace RegEx {
24 class matchList {
25 std::vector<boost::regex> m_regs;
26
27 public:
28 template <typename C>
29 matchList( const C& c ) {
30 m_regs.reserve( c.size() );
31 std::transform( std::begin( c ), std::end( c ), std::back_inserter( m_regs ),
32 []( typename C::const_reference i ) { return boost::regex{i}; } );
33 }
34
35 bool Or( const std::string& test ) const {
36 return std::any_of( std::begin( m_regs ), std::end( m_regs ),
37 [&]( const boost::regex& r ) { return boost::regex_match( test, r ); } );
38 }
39 bool And( const std::string& test ) const {
40 return std::all_of( std::begin( m_regs ), std::end( m_regs ),
41 [&]( const boost::regex& r ) { return boost::regex_match( test, r ); } );
42 }
43 };
44
53 template <typename T>
54 bool matchOr( const std::string& test, const T& regexps ) {
55 // compares the string in test, to the regexps in a container
56 //
57 return std::any_of( std::begin( regexps ), std::end( regexps ), [&]( typename T::const_reference i ) {
58 return boost::regex_match( test, boost::regex{i} );
59 } );
60 }
61
70 template <typename T>
71 bool matchAnd( const std::string& test, const T& regexps ) {
72 // compares the string in test, to the regexps in a container
73 //
74 return std::all_of( std::begin( regexps ), std::end( regexps ), [&]( typename T::const_reference i ) {
75 return boost::regex_match( test, boost::regex{i} );
76 } );
77 }
78 } // namespace RegEx
79 } // namespace Utils
80 } // namespace Gaudi
81 #endif
GaudiTesting.BaseTest.regexps
regexps
Definition: BaseTest.py:1016
gaudirun.c
c
Definition: gaudirun.py:487
Gaudi::Utils::RegEx::matchList
Definition: RegEx.h:24
Gaudi::Utils::RegEx::matchList::matchList
matchList(const C &c)
Definition: RegEx.h:29
Gaudi::Utils::RegEx::matchOr
bool matchOr(const std::string &test, const T &regexps)
return true if the string is in any of the regex's
Definition: RegEx.h:54
std::end
T end(T... args)
std::string
STL class.
Gaudi::Utils::RegEx::matchList::Or
bool Or(const std::string &test) const
Definition: RegEx.h:35
compareRootHistos.test
string test
Definition: compareRootHistos.py:15
std::vector< boost::regex >
std::begin
T begin(T... args)
std::back_inserter
T back_inserter(T... args)
Gaudi::Utils::RegEx::matchList::m_regs
std::vector< boost::regex > m_regs
Definition: RegEx.h:25
std::any_of
T any_of(T... args)
Gaudi::Utils::RegEx::matchAnd
bool matchAnd(const std::string &test, const T &regexps)
return true if the string is in all of the regex's
Definition: RegEx.h:71
Gaudi::Utils::RegEx::matchList::And
bool And(const std::string &test) const
Definition: RegEx.h:39
std::transform
T transform(T... args)
Gaudi
Header file for std:chrono::duration-based Counters.
Definition: __init__.py:1
std::vector::reserve
T reserve(T... args)