16 std::string i_resolve( std::string& source,
int recursions ) {
17 if ( recursions > 0 ) {
18 int lvl = 0, mx_lvl = 0;
19 for (
const char *c = source.c_str(), *beg =
nullptr; *c != 0; ++c ) {
22 if ( *( c + 1 ) ==
'{' ) {
32 if ( lvl == mx_lvl ) {
33 std::string env( beg + 2, c - beg - 2 );
35 if ( !
System::getEnv( env.c_str(), rep ) ) rep = i_resolve( env, --recursions );
37 std::string e( beg, c - beg + 1 );
38 size_t idx = std::string::npos;
39 while ( ( idx = source.find( e ) ) != std::string::npos ) { source.replace( idx, e.length(), rep ); }
40 return i_resolve( source, --recursions );
58 std::string source = var;
59 res = i_resolve( source, recursions );
66 std::string home_dir =
"./";
This class is used for returning status codes from appropriate routines.
constexpr static const auto SUCCESS
constexpr static const auto FAILURE
GAUDI_API StatusCode resolveEnv(const std::string &var, std::string &res, int recusions=124)
GAUDI_API std::vector< std::string > getEnv()
get all environment variables
GAUDI_API std::string getEnv(const char *var)
get a particular environment variable (returning "UNKNOWN" if not set)
GAUDI_API std::string tempDirectory()
GAUDI_API std::string homeDirectory()