/search.css" rel="stylesheet" type="text/css"/> /search.js">
Functions | |
bool | getEnv (const std::string &envName, std::string &envValue) |
Get enviroment variable. | |
bool | searchFile (const std::string &fileInput, std::string &fileOutput) |
Search file true if file was founded. | |
std::string | removeEnvironment (const std::string &input) |
Remove enviroment variables from string. | |
bool | readFile (const std::string &name, std::string &result) |
Read file to string. | |
bool | parseValue (const std::string &input, std::string &stringResult, std::vector< std::string > &vectorResult) |
Try to recognize string as value of job options type. |
bool Gaudi::Parsers::Utils::getEnv | ( | const std::string & | envName, |
std::string & | envValue | ||
) |
Get enviroment variable.
envName | Enviroment variable name |
envValue | Result = enviroment value |
Definition at line 41 of file ParserUtils.cc.
{ char* envch = getenv(envName.c_str()); if(envch==NULL) { return false; } envValue = envch; return true; }
bool Gaudi::Parsers::Utils::searchFile | ( | const std::string & | fileInput, |
std::string & | fileOutput | ||
) |
Search file true if file was founded.
fileInput | Path to file which can be not completed |
addCurrent | Add current program directory? |
dirs | Directories in which we can search file |
fileOutPut | Result - absolute path to file |
Definition at line 82 of file ParserUtils.cc.
{ fs::path givenPath(removeEnvironment(fileInput),fs::native); if(fs::exists(fileOutput = givenPath.string())) { return true; } return false; }
std::string Gaudi::Parsers::Utils::removeEnvironment | ( | const std::string & | input | ) |
Remove enviroment variables from string.
input | String to process |
Definition at line 50 of file ParserUtils.cc.
{ 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; } bool ok = getEnv(var, env); if(ok) { 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; }
bool Gaudi::Parsers::Utils::readFile | ( | const std::string & | name, |
std::string & | result | ||
) |
Read file to string.
name | Path to file |
result | Result string |
Definition at line 93 of file ParserUtils.cc.
{ std::ifstream in(name.c_str()); if (!in.is_open()) { return false; } char c; while (!in.get(c).eof()) { result += c; } return true; }
bool Gaudi::Parsers::Utils::parseValue | ( | const std::string & | input, |
std::string & | stringResult, | ||
std::vector< std::string > & | vectorResult | ||
) |
Try to recognize string as value of job options type.
input | string |
stringResult | String representation of value |
vectorResult | Result vector. Values represented as strings |