| The Gaudi Framework v32r1 (f65d50dc)

Functions
Gaudi::Parsers::Utils Namespace Reference

## Functions
std::string | replaceEnvironments (const std::string &input)

## Function Documentation

## ◆ replaceEnvironments()

std::string Gaudi::Parsers::Utils::replaceEnvironments | ( | const std::string & | input | ) |

Definition at line 18 of file Utils.cpp.

18 {
19 static const boost::regex expression( "\\$(([A-Za-z0-9_]+)|\\(([A-Za-z0-9_]+)\\))" );
20
21 std::string result = input;
22 auto start = input.begin();
23 auto end = input.end();
24 boost::match_results<std::string::const_iterator> what;
25 boost::match_flag_type flags = boost::match_default;
26 while ( boost::regex_search( start, end, what, expression, flags ) ) {
27 std::string var{what[2].first, what[2].second};
28 if ( var.empty() ) var = std::string{what[3].first, what[3].second};
29 std::string env;
30 if ( System::getEnv( var, env ) ) {
31 boost::algorithm::replace_first( result, std::string{what[0].first, what[0].second}, env );
32 }
33 start = what[0].second;
34 // update flags:
35 flags |= boost::match_prev_avail;
36 flags |= boost::match_not_bob;
37 }
38 return result;
39 }
System::getEnv
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
Definition: System.cpp:369
std::string::end
T end(T... args)
IOTest.start
def start
Definition: IOTest.py:97
std::string
STL class.
IOTest.end
def end
Definition: IOTest.py:112
std::string::begin
T begin(T... args)