Skip to content
Snippets Groups Projects
makeseriallist.cxx 1.1 KiB
Newer Older
Jan Reher's avatar
Jan Reher committed
#include "serialListReader.h"
#include "QtCore/QCoreApplication"
#include <vector>
#include <string>
#include <iostream>

using namespace std;

int main(int argc, char *argv[]) {
  if (argc != 3) {
    cerr << "Too few or too many parameters!" << endl;
    return 1;
  }
  QCoreApplication *_app = new QCoreApplication(argc,argv);
  serialListReader *_reader = new serialListReader(false);

  vector<string> serialListString = _reader->getFullList();
  vector<unsigned int> serialList;
  serialList.clear();

  for ( size_t i = 0 ; i < serialListString.size() ; i++) serialList.push_back( stoul( serialListString[i] ) );
  if ( serialListString.size() != serialList.size() ) {
    cerr << "ERROR: Sizes don't match!" << endl;
    return 1;
  }

  unsigned int serialMin = stoul(argv[1]);
  unsigned int serialMax = stoul(argv[2]);
  int numOut = 0;
  for ( size_t i = 0 ; i < serialList.size() ; i++) {
    if ( serialList [i] >= serialMin && serialList [i] <= serialMax ) {
      cout << serialListString[i] << endl;
      numOut++;
    }
  }
  cerr << "Found " << numOut << " APDs in the given range." << endl;
  return 0;
}