/search.css" rel="stylesheet" type="text/css"/> /search.js">
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

In This Package:

Functions
Gaudi::Parsers::Utils Namespace Reference

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.

Function Documentation

bool Gaudi::Parsers::Utils::getEnv ( const std::string &  envName,
std::string &  envValue 
)

Get enviroment variable.

Returns:
true if variable exists
Parameters:
envNameEnviroment variable name
envValueResult = 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.

Parameters:
fileInputPath to file which can be not completed
addCurrentAdd current program directory?
dirsDirectories in which we can search file
fileOutPutResult - 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.

Returns:
String without enviroment variables
Parameters:
inputString 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.

Returns:
true if file was readen succesfully
Parameters:
namePath to file
resultResult 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.

Returns:
true if string is recognized
Parameters:
inputstring
stringResultString representation of value
vectorResultResult vector. Values represented as strings
| Classes | Job Modules | Data Objects | Services | Algorithms | Tools | Packages | Directories | Tracs |

Generated on Fri May 16 2014 09:50:18 for LafKernel by doxygen 1.7.4