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