Exemplo n.º 1
0
std::map < int, int > loadIntMap(const std::string & filename){
    std::map < int, int > aMap;

    std::fstream file; if (!openInFile(filename, & file)){
        std::cerr << WHERE_AM_I << " Map not found: " << filename << std::endl;
        return aMap;
    }

    std::vector < std::string > row;
    while (! file.eof()) {
        row = getNonEmptyRow(file);
        if (row.size() == 2) aMap[toInt(row[0])] = toInt(row[1]);
    }

    file.close();
    return aMap;
}
Exemplo n.º 2
0
Arquivo: pos.cpp Projeto: wk1984/gimli
std::vector < RVector3 > loadRVector3(const std::string & fileName){
    std::vector < RVector3 > l;
    std::fstream file; openInFile(fileName, & file, true);
    std::vector < std::string > row;

    while (! file.eof()){
        row = getNonEmptyRow(file);
        switch (row.size()){
            case 1 : l.push_back(RVector3(toDouble(row[0]), 0.0, 0.0)); break;
            case 2 : l.push_back(RVector3(toDouble(row[0]), toDouble(row[1]), 0.0)); break;
            case 3 : l.push_back(RVector3(toDouble(row[0]), toDouble(row[1]),
                                    toDouble(row[2]))); break;
        }
    }
    file.close();
    return l;
}
Exemplo n.º 3
0
std::map < float, float > loadFloatMap(const std::string & filename){
    std::map < float, float > aMap;

    std::fstream file; if (!openInFile(filename, & file)){
        std::cerr << WHERE_AM_I << " Map not found: " << filename << std::endl;
        return aMap;
    }

    std::vector < std::string > row;
    while (!file.eof()) {
        row = getNonEmptyRow(file);
        if (row.size() == 2){
            aMap[toFloat(row[0])] = toFloat(row[1]);
        } else {
            if (aMap.size() == 0){
                throwError(1, "no proper format found for map <float, Complex> in " + filename  + " " + str(row.size()) );
            }
        }
    }

    file.close();
    return aMap;
}