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