31#include <boost/algorithm/string.hpp>
32#include <boost/lexical_cast.hpp>
46 if (dataset_name ==
"") {
52 while (line.empty() && sfile.
good()) {
58 if (regex::regex_match(line, s_match, expression)) {
59 dataset_name = s_match[1].
str();
80 std::string reg_ex_str =
"^\\s*#\\s*" + key_word +
"\\s*:\\s*(.+)\\s*$";
83 while (sfile.
good()) {
86 if (!line.empty() && regex::regex_match(line, s_match, expression)) {
108 auto table =
Table::AsciiReader{sfile}.fixColumnTypes({
typeid(double),
typeid(
double)}).read();
112 return std::make_pair(boost::get<double>(row[0]), boost::get<double>(row[1]));
114 dataset_ptr = make_unique<XYDataset>(
std::move(vector_pair));
121 bool is_a_dataset_file =
false;
130 while ((line.empty() || regex::regex_match(line, s_match, expression)) && sfile.
good()) {
140 ss >> d1 >> d2 >> empty_string;
141 boost::lexical_cast<double>(d1);
142 boost::lexical_cast<double>(d2);
143 if (!empty_string.
empty()) {
144 is_a_dataset_file =
false;
146 is_a_dataset_file =
true;
149 is_a_dataset_file =
false;
153 return is_a_dataset_file;
TableReader implementation for reading ASCII tables from streams.
Represents one row of a Table.
std::string getParameter(const std::string &file, const std::string &key_word) override
Get the parameter identified by a given key_word value from a file.
bool isDatasetFile(const std::string &file) override
Check that the ASCII file is a dataset file(with at least one line with 2 double values)
std::unique_ptr< XYDataset > getDataset(const std::string &file) override
Get a XYDataset object reading data from an ASCII file.
std::string getName(const std::string &file) override
Get the dataset name of a ASCII file.
std::string removeExtension(const std::string &input_str)
std::string removeAllBeforeLastSlash(const std::string &input_str)