Пример #1
0
QString ConfigManager<>::operator[](const QString& key) const
{
    QString keyLower = key.toLower();
    if(!_container.contains(keyLower))
    {
        qDebug() << "[ConfigManager] Klucz " << key
                 << "nie został znaleziony.";
        throw KeyNotFound();
    }
    return _container[keyLower];
}
Пример #2
0
/**
 * Similar as the 'which' command in the command line
 */
const File File::which(const char *envName, const char *filename)
{
    const char *env = getenv(envName);
    if (!env)
        throw KeyNotFound("Environment variable", envName);

    // split path list and look into every directory of the list
    std::vector<std::string> paths;
    for (auto it : strings::split(env, PATH_LIST_SEP_CHAR, paths))
    {
        File dir(it);
        if (!dir.exists())
            continue;

        File result(dir, filename);
        if (result.exists()) {
            return result;
        }
    }
    throw KeyNotFound("File not found along path", filename);
}
Пример #3
0
boost::any Frontend::any_retrieve_from_hvector(std::vector<HandlerType>& hvector, const std::string& key)
{
  for (auto& x : hvector)
  {
    auto value = x->retrieve(key);
    if (!value.empty()) return value;
  }
  // If the function did not return, then throw an exception
  stringstream estream;
  estream << "ERROR : key \"" << key << "\" not managed by the following handlers : " << endl;
  for (auto& x : hvector)
  {
    estream << x->info() << endl;
  }
  throw KeyNotFound(estream.str());
}