|
6 | 6 |
|
7 | 7 | namespace libdbc { |
8 | 8 |
|
9 | | - Message::Message(uint32_t id, const std::string& name, uint8_t size, const std::string& node) : |
10 | | - id(id), name(name), size(size), node(node) {} |
11 | | - |
12 | | - bool Message::operator==(const Message& rhs) const { |
13 | | - return (this->id == rhs.id) && (this->name == rhs.name) && |
14 | | - (this->size == rhs.size) && (this->node == rhs.node); |
15 | | - } |
16 | | - |
17 | | - std::ostream& operator<< (std::ostream &out, const Message& msg) { |
18 | | - out << "Message: {id: " << msg.id << ", "; |
19 | | - out << "name: " << msg.name << ", "; |
20 | | - out << "size: " << msg.size << ", "; |
21 | | - out << "node: " << msg.node << "}"; |
22 | | - return out; |
23 | | - } |
24 | | - |
25 | | - |
26 | | - Signal::Signal(std::string name, bool is_multiplexed, uint32_t start_bit, uint32_t size, bool is_bigendian, bool is_signed, double factor, double offset, double min, double max, std::string unit, std::vector<std::string> receivers) : |
27 | | - name(name), is_multiplexed(is_multiplexed), start_bit(start_bit), size(size), is_bigendian(is_bigendian), is_signed(is_signed), offset(offset), min(min), max(max), unit(unit), receivers(receivers) {} |
28 | | - |
29 | | - bool Signal::operator==(const Signal& rhs) const { |
30 | | - return (this->name == rhs.name) && (this->is_multiplexed == rhs.is_multiplexed) && |
31 | | - (this->start_bit == rhs.start_bit) && (this->size == rhs.size) && |
32 | | - (this->is_bigendian == rhs.is_bigendian) && (this->is_signed == rhs.is_signed) && |
33 | | - (this->offset == rhs.offset) && (this->min == rhs.min) && (this->max == rhs.max) && |
34 | | - (this->unit == rhs.unit) && (this->receivers == rhs.receivers); |
35 | | - } |
36 | | - |
37 | | - |
38 | | - std::ostream& operator<< (std::ostream &out, const Signal& sig) { |
39 | | - out << "Signal {name: " << sig.name << ", "; |
40 | | - out << "Multiplexed: " << (sig.is_multiplexed ? "True" : "False") << ", "; |
41 | | - out << "Start bit: " << sig.start_bit << ", "; |
42 | | - out << "Size: " << sig.size << ", "; |
43 | | - out << "Endianness: " << (sig.is_bigendian ? "Big endian" : "Little endian") << ", "; |
44 | | - out << "Value Type: " << (sig.is_signed ? "Signed" : "Unsigned") << ", "; |
45 | | - out << "Min: " << sig.min << ", Max: " << sig.max << ", "; |
46 | | - out << "Unit: (" << sig.unit << "), "; |
47 | | - out << "receivers: "; |
48 | | - for(const auto &r : sig.receivers) |
49 | | - out << r; |
50 | | - return out << "}"; |
51 | | - } |
52 | | - |
53 | | - |
54 | 9 | DbcParser::DbcParser() : version(""), nodes(), |
55 | 10 | version_re("^(VERSION)\\s\"(.*)\""), bit_timing_re("^(BS_:)"), |
56 | 11 | name_space_re("^(NS_)\\s\\:"), node_re("^(BU_:)\\s((?:[\\w]+?\\s?)*)"), |
|
0 commit comments