Skip to content
Snippets Groups Projects
toolbox.cpp 706 B
#include <fstream>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

vector<string> loadSerialsFromFileName(string m_fileName, bool m_debug = false) {
    ifstream in(m_fileName.c_str());
    if (!in.good()) {
        cerr << "Could not load serials. Does the input file exist?" << endl;
        exit(0);
    }

    vector<string> result;
    result.clear();

    string line = "";
    while (in.good()) {
        getline(in,line);
        if (line.length() == 0 || !isdigit(line[0])) continue;
        result.push_back(line);
        if (m_debug) cout << "Found serial: " << line << endl;
    }
    cerr << "Found " << result.size() << " APDs" << endl;
    return result;
}