1#ifndef DBALLE_CMDLINE_PROCESSOR_H
2#define DBALLE_CMDLINE_PROCESSOR_H
4#include <dballe/exporter.h>
5#include <dballe/importer.h>
6#include <dballe/msg/msg.h>
11#define DBALLE_JSON_VERSION "0.1"
41 const std::string& msg)
42 : filename(filename), index(index)
44 initmsg(filename, index, msg.c_str());
56 const std::exception& original)
57 : filename(filename), index(index)
59 initmsg(filename, index, original.what());
72 const std::string& msg,
const std::exception& original)
73 : filename(filename), index(index)
75 initmsg(filename, index, msg.c_str());
77 this->msg += original.what();
82 const char* what() const noexcept
override {
return msg.c_str(); }
85 void initmsg(
const std::string& fname,
unsigned index,
const char* msg);
93 std::vector<std::shared_ptr<Message>>* msgs;
102 void set_msgs(std::vector<std::shared_ptr<Message>>* new_msgs);
111 virtual bool operator()(
const Item& item) = 0;
116 std::vector<std::pair<int, int>> ranges;
118 void parse(
const std::string& str);
120 bool match(
int val)
const;
126 int subcategory = -1;
130 const char* index_filter =
nullptr;
131 const char* input_type =
"auto";
132 const char* fail_file_name =
nullptr;
139 int subcategory = -1;
150 void set_index_filter(
const std::string& val);
158 bool match_index(
int idx)
const;
161 const std::vector<std::shared_ptr<dballe::Message>>* msgs)
const;
163 match_msgs(
const std::vector<std::shared_ptr<dballe::Message>>& msgs)
const;
166 const std::vector<std::shared_ptr<dballe::Message>>* msgs)
const;
169 const std::vector<std::shared_ptr<dballe::Message>>* msgs)
const;
172 const std::vector<std::shared_ptr<dballe::Message>>* msgs)
const;
175 const std::vector<std::shared_ptr<dballe::Message>>* msgs)
const;
176 bool match_item(
const Item& item)
const;
182 std::string input_type;
183 const char* fail_file_name;
185 void read_csv(
const std::list<std::string>& fnames,
Action& action);
186 void read_json(
const std::list<std::string>& fnames,
Action& action);
187 void read_file(
const std::list<std::string>& fnames,
Action& action);
192 bool verbose =
false;
193 unsigned count_successes = 0;
194 unsigned count_failures = 0;
198 bool has_fail_file()
const;
200 void read(
const std::list<std::string>& fnames,
Action& action);
Binary message.
Definition file.h:135
Message importer interface.
Definition importer.h:69
Query used to filter DB-All.e data.
Definition query.h:17
Match DB-All.e objects using the same queries that can be made on DB-All.e databases.
Definition matcher.h:93
Definition processor.h:109
Definition processor.h:136
void matcher_reset()
Reset to the empty matcher.
void matcher_from_record(const Query &query)
Initialise the matcher from a record.
Definition processor.h:115
Definition processor.h:89
void processing_failed(std::exception &e) const __attribute__((noreturn))
Throw a ProcessingException based on e.
void decode(Importer &imp, bool print_errors=false)
Decode all that can be decoded.
void set_msgs(std::vector< std::shared_ptr< Message > > *new_msgs)
Set the value of msgs, possibly replacing the previous one.
Exception used to embed processing issues that mean that processing of the current element can safely...
Definition processor.h:28
ProcessingException(const std::string &filename, unsigned index, const std::string &msg)
Create a new exception.
Definition processor.h:40
ProcessingException(const std::string &filename, unsigned index, const std::string &msg, const std::exception &original)
Create a new exception.
Definition processor.h:71
ProcessingException(const std::string &filename, unsigned index, const std::exception &original)
Create a new exception.
Definition processor.h:55
Definition processor.h:124
ExporterOptions with default constructor usable.
Definition msg.h:39
ImporterOptions with default constructor usable.
Definition msg.h:26