The Gaudi Framework
master (37c0b60a)
RegEx.h
Go to the documentation of this file.
1
/***********************************************************************************\
2
* (c) Copyright 1998-2019 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
#ifndef GAUDIUTILS_REGEX_H
12
#define GAUDIUTILS_REGEX_H
13
// ============================================================================
14
// Include files
15
// ============================================================================
16
#include <boost/regex.hpp>
17
#include <string>
18
19
/*
20
* Gaudi namespace declaration
21
*/
22
namespace
Gaudi
{
23
namespace
Utils {
24
// ========================================================================
33
namespace
RegEx {
34
class
matchList
{
35
std::vector<boost::regex>
m_regs
;
36
37
public
:
38
template
<
typename
C>
39
matchList
(
const
C&
c
) {
40
m_regs
.
reserve
(
c
.size() );
41
std::transform
(
std::begin
(
c
),
std::end
(
c
),
std::back_inserter
(
m_regs
),
42
[](
typename
C::const_reference i ) {
return
boost::regex{ i }; } );
43
}
44
45
bool
Or
(
const
std::string
&
test
)
const
{
46
return
std::any_of
(
std::begin
(
m_regs
),
std::end
(
m_regs
),
47
[&](
const
boost::regex& r ) {
return
boost::regex_match(
test
, r ); } );
48
}
49
bool
And
(
const
std::string
&
test
)
const
{
50
return
std::all_of
(
std::begin
(
m_regs
),
std::end
(
m_regs
),
51
[&](
const
boost::regex& r ) {
return
boost::regex_match(
test
, r ); } );
52
}
53
};
54
63
template
<
typename
T>
64
bool
matchOr
(
const
std::string
&
test
,
const
T&
regexps
) {
65
// compares the string in test, to the regexps in a container
66
//
67
return
std::any_of
(
std::begin
(
regexps
),
std::end
(
regexps
), [&](
typename
T::const_reference i ) {
68
return
boost::regex_match(
test
, boost::regex{ i } );
69
} );
70
}
71
80
template
<
typename
T>
81
bool
matchAnd
(
const
std::string
&
test
,
const
T&
regexps
) {
82
// compares the string in test, to the regexps in a container
83
//
84
return
std::all_of
(
std::begin
(
regexps
),
std::end
(
regexps
), [&](
typename
T::const_reference i ) {
85
return
boost::regex_match(
test
, boost::regex{ i } );
86
} );
87
}
88
}
// namespace RegEx
89
}
// namespace Utils
90
}
// namespace Gaudi
91
#endif
Gaudi::Utils::RegEx::matchList
Definition:
RegEx.h:34
std::string
STL class.
std::vector::reserve
T reserve(T... args)
std::vector< boost::regex >
std::back_inserter
T back_inserter(T... args)
Gaudi::Utils::RegEx::matchList::And
bool And(const std::string &test) const
Definition:
RegEx.h:49
gaudirun.c
c
Definition:
gaudirun.py:525
std::any_of
T any_of(T... args)
Gaudi::Utils::RegEx::matchList::m_regs
std::vector< boost::regex > m_regs
Definition:
RegEx.h:35
Gaudi::Utils::RegEx::matchAnd
bool matchAnd(const std::string &test, const T ®exps)
return true if the string is in all of the regex's
Definition:
RegEx.h:81
Gaudi::Utils::RegEx::matchList::matchList
matchList(const C &c)
Definition:
RegEx.h:39
GaudiTesting.BaseTest.regexps
list regexps
Definition:
BaseTest.py:1161
std::transform
T transform(T... args)
Gaudi
This file provides a Grammar for the type Gaudi::Accumulators::Axis It allows to use that type from p...
Definition:
__init__.py:1
Gaudi::Utils::RegEx::matchOr
bool matchOr(const std::string &test, const T ®exps)
return true if the string is in any of the regex's
Definition:
RegEx.h:64
std::begin
T begin(T... args)
compareRootHistos.test
test
Definition:
compareRootHistos.py:28
std::end
T end(T... args)
Gaudi::Utils::RegEx::matchList::Or
bool Or(const std::string &test) const
Definition:
RegEx.h:45
GaudiUtils
include
GaudiUtils
RegEx.h
Generated on Thu Dec 19 2024 15:35:08 for The Gaudi Framework by
1.8.18