dbc  ..
dbc.hpp
1 
2 #ifndef __DBC_HPP__
3 #define __DBC_HPP__
4 
5 #include <libdbc/exceptions/error.hpp>
6 #include <libdbc/message.hpp>
7 #include <libdbc/signal.hpp>
8 #include <libdbc/utils/utils.hpp>
9 
10 #include <regex>
11 
12 namespace libdbc {
13 
14 class Parser {
15 public:
16  virtual ~Parser() = default;
17 
18  virtual void parse_file(const std::string& file) = 0;
19 
20 protected:
21 };
22 
23 class DbcParser : public Parser {
24 public:
25  DbcParser();
26 
27  virtual ~DbcParser() = default;
28 
29  virtual void parse_file(const std::string& file) final override;
30 
31  std::string get_version() const;
32  std::vector<std::string> get_nodes() const;
33  std::vector<libdbc::Message> get_messages() const;
34 
35  Message::ParseSignalsStatus parseMessage(const uint32_t id, const std::vector<uint8_t>& data, std::vector<double>& out_values);
36 
37 private:
38  std::string version;
39  std::vector<std::string> nodes;
40  std::vector<libdbc::Message> messages;
41 
42  const std::regex version_re;
43  const std::regex bit_timing_re;
44  const std::regex name_space_re;
45  const std::regex node_re;
46  const std::regex message_re;
47  const std::regex signal_re;
48 
49  void parse_dbc_header(std::istream& file_stream);
50  void parse_dbc_nodes(std::istream& file_stream);
51  void parse_dbc_messages(const std::vector<std::string>& lines);
52 };
53 
54 }
55 
56 #endif // __DBC_HPP__
Definition: dbc.hpp:23
Definition: dbc.hpp:14