Exemple #1
0
std::string ICatalogInfo::transformArchivePath(const std::string &path) const {
  std::string ret;
#ifdef __linux__
  ret = replacePrefix(path, catalogPrefix(), linuxPrefix());
  ret = replaceAllOccurences(ret, "\\", "/");
#elif __APPLE__
  ret = replacePrefix(path, catalogPrefix(), macPrefix());
  ret = replaceAllOccurences(ret, "\\", "/");
#elif _WIN32
  // Check to see if path is a windows path.
  if (path.find("\\") == std::string::npos) {
    ret = replacePrefix(path, linuxPrefix(), windowsPrefix());
    ret = replaceAllOccurences(ret, "/", "\\");
  } else {
    ret = path;
  }
#endif
  return ret;
}
Exemple #2
0
/**
 * \brief function to set parameters appearing in a script
 * \param scriptContent The string to modify
 * \param \param params a list of parameters in the form of PARAM1=value1  PARAM2=value2 ...
 */
void
vishnu::setParams(std::string& scriptContent,
                  const std::string & params) {
  std::string paramName;
  std::string paramValue;
  size_t pos;
  ListStrings paramsVec;

  std::string& refParams = const_cast<std::string&>(params);
  boost::trim(refParams);
  boost::split(paramsVec, refParams, boost::is_any_of(" "));
  for (ListStrings::iterator it = paramsVec.begin(); it != paramsVec.end(); ++it) {
    pos = it->find("=");
    if (pos != std::string::npos) {
      paramName = it->substr(0, pos);
      paramValue = it->substr(pos+1, std::string::npos);
      replaceAllOccurences(scriptContent, "$" + paramName, paramValue);
      replaceAllOccurences(scriptContent, "${" + paramName + "}", paramValue);
    }
  }
}