The Gaudi Framework
master (934d2c3c)
Toggle main menu visibility
Loading...
Searching...
No Matches
RegEx.h
Go to the documentation of this file.
1
/***********************************************************************************\
2
* (c) Copyright 1998-2026 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 <
algorithm
>
16
#include <
iterator
>
17
#include <
regex
>
18
#include <
string
>
19
20
/*
21
* Gaudi namespace declaration
22
*/
23
namespace
Gaudi::Utils
{
24
// ========================================================================
33
namespace
RegEx
{
34
class
matchList
{
35
std::vector<std::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
std::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
std::regex
& r ) {
return
std::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
std::regex
& r ) {
return
std::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 ),
68
[&](
typename
T::const_reference i ) {
return
std::regex_match
( test,
std::regex
{ i } ); } );
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 ),
84
[&](
typename
T::const_reference i ) {
return
std::regex_match
( test,
std::regex
{ i } ); } );
85
}
86
}
// namespace RegEx
87
}
// namespace Gaudi::Utils
algorithm
iterator
regex
string
std::transform
constexpr _OutputIterator transform(_InputIterator __first, _InputIterator __last, _OutputIterator __result, _UnaryOperation __unary_op)
std::all_of
constexpr bool all_of(_InputIterator __first, _InputIterator __last, _Predicate __pred)
std::any_of
constexpr bool any_of(_InputIterator __first, _InputIterator __last, _Predicate __pred)
std::regex
basic_regex< char > regex
std::regex_match
bool regex_match(_Bi_iter __s, _Bi_iter __e, match_results< _Bi_iter, _Alloc > &__m, const basic_regex< _Ch_type, _Rx_traits > &__re, regex_constants::match_flag_type __flags=regex_constants::match_default)
std::back_inserter
constexpr back_insert_iterator< _Container > back_inserter(_Container &__x)
std::begin
constexpr auto begin(_Container &__cont) -> decltype(__cont.begin())
std::end
constexpr auto end(_Container &__cont) -> decltype(__cont.end())
std::vector
std::vector::reserve
constexpr void reserve(size_type __n)
Gaudi::Utils::RegEx::matchList::Or
bool Or(const std::string &test) const
Definition
RegEx.h:45
Gaudi::Utils::RegEx::matchList::And
bool And(const std::string &test) const
Definition
RegEx.h:49
Gaudi::Utils::RegEx::matchList::m_regs
std::vector< std::regex > m_regs
Definition
RegEx.h:35
Gaudi::Utils::RegEx::matchList::matchList
matchList(const C &c)
Definition
RegEx.h:39
Gaudi::Utils::RegEx
RegeEx: nemspace to hold gaudi regular expression checking.
Definition
RegEx.h:33
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
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:80
Gaudi::Utils
Definition
Property.h:693
GaudiUtils
include
GaudiUtils
RegEx.h
Generated on
for The Gaudi Framework by
1.18.0