33 bool validFile = file.is_open();
36 {
throw RBDSException(
"Cannot open file \"" + fileName +
"\"");}
38 {std::cout <<
"LoadBins> loading \"" << fileName <<
"\"" << std::endl;}
41 std::vector<double>* result =
new std::vector<double>();
43 while (std::getline(file, line))
45 std::istringstream liness(line);
48 if (std::all_of(line.begin(), line.end(), isspace))
52 if (!(liness >> binEdge))
53 {
throw RBDSException(
"invalid bin edge on line " + std::to_string(lineNum) +
"\n\"" + line +
"\"\nCannot convert to a double.");}
54 result->push_back(binEdge);
58 std::string remainder;
60 std::string message =
"Error: extra text \"" + remainder +
"\" on line " + std::to_string(lineNum) +
" of bin edges file \"" + fileName +
"\"";
67 if (result->size() < 2)
68 {
throw RBDSException(
"insufficient number of bins in file - must be at least 2");}