Gaudi Framework, version v23r2

Home   Generated: Thu Jun 28 2012
Functions

Gaudi::Parsers::Utils Namespace Reference

Functions

std::string replaceEnvironments (const std::string &input)

Function Documentation

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

Definition at line 26 of file Utils.cpp.

                                                         {
  std::string result=input;// result

    const char* re = "\\$(([A-Za-z0-9_]+)|\\(([A-Za-z0-9_]+)\\))";
    std::string::const_iterator start, end;
    boost::regex expression(re);
    start = input.begin();
    end = input.end();
    boost::match_results<std::string::const_iterator> what;
    boost::match_flag_type flags = boost::match_default;
    while ( boost::regex_search(start, end, what, expression, flags ) )
    {
      std::string var,env;
      std::string matched(what[0].first,what[0].second);
      std::string v1(what[2].first,what[2].second);
      std::string v2(what[3].first,what[3].second);

      if ( v1.length()>0){ var = v1; }
      else { var = v2; }

      System::getEnv(var, env);
      if(var != "UNKNOWN") {
        boost::algorithm::replace_first(result,matched, env);
      }
      start = what[0].second;
      // update flags:
      flags |= boost::match_prev_avail;
      flags |= boost::match_not_bob;
    }
    return result;
}
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines

Generated at Thu Jun 28 2012 23:27:50 for Gaudi Framework, version v23r2 by Doxygen version 1.7.2 written by Dimitri van Heesch, © 1997-2004