The Gaudi Framework
master (57817a18)
Toggle main menu visibility
Loading...
Searching...
No Matches
Utils.cpp
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
#include "
Utils.h
"
12
#include <
GaudiKernel/System.h
>
13
#include <regex>
14
15
namespace
gpu
=
Gaudi::Parsers::Utils
;
16
17
std::string
gpu::replaceEnvironments
( std::string_view input ) {
18
static
const
std::regex expression(
"\\$(([A-Za-z0-9_]+)|\\(([A-Za-z0-9_]+)\\))"
);
19
20
std::string result = std::string{ input };
21
auto
start = input.begin();
22
auto
end = input.end();
23
std::match_results<std::string_view::const_iterator> what;
24
auto
flags = std::regex_constants::match_default;
25
std::size_t from = 0;
26
while
( std::regex_search( start, end, what, expression, flags ) ) {
27
if
( std::string env;
System::getEnv
( what[what[2].matched ? 2 : 3].str(), env ) ) {
28
auto
pos = result.find( what[0].first, from, what[0].length() );
29
result.replace( pos, what[0].length(), env );
30
from = pos + env.size();
31
}
32
start = what[0].second;
33
// update flags:
34
flags |= std::regex_constants::match_prev_avail;
35
}
36
return
result;
37
}
Utils.h
System.h
Gaudi::Parsers::Utils
Definition
Utils.h:17
Gaudi::Parsers::Utils::replaceEnvironments
std::string replaceEnvironments(std::string_view input)
Definition
Utils.cpp:17
System::getEnv
GAUDI_API std::vector< std::string > getEnv()
get all environment variables
Definition
System.cpp:341
GaudiCoreSvc
src
JobOptionsSvc
Utils.cpp
Generated on
for The Gaudi Framework by
1.17.0