17 {
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
34 flags |= std::regex_constants::match_prev_avail;
35 }
36 return result;
37}
GAUDI_API std::vector< std::string > getEnv()
get all environment variables