19#include "BinLoader.hh"
20#include "RBDSException.hh"
34 bool validFile = file.is_open();
37 {
throw RBDSException(
"Cannot open file \"" + fileName +
"\"");}
39 {std::cout <<
"LoadBins> loading \"" << fileName <<
"\"" << std::endl;}
42 std::vector<double>* result =
new std::vector<double>();
44 while (std::getline(file, line))
46 std::istringstream liness(line);
49 if (std::all_of(line.begin(), line.end(), isspace))
53 if (!(liness >> binEdge))
54 {
throw RBDSException(
"invalid bin edge on line " + std::to_string(lineNum) +
"\n\"" + line +
"\"\nCannot convert to a double.");}
55 result->push_back(binEdge);
59 std::string remainder;
61 std::string message =
"Error: extra text \"" + remainder +
"\" on line " + std::to_string(lineNum) +
" of bin edges file \"" + fileName +
"\"";
68 if (result->size() < 2)
69 {
throw RBDSException(
"insufficient number of bins in file - must be at least 2");}
General exception with possible name of object and message.
std::vector< double > * LoadBins(const std::string &fileName)
Method to load a single column text file and return vector of values.