-
Notifications
You must be signed in to change notification settings - Fork 7
Expand file tree
/
Copy pathdbc.hpp
More file actions
73 lines (54 loc) · 1.72 KB
/
dbc.hpp
File metadata and controls
73 lines (54 loc) · 1.72 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
#ifndef DBC_HPP
#define DBC_HPP
#include <cstdint>
#include <istream>
#include <libdbc/message.hpp>
#include <regex>
#include <string>
#include <vector>
#if __cplusplus >= 201703L
#include <filesystem>
#endif // __cplusplus >= 201703L
namespace Libdbc {
class Parser {
public:
virtual ~Parser() = default;
virtual void parse_file(const std::string& file) = 0;
virtual void parse_file(std::istream& file) = 0;
protected:
};
class DbcParser : public Parser {
public:
DbcParser();
void parse_file(const std::string& file_name) override;
void parse_file(std::istream& stream) override;
const std::string& get_version() const;
const std::vector<std::string>& get_nodes() const;
const std::vector<Libdbc::Message>& get_messages() const;
Message::ParseSignalsStatus parse_message(uint32_t message_id, const std::vector<uint8_t>& data, std::vector<double>& out_values) const;
const std::vector<std::string>& unused_lines() const;
#if __cplusplus >= 201703L
static void validate_dbc_file(const std::filesystem::path&);
#else
static void validate_dbc_file(const std::string&);
#endif // __cplusplus >= 201703L
static void validate_dbc_file(std::istream& stream);
private:
std::string version{};
std::vector<std::string> nodes{};
std::vector<Libdbc::Message> messages{};
std::regex version_re;
std::regex bit_timing_re;
std::regex name_space_re;
std::regex node_re;
std::regex message_re;
std::regex value_re;
std::regex signal_re;
std::vector<std::string> missed_lines{};
void parse_dbc_header(std::istream& file_stream);
void parse_dbc_nodes(std::istream& file_stream);
void parse_dbc_messages(const std::vector<std::string>& lines);
static std::string get_extension(const std::string& file_name);
};
}
#endif // DBC_HPP