| # Gaudi Framework, version v23r0 |

Home |  | Generated: Mon Jan 30 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