1 #ifndef DBALLE_CMDLINE_PROCESSOR_H
2 #define DBALLE_CMDLINE_PROCESSOR_H
4 #include <dballe/importer.h>
5 #include <dballe/exporter.h>
6 #include <dballe/msg/msg.h>
11 #define DBALLE_JSON_VERSION "0.1"
41 const std::string& filename,
43 const std::string& msg)
44 : filename(filename), index(index)
46 initmsg(filename, index, msg.c_str());
58 const std::string& filename,
60 const std::exception& original)
61 : filename(filename), index(index)
63 initmsg(filename, index, original.what());
76 const std::string& filename,
78 const std::string& msg,
79 const std::exception& original)
80 : filename(filename), index(index)
82 initmsg(filename, index, msg.c_str());
84 this->msg += original.what();
89 virtual const char* what()
const throw ()
95 void initmsg(
const std::string& fname,
unsigned index,
const char* msg);
103 std::vector<std::shared_ptr<Message>>* msgs;
112 void set_msgs(std::vector<std::shared_ptr<Message>>* new_msgs);
121 virtual bool operator()(
const Item& item) = 0;
126 std::vector<std::pair<int, int>> ranges;
128 void parse(
const std::string& str);
130 bool match(
int val)
const;
136 int subcategory = -1;
140 const char* index_filter =
nullptr;
141 const char* input_type =
"auto";
142 const char* fail_file_name =
nullptr;
149 int subcategory = -1;
160 void set_index_filter(
const std::string& val);
168 bool match_index(
int idx)
const;
169 bool match_common(
const BinaryMessage& rmsg,
const std::vector<std::shared_ptr<dballe::Message>>* msgs)
const;
170 bool match_msgs(
const std::vector<std::shared_ptr<dballe::Message>>& msgs)
const;
174 bool match_item(
const Item& item)
const;
180 std::string input_type;
181 const char* fail_file_name;
183 void read_csv(
const std::list<std::string>& fnames,
Action& action);
184 void read_json(
const std::list<std::string>& fnames,
Action& action);
185 void read_file(
const std::list<std::string>& fnames,
Action& action);
190 bool verbose =
false;
191 unsigned count_successes = 0;
192 unsigned count_failures = 0;
196 bool has_fail_file()
const;
198 void read(
const std::list<std::string>& fnames,
Action& action);