26 #include <boost/regex.hpp> 27 #include <boost/algorithm/string.hpp> 32 #include "boost/lexical_cast.hpp" 40 using boost::regex_match;
50 std::ifstream sfile(file);
57 std::string dataset_name{};
60 while (line.empty() && sfile.good()) {
61 std::getline(sfile, line);
65 boost::smatch s_match;
66 if (boost::regex_match(line, s_match, expression)) {
67 dataset_name = s_match[1].str();
81 std::ifstream sfile(file);
88 std::string dataset_name{};
89 std::string reg_ex_str =
"^\\s*#\\s*" + key_word +
"\\s+(\\w+)\\s*$";
90 boost::regex expression(reg_ex_str);
92 while (sfile.good()) {
93 std::getline(sfile, line);
94 boost::smatch s_match;
95 if (!line.empty() && boost::regex_match(line, s_match, expression)) {
97 size_t start_position = line.find(key_word)+key_word.length();
98 value = line.substr (start_position);
111 std::unique_ptr<XYDataset> dataset_ptr {};
112 std::ifstream sfile(file);
118 std::vector<std::pair<double, double>> vector_pair;
119 for (
auto row : table) {
120 vector_pair.push_back(std::make_pair( boost::get<double>(row[0]), boost::get<double>(row[1]) ));
122 dataset_ptr = std::unique_ptr<XYDataset> {
new XYDataset(vector_pair) };
129 bool is_a_dataset_file =
false;
130 std::ifstream sfile(file);
136 boost::regex expression(
"\\s*#.*");
137 boost::smatch s_match;
138 while ((line.empty() || boost::regex_match(line, s_match, expression)) && sfile.good()) {
139 std::getline(sfile, line);
144 std::stringstream ss(line);
145 std::string empty_string{};
147 ss >> d1 >> d2 >> empty_string;
148 boost::lexical_cast<
double>(d1);
149 boost::lexical_cast<
double>(d2);
150 if (!empty_string.empty()){
151 is_a_dataset_file =
false;
154 is_a_dataset_file =
true;
158 is_a_dataset_file =
false;
162 return is_a_dataset_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::string removeAllBeforeLastSlash(const std::string &input_str)
std::string getName(const std::string &file) override
Get the dataset name of a ASCII file.
std::unique_ptr< XYDataset > getDataset(const std::string &file) override
Get a XYDataset object reading data from an ASCII file.
TableReader implementation for reading ASCII tables from streams.
AsciiReader & fixColumnTypes(std::vector< std::type_index > column_types)
Overrides the automatically detected column types.
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.
std::string removeExtension(const std::string &input_str)
This module provides an interface for accessing two dimensional datasets (pairs of (X...