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 const char* what() const noexcept
override 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_json(
const BinaryMessage& rmsg,
const std::vector<std::shared_ptr<dballe::Message>>* msgs)
const;
175 bool match_item(
const Item& item)
const;
181 std::string input_type;
182 const char* fail_file_name;
184 void read_csv(
const std::list<std::string>& fnames,
Action& action);
185 void read_json(
const std::list<std::string>& fnames,
Action& action);
186 void read_file(
const std::list<std::string>& fnames,
Action& action);
191 bool verbose =
false;
192 unsigned count_successes = 0;
193 unsigned count_failures = 0;
197 bool has_fail_file()
const;
199 void read(
const std::list<std::string>& fnames,
Action& action);
Definition: processor.h:124
Binary message.
Definition: file.h:130
void decode(Importer &imp, bool print_errors=false)
Decode all that can be decoded.
Definition: processor.h:118
Message importer interface.
Definition: importer.h:71
void processing_failed(std::exception &e) const __attribute__((noreturn))
Throw a ProcessingException based on e.
Definition: processor.h:178
void matcher_reset()
Reset to the empty matcher.
ProcessingException(const std::string &filename, unsigned index, const std::string &msg, const std::exception &original)
Create a new exception.
Definition: processor.h:75
Definition: processor.h:145
void set_msgs(std::vector< std::shared_ptr< Message >> *new_msgs)
Set the value of msgs, possibly replacing the previous one.
Definition: processor.h:98
Match DB-All.e objects using the same queries that can be made on DB-All.e databases.
Definition: matcher.h:90
ImporterOptions with default constructor usable.
Definition: msg.h:25
ProcessingException(const std::string &filename, unsigned index, const std::exception &original)
Create a new exception.
Definition: processor.h:57
Definition: processor.h:133
void matcher_from_record(const Query &query)
Initialise the matcher from a record.
ExporterOptions with default constructor usable.
Definition: msg.h:38
Exception used to embed processing issues that mean that processing of the current element can safely...
Definition: processor.h:27
Query used to filter DB-All.e data.
Definition: query.h:14
ProcessingException(const std::string &filename, unsigned index, const std::string &msg)
Create a new exception.
Definition: processor.h:40