The Gaudi Framework  master (ff829712)
Loading...
Searching...
No Matches
RegEx.h
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2025 CERN for the benefit of the LHCb and ATLAS collaborations *
3* *
4* This software is distributed under the terms of the Apache version 2 licence, *
5* copied verbatim in the file "LICENSE". *
6* *
7* In applying this licence, CERN does not waive the privileges and immunities *
8* granted to it by virtue of its status as an Intergovernmental Organization *
9* or submit itself to any jurisdiction. *
10\***********************************************************************************/
11#pragma once
12// ============================================================================
13// Include files
14// ============================================================================
15#include <boost/regex.hpp>
16#include <string>
17
18/*
19 * Gaudi namespace declaration
20 */
21namespace Gaudi {
22 namespace Utils {
23 // ========================================================================
32 namespace RegEx {
33 class matchList {
34 std::vector<boost::regex> m_regs;
35
36 public:
37 template <typename C>
38 matchList( const C& c ) {
39 m_regs.reserve( c.size() );
40 std::transform( std::begin( c ), std::end( c ), std::back_inserter( m_regs ),
41 []( typename C::const_reference i ) { return boost::regex{ i }; } );
42 }
43
44 bool Or( const std::string& test ) const {
45 return std::any_of( std::begin( m_regs ), std::end( m_regs ),
46 [&]( const boost::regex& r ) { return boost::regex_match( test, r ); } );
47 }
48 bool And( const std::string& test ) const {
49 return std::all_of( std::begin( m_regs ), std::end( m_regs ),
50 [&]( const boost::regex& r ) { return boost::regex_match( test, r ); } );
51 }
52 };
53
62 template <typename T>
63 bool matchOr( const std::string& test, const T& regexps ) {
64 // compares the string in test, to the regexps in a container
65 //
66 return std::any_of( std::begin( regexps ), std::end( regexps ), [&]( typename T::const_reference i ) {
67 return boost::regex_match( test, boost::regex{ i } );
68 } );
69 }
70
79 template <typename T>
80 bool matchAnd( const std::string& test, const T& regexps ) {
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 } // namespace RegEx
88 } // namespace Utils
89} // namespace Gaudi
bool Or(const std::string &test) const
Definition RegEx.h:44
bool And(const std::string &test) const
Definition RegEx.h:48
std::vector< boost::regex > m_regs
Definition RegEx.h:34
RegeEx: nemspace to hold gaudi regular expression checking.
Definition RegEx.h:32
bool matchOr(const std::string &test, const T &regexps)
return true if the string is in any of the regex's
Definition RegEx.h:63
bool matchAnd(const std::string &test, const T &regexps)
return true if the string is in all of the regex's
Definition RegEx.h:80
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition __init__.py:1