From 6ab9cd78d426f923b2ffecd8166c8c7f84da2c7c Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Thu, 16 Feb 2023 17:54:30 +0100 Subject: [PATCH 001/131] Parsing VAL attributes and assigning it to the signals --- include/libdbc/message.hpp | 3 +- include/libdbc/signal.hpp | 6 ++ src/dbc.cpp | 132 +++++++++++++++++++++++++++++++++++++ src/message.cpp | 11 +++- test/test_dbc.cpp | 114 ++++++++++++++++++++++++++++---- 5 files changed, 253 insertions(+), 13 deletions(-) diff --git a/include/libdbc/message.hpp b/include/libdbc/message.hpp index 90a1dc1..c69d605 100644 --- a/include/libdbc/message.hpp +++ b/include/libdbc/message.hpp @@ -29,8 +29,9 @@ struct Message { ParseSignalsStatus parseSignals(const std::vector& data, std::vector& values) const; void appendSignal(const Signal& signal); - const std::vector signals() const; + const std::vector& getSignals() const; uint32_t id() const; + void addValueDescription(const std::string& signal_name, const std::vector&); virtual bool operator==(const Message& rhs) const; diff --git a/include/libdbc/signal.hpp b/include/libdbc/signal.hpp index 30178de..f41cef6 100644 --- a/include/libdbc/signal.hpp +++ b/include/libdbc/signal.hpp @@ -8,6 +8,11 @@ namespace libdbc { struct Signal { + struct SignalValueDescriptions { + uint32_t value; + std::string description; + }; + std::string name; bool is_multiplexed; uint32_t start_bit; @@ -20,6 +25,7 @@ struct Signal { double max; std::string unit; std::vector receivers; + std::vector svDescriptions; Signal() = delete; explicit Signal(std::string name, diff --git a/src/dbc.cpp b/src/dbc.cpp index c091408..996de29 100644 --- a/src/dbc.cpp +++ b/src/dbc.cpp @@ -25,6 +25,119 @@ const auto unitPattern = "\"(.*)\""; // Random string const auto receiverPattern = "([\\w\\,]+|Vector__XXX)*"; const auto whiteSpace = "\\s"; +enum VALToken { Identifier = 0, CANId, SignalName, Value, Description }; + +struct VALObject { + uint32_t can_id; + std::string signal_name; + std::vector vd; +}; + +bool parseVal(const std::string& str, VALObject& obj) { + obj.signal_name = ""; + obj.vd.clear(); + auto state = Identifier; + const char* a = str.data(); + libdbc::Signal::SignalValueDescriptions vd; + for (;;) { + switch (state) { + case Identifier: { + if (*a != 'V') + return false; + a++; + if (*a != 'A') + return false; + a++; + if (*a != 'L') + return false; + a++; + if (*a != '_') + return false; + a++; + if (*a != ' ') + return false; + a++; // skip whitespace + state = CANId; + break; + } + case CANId: { + std::string can_id_str; + while (*a >= '0' && *a <= '9') { + can_id_str += *a; + a++; + } + if (can_id_str.empty()) + return false; + obj.can_id = std::stoul(can_id_str); + if (*a != ' ') + return false; + a++; // skip whitespace + state = SignalName; + break; + } + case SignalName: { + if ((*a >= 'a' && *a <= 'z') || (*a >= 'A' && *a <= 'Z') || *a == '_') + obj.signal_name += *a; + else + return false; + a++; + while ((*a >= 'a' && *a <= 'z') || (*a >= 'A' && *a <= 'Z') || *a == '_' || (*a >= '0' && *a <= '9')) { + obj.signal_name += *a; + a++; + } + if (*a != ' ') + return false; + a++; // skip whitespace + state = Value; + break; + } + case Value: { + std::string value_str; + while (*a >= '0' && *a <= '9') { + value_str += *a; + a++; + } + if (*a == ';') { + if (value_str.empty()) + return true; + return false; + } + if (value_str.empty()) + return false; + + if (*a != ' ') + return false; + a++; // skip whitespace + vd.value = (uint32_t)std::stoul(value_str); + state = Description; + break; + } + case Description: { + std::string desc; + if (*a != '"') + return false; + a++; + while (*a != '"' && *a != 0) { + desc += *a; + a++; + } + if (*a == 0) + return false; + a++; + if (*a != ' ') + return false; + a++; // skip whitespace + + vd.description = desc; + obj.vd.push_back(vd); + + state = Value; + break; + } + } + } +} + } // anonymous namespace namespace libdbc { @@ -123,6 +236,9 @@ void DbcParser::parse_dbc_nodes(std::istream& file_stream) { void DbcParser::parse_dbc_messages(const std::vector& lines) { std::smatch match; + std::vector sv; + + VALObject obj; for (const auto& line : lines) { if (std::regex_search(line, match, message_re)) { uint32_t id = std::stoul(match.str(2)); @@ -133,6 +249,7 @@ void DbcParser::parse_dbc_messages(const std::vector& lines) { Message msg(id, name, size, node); messages.push_back(msg); + continue; } if (std::regex_search(line, match, signal_re)) { @@ -158,6 +275,21 @@ void DbcParser::parse_dbc_messages(const std::vector& lines) { Signal sig(name, is_multiplexed, start_bit, size, is_bigendian, is_signed, factor, offset, min, max, unit, receivers); messages.back().appendSignal(sig); + continue; + } + + if (parseVal(line, obj)) { + sv.push_back(obj); + continue; + } + } + + for (const auto& obj : sv) { + for (auto& msg : messages) { + if (msg.id() == obj.can_id) { + msg.addValueDescription(obj.signal_name, obj.vd); + break; + } } } } diff --git a/src/message.cpp b/src/message.cpp index 7a2331b..02f4c05 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -67,7 +67,7 @@ void Message::appendSignal(const Signal& signal) { m_signals.push_back(signal); } -const std::vector Message::signals() const { +const std::vector& Message::getSignals() const { return m_signals; } @@ -75,6 +75,15 @@ uint32_t Message::id() const { return m_id; } +void Message::addValueDescription(const std::string& signal_name, const std::vector& vd) { + for (auto& s : m_signals) { + if (s.name.compare(signal_name) == 0) { + s.svDescriptions = vd; + return; + } + } +} + std::ostream& operator<<(std::ostream& out, const Message& msg) { out << "Message: {id: " << msg.id() << ", "; out << "name: " << msg.m_name << ", "; diff --git a/test/test_dbc.cpp b/test/test_dbc.cpp index 1c218aa..7b7b0d1 100644 --- a/test/test_dbc.cpp +++ b/test/test_dbc.cpp @@ -57,7 +57,7 @@ TEST_CASE("Testing dbc file loading", "[fileio]") { REQUIRE(parser->get_messages() == msgs); - REQUIRE(parser->get_messages().front().signals() == msg.signals()); + REQUIRE(parser->get_messages().front().getSignals() == msg.getSignals()); } } @@ -80,13 +80,13 @@ TEST_CASE("Testing big endian, little endian") { parser.parse_file(filename); REQUIRE(parser.get_messages().size() == 1); - REQUIRE(parser.get_messages().at(0).signals().size() == 2); + REQUIRE(parser.get_messages().at(0).getSignals().size() == 2); { - const auto signal = parser.get_messages().at(0).signals().at(0); + const auto signal = parser.get_messages().at(0).getSignals().at(0); REQUIRE(signal.is_bigendian == true); } { - const auto signal = parser.get_messages().at(0).signals().at(1); + const auto signal = parser.get_messages().at(0).getSignals().at(1); REQUIRE(signal.is_bigendian == false); } } @@ -104,31 +104,31 @@ TEST_CASE("Testing negative values") { parser.parse_file(filename); REQUIRE(parser.get_messages().size() == 1); - REQUIRE(parser.get_messages().at(0).signals().size() == 4); + REQUIRE(parser.get_messages().at(0).getSignals().size() == 4); SECTION("Evaluating first message") { - const auto signal = parser.get_messages().at(0).signals().at(0); + const auto signal = parser.get_messages().at(0).getSignals().at(0); REQUIRE(signal.factor == 0.1); REQUIRE(signal.offset == 0); REQUIRE(signal.min == -3276.8); REQUIRE(signal.max == -3276.7); } SECTION("Evaluating second message") { - const auto signal = parser.get_messages().at(0).signals().at(1); + const auto signal = parser.get_messages().at(0).getSignals().at(1); REQUIRE(signal.factor == 0.1); REQUIRE(signal.offset == 0); REQUIRE(signal.min == -3276.8); REQUIRE(signal.max == -3276.7); } SECTION("Evaluating third message") { - const auto signal = parser.get_messages().at(0).signals().at(2); + const auto signal = parser.get_messages().at(0).getSignals().at(2); REQUIRE(signal.factor == 10); REQUIRE(signal.offset == 0); REQUIRE(signal.min == -3276.8); REQUIRE(signal.max == -3276.7); } SECTION("Evaluating fourth message") { - const auto signal = parser.get_messages().at(0).signals().at(3); + const auto signal = parser.get_messages().at(0).getSignals().at(3); REQUIRE(signal.factor == 1); REQUIRE(signal.offset == -10); REQUIRE(signal.min == 0); @@ -146,9 +146,101 @@ TEST_CASE("Special characters in unit") { parser.parse_file(filename); REQUIRE(parser.get_messages().size() == 1); - REQUIRE(parser.get_messages().at(0).signals().size() == 1); + REQUIRE(parser.get_messages().at(0).getSignals().size() == 1); SECTION("Checking that signal with special characters as unit is parsed correctly") { - const auto signal = parser.get_messages().at(0).signals().at(0); + const auto signal = parser.get_messages().at(0).getSignals().at(0); REQUIRE(signal.unit.compare("Km/h") == 0); } } + +TEST_CASE("Signal Value Description") { + const auto* filename = std::tmpnam(NULL); + + create_tmp_dbc_with(filename, R"(BO_ 234 MSG1: 8 Vector__XXX + SG_ State1 : 0|8@1+ (1,0) [0|200] "Km/h" DEVICE1,DEVICE2,DEVICE3 + SG_ State2 : 0|8@1+ (1,0) [0|204] "" DEVICE1,DEVICE2,DEVICE3 +VAL_ 234 State1 123 "Description 1" 0 "Description 2" 90903489 "Big value and special characters &$§())!" ;)"); + + auto parser = libdbc::DbcParser(); + parser.parse_file(filename); + + REQUIRE(parser.get_messages().size() == 1); + REQUIRE(parser.get_messages().at(0).getSignals().size() == 2); + + REQUIRE(parser.get_messages().at(0).getSignals().at(0).svDescriptions.size() == 3); + REQUIRE(parser.get_messages().at(0).getSignals().at(1).svDescriptions.size() == 0); + + const auto signal = parser.get_messages().at(0).getSignals().at(0); + REQUIRE(signal.svDescriptions.at(0).value == 123); + REQUIRE(signal.svDescriptions.at(0).description == "Description 1"); + REQUIRE(signal.svDescriptions.at(1).value == 0); + REQUIRE(signal.svDescriptions.at(1).description == "Description 2"); + REQUIRE(signal.svDescriptions.at(2).value == 90903489); + REQUIRE(signal.svDescriptions.at(2).description == "Big value and special characters &$§())!"); +} + +TEST_CASE("Signal Value Description Extended CAN id") { + /* + * It should not crash, even extended CAN id is used + */ + const auto* filename = std::tmpnam(NULL); + + create_tmp_dbc_with(filename, R"(BO_ 3221225472 MSG1: 8 Vector__XXX + SG_ State1 : 0|8@1+ (1,0) [0|200] "Km/h" DEVICE1,DEVICE2,DEVICE3 + SG_ State2 : 0|8@1+ (1,0) [0|204] "" DEVICE1,DEVICE2,DEVICE3 +VAL_ 3221225472 State1 123 "Description 1" 0 "Description 2" 4000000000 "Big value and special characters &$§())!" ;)"); + + auto parser = libdbc::DbcParser(); + parser.parse_file(filename); + + REQUIRE(parser.get_messages().size() == 1); + REQUIRE(parser.get_messages().at(0).getSignals().size() == 2); + + REQUIRE(parser.get_messages().at(0).getSignals().at(0).svDescriptions.size() == 3); + REQUIRE(parser.get_messages().at(0).getSignals().at(1).svDescriptions.size() == 0); + + const auto signal = parser.get_messages().at(0).getSignals().at(0); + REQUIRE(signal.svDescriptions.at(0).value == 123); + REQUIRE(signal.svDescriptions.at(0).description == "Description 1"); + REQUIRE(signal.svDescriptions.at(1).value == 0); + REQUIRE(signal.svDescriptions.at(1).description == "Description 2"); + REQUIRE(signal.svDescriptions.at(2).value == 4000000000); + REQUIRE(signal.svDescriptions.at(2).description == "Big value and special characters &$§())!"); +} + +TEST_CASE("Signal Value Multiple VAL_") { + /* + * It should not crash, even extended CAN id is used + */ + const auto* filename = std::tmpnam(NULL); + + create_tmp_dbc_with(filename, R"(BO_ 3221225472 MSG1: 8 Vector__XXX + SG_ State1 : 0|8@1+ (1,0) [0|200] "Km/h" DEVICE1,DEVICE2,DEVICE3 + SG_ State2 : 0|8@1+ (1,0) [0|204] "" DEVICE1,DEVICE2,DEVICE3" +BO_ 123 MSG1: 8 Vector__XXX + SG_ State1 : 0|8@1+ (1,0) [0|200] "Km/h" DEVICE1,DEVICE2,DEVICE3 + SG_ State2 : 0|8@1+ (1,0) [0|204] "" DEVICE1,DEVICE2,DEVICE3 +VAL_ 3221225472 State1 123 "Description 1" 0 "Description 2" +VAL_ 123 State1 123 "Description 3" 0 "Description 4")"); + + auto parser = libdbc::DbcParser(); + parser.parse_file(filename); + + REQUIRE(parser.get_messages().size() == 1); + REQUIRE(parser.get_messages().at(0).getSignals().size() == 2); + + REQUIRE(parser.get_messages().at(0).getSignals().at(0).svDescriptions.size() == 2); + REQUIRE(parser.get_messages().at(0).getSignals().at(1).svDescriptions.size() == 2); + + const auto signal = parser.get_messages().at(0).getSignals().at(0); + REQUIRE(signal.svDescriptions.at(0).value == 123); + REQUIRE(signal.svDescriptions.at(0).description == "Description 1"); + REQUIRE(signal.svDescriptions.at(1).value == 0); + REQUIRE(signal.svDescriptions.at(1).description == "Description 2"); + + const auto signal2 = parser.get_messages().at(0).getSignals().at(0); + REQUIRE(signal2.svDescriptions.at(0).value == 123); + REQUIRE(signal2.svDescriptions.at(0).description == "Description 3"); + REQUIRE(signal2.svDescriptions.at(1).value == 0); + REQUIRE(signal2.svDescriptions.at(1).description == "Description 4"); +} From 2c3d82823b2ab4eaece5b6a6a339cbce7df30d94 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Thu, 16 Feb 2023 17:54:55 +0100 Subject: [PATCH 002/131] Description: fix test Reason, in a previous commit a second message was added --- test/test_dbc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_dbc.cpp b/test/test_dbc.cpp index 7b7b0d1..4603556 100644 --- a/test/test_dbc.cpp +++ b/test/test_dbc.cpp @@ -226,7 +226,7 @@ VAL_ 123 State1 123 "Description 3" 0 "Description 4")"); auto parser = libdbc::DbcParser(); parser.parse_file(filename); - REQUIRE(parser.get_messages().size() == 1); + REQUIRE(parser.get_messages().size() == 2); REQUIRE(parser.get_messages().at(0).getSignals().size() == 2); REQUIRE(parser.get_messages().at(0).getSignals().at(0).svDescriptions.size() == 2); @@ -238,7 +238,7 @@ VAL_ 123 State1 123 "Description 3" 0 "Description 4")"); REQUIRE(signal.svDescriptions.at(1).value == 0); REQUIRE(signal.svDescriptions.at(1).description == "Description 2"); - const auto signal2 = parser.get_messages().at(0).getSignals().at(0); + const auto signal2 = parser.get_messages().at(1).getSignals().at(0); REQUIRE(signal2.svDescriptions.at(0).value == 123); REQUIRE(signal2.svDescriptions.at(0).description == "Description 3"); REQUIRE(signal2.svDescriptions.at(1).value == 0); From f9eb28161911a96305b351d9ebc0087d209bcead Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Thu, 16 Feb 2023 17:55:12 +0100 Subject: [PATCH 003/131] add more checks --- test/test_dbc.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/test/test_dbc.cpp b/test/test_dbc.cpp index 4603556..c71ed1d 100644 --- a/test/test_dbc.cpp +++ b/test/test_dbc.cpp @@ -230,7 +230,9 @@ VAL_ 123 State1 123 "Description 3" 0 "Description 4")"); REQUIRE(parser.get_messages().at(0).getSignals().size() == 2); REQUIRE(parser.get_messages().at(0).getSignals().at(0).svDescriptions.size() == 2); - REQUIRE(parser.get_messages().at(0).getSignals().at(1).svDescriptions.size() == 2); + REQUIRE(parser.get_messages().at(0).getSignals().at(1).svDescriptions.size() == 0); + REQUIRE(parser.get_messages().at(1).getSignals().at(0).svDescriptions.size() == 2); + REQUIRE(parser.get_messages().at(1).getSignals().at(1).svDescriptions.size() == 0); const auto signal = parser.get_messages().at(0).getSignals().at(0); REQUIRE(signal.svDescriptions.at(0).value == 123); From 61857a8e1d7b47a55ee6ec9b757b914c3fb34e4e Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Thu, 16 Feb 2023 17:55:35 +0100 Subject: [PATCH 004/131] missing semicolon in the test leads to not reading the line correctly --- test/test_dbc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/test_dbc.cpp b/test/test_dbc.cpp index c71ed1d..9c49888 100644 --- a/test/test_dbc.cpp +++ b/test/test_dbc.cpp @@ -220,8 +220,8 @@ TEST_CASE("Signal Value Multiple VAL_") { BO_ 123 MSG1: 8 Vector__XXX SG_ State1 : 0|8@1+ (1,0) [0|200] "Km/h" DEVICE1,DEVICE2,DEVICE3 SG_ State2 : 0|8@1+ (1,0) [0|204] "" DEVICE1,DEVICE2,DEVICE3 -VAL_ 3221225472 State1 123 "Description 1" 0 "Description 2" -VAL_ 123 State1 123 "Description 3" 0 "Description 4")"); +VAL_ 3221225472 State1 123 "Description 1" 0 "Description 2" ; +VAL_ 123 State1 123 "Description 3" 0 "Description 4" ;)"); auto parser = libdbc::DbcParser(); parser.parse_file(filename); From 531ef66c2a05df06d28e04ff9a50bfc431cf819a Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Thu, 16 Feb 2023 17:55:52 +0100 Subject: [PATCH 005/131] return false if something goes wrong --- src/dbc.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/dbc.cpp b/src/dbc.cpp index 996de29..63043d3 100644 --- a/src/dbc.cpp +++ b/src/dbc.cpp @@ -136,6 +136,7 @@ bool parseVal(const std::string& str, VALObject& obj) { } } } + return false; } } // anonymous namespace From 12ae90fba638db64d6ebb32e8f708cd2690d4867 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Sun, 30 Apr 2023 19:21:00 +0200 Subject: [PATCH 006/131] Do not use reference, because then livetime must be considered --- include/libdbc/message.hpp | 2 +- src/message.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/include/libdbc/message.hpp b/include/libdbc/message.hpp index c69d605..a6613b2 100644 --- a/include/libdbc/message.hpp +++ b/include/libdbc/message.hpp @@ -29,7 +29,7 @@ struct Message { ParseSignalsStatus parseSignals(const std::vector& data, std::vector& values) const; void appendSignal(const Signal& signal); - const std::vector& getSignals() const; + const std::vector getSignals() const; uint32_t id() const; void addValueDescription(const std::string& signal_name, const std::vector&); diff --git a/src/message.cpp b/src/message.cpp index 02f4c05..1739b92 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -67,7 +67,7 @@ void Message::appendSignal(const Signal& signal) { m_signals.push_back(signal); } -const std::vector& Message::getSignals() const { +const std::vector Message::getSignals() const { return m_signals; } From 3f2a88a16837ed25ce5bb21df0633f862c38f564 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Thu, 16 Feb 2023 17:56:32 +0100 Subject: [PATCH 007/131] Description:Add testcase --- test/test_parseMessage.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/test/test_parseMessage.cpp b/test/test_parseMessage.cpp index e171484..a6f2000 100644 --- a/test/test_parseMessage.cpp +++ b/test/test_parseMessage.cpp @@ -141,3 +141,24 @@ TEST_CASE("Parse Message big endian signed values") { REQUIRE(Catch::Approx(result_values.at(10)) == 3.5050); REQUIRE(Catch::Approx(result_values.at(11)) == 21.6); } + +TEST_CASE("Parse Message with non byte aligned values") { + const auto* filename = std::tmpnam(NULL); + create_tmp_dbc_with(filename, R"(BO_ 403 INFORMATION: 8 Vector__XXX + SG_ Voltage : 30|9@1+ (0.2,0) [0|102.2] "V" Vector__XXX + SG_ Phase_Current : 20|10@1- (1,0) [-512|512] "A" Vector__XXX + SG_ Iq_Current : 10|10@1- (1,0) [-512|512] "A" Vector__XXX + SG_ Id_Current : 0|10@1- (1,0) [-512|512] "A" Vector__XXX)"); + + libdbc::DbcParser p; + p.parse_file(filename); + + std::vector data{131, 51, 33, 9, 33, 0, 0, 0}; + std::vector result_values; + REQUIRE(p.parseMessage(545, data, result_values) == libdbc::Message::ParseSignalsStatus::Success); + REQUIRE(result_values.size() == 4); + REQUIRE(Catch::Approx(result_values.at(0)) == 26.4); + REQUIRE(Catch::Approx(result_values.at(1)) == 146); + REQUIRE(Catch::Approx(result_values.at(2)) == 76); + REQUIRE(Catch::Approx(result_values.at(3)) == -125); +} From 6908fb9c2b1b29e0b3208fa6100e6172b7f61adf Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Thu, 16 Feb 2023 17:56:51 +0100 Subject: [PATCH 008/131] Wrong CANid used --- test/test_parseMessage.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/test_parseMessage.cpp b/test/test_parseMessage.cpp index a6f2000..145f4c7 100644 --- a/test/test_parseMessage.cpp +++ b/test/test_parseMessage.cpp @@ -155,7 +155,7 @@ TEST_CASE("Parse Message with non byte aligned values") { std::vector data{131, 51, 33, 9, 33, 0, 0, 0}; std::vector result_values; - REQUIRE(p.parseMessage(545, data, result_values) == libdbc::Message::ParseSignalsStatus::Success); + REQUIRE(p.parseMessage(403, data, result_values) == libdbc::Message::ParseSignalsStatus::Success); REQUIRE(result_values.size() == 4); REQUIRE(Catch::Approx(result_values.at(0)) == 26.4); REQUIRE(Catch::Approx(result_values.at(1)) == 146); From 1e7c7a7073ac403f98d30e36668f539238270842 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Thu, 16 Feb 2023 17:57:08 +0100 Subject: [PATCH 009/131] Implement 2 complement to decimal --- src/message.cpp | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/message.cpp b/src/message.cpp index 1739b92..669ad9b 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -54,8 +54,17 @@ Message::ParseSignalsStatus Message::parseSignals(const std::vector& da case 64: values.push_back((int64_t)v * signal.factor + signal.offset); break; - default: - return ParseSignalsStatus::ErrorInvalidConversion; + default: { + // 2 complement -> decimal + const int negative = (v & (1 << (signal.size - 1))) != 0; + int64_t nativeInt; + if (negative) + nativeInt = v | ~((1 << signal.size) - 1); + else + nativeInt = v; + values.push_back(nativeInt * signal.factor + signal.offset); + break; + } } } else values.push_back(v * signal.factor + signal.offset); From a83a44849e828034145fdb87dc0e113a59f686e3 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Thu, 16 Feb 2023 17:57:26 +0100 Subject: [PATCH 010/131] add comment --- src/message.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/message.cpp b/src/message.cpp index 669ad9b..12fc225 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -59,7 +59,7 @@ Message::ParseSignalsStatus Message::parseSignals(const std::vector& da const int negative = (v & (1 << (signal.size - 1))) != 0; int64_t nativeInt; if (negative) - nativeInt = v | ~((1 << signal.size) - 1); + nativeInt = v | ~((1 << signal.size) - 1); // invert all bits above signal.size else nativeInt = v; values.push_back(nativeInt * signal.factor + signal.offset); From 9fc66dcde03dc264007d534bb48203b426a999f5 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Thu, 16 Feb 2023 17:53:26 +0100 Subject: [PATCH 011/131] Add test --- test/test_parseMessage.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/test/test_parseMessage.cpp b/test/test_parseMessage.cpp index 145f4c7..7ccb971 100644 --- a/test/test_parseMessage.cpp +++ b/test/test_parseMessage.cpp @@ -162,3 +162,20 @@ TEST_CASE("Parse Message with non byte aligned values") { REQUIRE(Catch::Approx(result_values.at(2)) == 76); REQUIRE(Catch::Approx(result_values.at(3)) == -125); } + +TEST_CASE("Parse Message data length < 8 unsigned") { + const auto* filename = std::tmpnam(NULL); + create_tmp_dbc_with(filename, R"(BO_ 234 MSG1: 8 Vector__XXX + SG_ Msg1Sig1 : 7|8@0+ (1,0) [-3276.8|-3276.7] "C" Vector__XXX + SG_ Msg1Sig2 : 15|8@0+ (1,0) [-3276.8|-3276.7] "km/h" Vector__XXX)"); + + libdbc::DbcParser p; + p.parse_file(filename); + + std::vector data{0x1, 0x2}; + std::vector result_values; + REQUIRE(p.parseMessage(234, data, result_values) == libdbc::Message::ParseSignalsStatus::Success); + REQUIRE(result_values.size() == 2); + REQUIRE(Catch::Approx(result_values.at(0)) == 0x1); + REQUIRE(Catch::Approx(result_values.at(1)) == 0x2); +} From 9a347c92e035d7ad5a7abc0c571c9de3d6fc1ba8 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Thu, 16 Feb 2023 18:12:24 +0100 Subject: [PATCH 012/131] Fix test Reason: When shifting to the left, but the number of bits is not 64, the shift will not shift enough so bits of the next byte might be also in v. With this masking they can be removed --- src/message.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/message.cpp b/src/message.cpp index 12fc225..410b829 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -66,8 +66,10 @@ Message::ParseSignalsStatus Message::parseSignals(const std::vector& da break; } } - } else - values.push_back(v * signal.factor + signal.offset); + } else { + // use only the relevant bits + values.push_back((v & ((1 << signal.size) - 1)) * signal.factor + signal.offset); + } } return ParseSignalsStatus::Success; } From 71cac351e9de2e771cae4e63282c6428fff2383a Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Thu, 16 Feb 2023 18:32:06 +0100 Subject: [PATCH 013/131] Implement more performant algorithm to get value for little endian --- src/message.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/message.cpp b/src/message.cpp index 410b829..cc9a341 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -34,11 +34,8 @@ Message::ParseSignalsStatus Message::parseSignals(const std::vector& da uint32_t start_bit = 8 * (signal.start_bit / 8) + (7 - (signal.start_bit % 8)); // Calculation taken from python CAN v = data_big_endian << start_bit; v = v >> (len - signal.size); - } else { - const uint32_t shiftLeft = (len - (signal.size + signal.start_bit)); - v = data_little_endian << shiftLeft; - v = v >> (shiftLeft + signal.start_bit); - } + } else + v = data_little_endian >> signal.start_bit; if (signal.is_signed && signal.size > 1) { switch (signal.size) { @@ -61,14 +58,15 @@ Message::ParseSignalsStatus Message::parseSignals(const std::vector& da if (negative) nativeInt = v | ~((1 << signal.size) - 1); // invert all bits above signal.size else - nativeInt = v; + nativeInt = v & ((1 << signal.size) - 1); // masking values.push_back(nativeInt * signal.factor + signal.offset); break; } } } else { // use only the relevant bits - values.push_back((v & ((1 << signal.size) - 1)) * signal.factor + signal.offset); + v = v & ((1 << signal.size) - 1); // masking + values.push_back(v * signal.factor + signal.offset); } } return ParseSignalsStatus::Success; From 4b43b62a7728714bfba07c1c5dd8386c7a72749c Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Fri, 17 Feb 2023 11:25:07 +0100 Subject: [PATCH 014/131] add possibility to get the name of the message --- include/libdbc/message.hpp | 1 + test/test_dbc.cpp | 10 +++++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/include/libdbc/message.hpp b/include/libdbc/message.hpp index a6613b2..0c96b7d 100644 --- a/include/libdbc/message.hpp +++ b/include/libdbc/message.hpp @@ -31,6 +31,7 @@ struct Message { void appendSignal(const Signal& signal); const std::vector getSignals() const; uint32_t id() const; + const std::string& name() {return m_name;} void addValueDescription(const std::string& signal_name, const std::vector&); virtual bool operator==(const Message& rhs) const; diff --git a/test/test_dbc.cpp b/test/test_dbc.cpp index 9c49888..dc386b5 100644 --- a/test/test_dbc.cpp +++ b/test/test_dbc.cpp @@ -80,6 +80,7 @@ TEST_CASE("Testing big endian, little endian") { parser.parse_file(filename); REQUIRE(parser.get_messages().size() == 1); + REQUIRE(parser.get_messages().at(0).name() == "MSG1"); REQUIRE(parser.get_messages().at(0).getSignals().size() == 2); { const auto signal = parser.get_messages().at(0).getSignals().at(0); @@ -104,6 +105,7 @@ TEST_CASE("Testing negative values") { parser.parse_file(filename); REQUIRE(parser.get_messages().size() == 1); + REQUIRE(parser.get_messages().at(0).name() == "MSG1"); REQUIRE(parser.get_messages().at(0).getSignals().size() == 4); SECTION("Evaluating first message") { @@ -146,6 +148,7 @@ TEST_CASE("Special characters in unit") { parser.parse_file(filename); REQUIRE(parser.get_messages().size() == 1); + REQUIRE(parser.get_messages().at(0).name() == "MSG1"); REQUIRE(parser.get_messages().at(0).getSignals().size() == 1); SECTION("Checking that signal with special characters as unit is parsed correctly") { const auto signal = parser.get_messages().at(0).getSignals().at(0); @@ -165,6 +168,7 @@ VAL_ 234 State1 123 "Description 1" 0 "Description 2" 90903489 "Big value and sp parser.parse_file(filename); REQUIRE(parser.get_messages().size() == 1); + REQUIRE(parser.get_messages().at(0).name() == "MSG1"); REQUIRE(parser.get_messages().at(0).getSignals().size() == 2); REQUIRE(parser.get_messages().at(0).getSignals().at(0).svDescriptions.size() == 3); @@ -194,6 +198,7 @@ VAL_ 3221225472 State1 123 "Description 1" 0 "Description 2" 4000000000 "Big val parser.parse_file(filename); REQUIRE(parser.get_messages().size() == 1); + REQUIRE(parser.get_messages().at(0).name() == "MSG1"); REQUIRE(parser.get_messages().at(0).getSignals().size() == 2); REQUIRE(parser.get_messages().at(0).getSignals().at(0).svDescriptions.size() == 3); @@ -217,7 +222,7 @@ TEST_CASE("Signal Value Multiple VAL_") { create_tmp_dbc_with(filename, R"(BO_ 3221225472 MSG1: 8 Vector__XXX SG_ State1 : 0|8@1+ (1,0) [0|200] "Km/h" DEVICE1,DEVICE2,DEVICE3 SG_ State2 : 0|8@1+ (1,0) [0|204] "" DEVICE1,DEVICE2,DEVICE3" -BO_ 123 MSG1: 8 Vector__XXX +BO_ 123 MSG2: 8 Vector__XXX SG_ State1 : 0|8@1+ (1,0) [0|200] "Km/h" DEVICE1,DEVICE2,DEVICE3 SG_ State2 : 0|8@1+ (1,0) [0|204] "" DEVICE1,DEVICE2,DEVICE3 VAL_ 3221225472 State1 123 "Description 1" 0 "Description 2" ; @@ -227,6 +232,9 @@ VAL_ 123 State1 123 "Description 3" 0 "Description 4" ;)"); parser.parse_file(filename); REQUIRE(parser.get_messages().size() == 2); + REQUIRE(parser.get_messages().at(0).name() == "MSG1"); + REQUIRE(parser.get_messages().at(1).name() == "MSG2"); + REQUIRE(parser.get_messages().at(0).getSignals().size() == 2); REQUIRE(parser.get_messages().at(0).getSignals().at(0).svDescriptions.size() == 2); From f4a8a81529da0c43159b98b3fc83d4c3ac6fe751 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Fri, 17 Feb 2023 11:28:40 +0100 Subject: [PATCH 015/131] Make function const --- include/libdbc/message.hpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/include/libdbc/message.hpp b/include/libdbc/message.hpp index 0c96b7d..204f5c2 100644 --- a/include/libdbc/message.hpp +++ b/include/libdbc/message.hpp @@ -31,7 +31,9 @@ struct Message { void appendSignal(const Signal& signal); const std::vector getSignals() const; uint32_t id() const; - const std::string& name() {return m_name;} + const std::string& name() const { + return m_name; + } void addValueDescription(const std::string& signal_name, const std::vector&); virtual bool operator==(const Message& rhs) const; From a3ca54d3ca67c9218f59507dea596fc4d6fd2b51 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Thu, 2 Mar 2023 18:32:09 +0100 Subject: [PATCH 016/131] Do not install headers if they are not desired. Reason: When including the project with FetchContent into a cmake project the headers are just needed for building, so the headers are not needed to be installed. In this case ignore them --- CMakeLists.txt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 44e6cef..bd22584 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,8 @@ include(CPack) option(DEBUG "use debug flag" NO) option(ENABLE_TESTS "Enable Unittests" ON) +# Turn OFF, if you are using FetchContent to include it to your project +option(INSTALL_HEADERS "Install header files if the library is used as dependency" ON) # defines variables used in the dbc.pc.in include(GNUInstallDirs) @@ -92,13 +94,13 @@ install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) # install headers -if (${CMAKE_MINOR_VERSION} GREATER_EQUAL 23) +if (${CMAKE_MINOR_VERSION} GREATER_EQUAL 23 AND INSTALL_HEADERS) install(TARGETS ${PROJECT_NAME} FILE_SET HEADERS DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lib${PROJECT_NAME} INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) -else() +elseif(INSTALL_HEADERS) install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/libdbc DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) endif() From 85a429276f01934784455ef85473a0820795ff4c Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Thu, 2 Mar 2023 18:41:09 +0100 Subject: [PATCH 017/131] Use FetchContent_Populate Reason: With it the source can be included directly and it does not install the header files --- CMakeLists.txt | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bd22584..038960b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -32,7 +32,9 @@ if (NOT ${FastFloat_FOUND}) GIT_REPOSITORY https://github.com/fastfloat/fast_float.git GIT_TAG 1ea4f27b2aeee2859a1354a3c24cff52a116cad1 ) - FetchContent_MakeAvailable(FastFloat) + # FetchContent_MakeAvailable(FastFloat) + FetchContent_Populate(FastFloat) + add_subdirectory(${fastfloat_SOURCE_DIR} ${fastfloat_BINARY_DIR} EXCLUDE_FROM_ALL) endif() set(GCC_COMPILE_FLAGS "-Wextra -Wall -Wfloat-equal -Wundef -Wshadow \ From abe7bae4424004415f5f050945344a59ddf3234d Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Thu, 2 Mar 2023 18:44:40 +0100 Subject: [PATCH 018/131] exclude als cmake files --- CMakeLists.txt | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 038960b..361d563 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -15,7 +15,7 @@ include(CPack) option(DEBUG "use debug flag" NO) option(ENABLE_TESTS "Enable Unittests" ON) # Turn OFF, if you are using FetchContent to include it to your project -option(INSTALL_HEADERS "Install header files if the library is used as dependency" ON) +option(FETCH_CONTENT_INCLUSION "Include project with FetchContent_Declare in another project. In this case the headers and the cmake files are not needed, only the library" OFF) # defines variables used in the dbc.pc.in include(GNUInstallDirs) @@ -96,18 +96,21 @@ install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) # install headers -if (${CMAKE_MINOR_VERSION} GREATER_EQUAL 23 AND INSTALL_HEADERS) +if (${CMAKE_MINOR_VERSION} GREATER_EQUAL 23 AND NOT FETCH_CONTENT_INCLUSION) install(TARGETS ${PROJECT_NAME} FILE_SET HEADERS DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lib${PROJECT_NAME} INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) -elseif(INSTALL_HEADERS) +elseif(NOT FETCH_CONTENT_INCLUSION) install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/libdbc DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) endif() -# Generate pkg-config file -configure_file(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY) -install( - FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc - DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) + +if (NOT FETCH_CONTENT_INCLUSION) + # Generate pkg-config file + configure_file(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY) + install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +endif() From 0de0d346608dd8b89602c237aaa75462f4656ffc Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Sun, 16 Apr 2023 10:11:26 +0200 Subject: [PATCH 019/131] add missing include. Otherwise tumbleweed does not build anymore --- include/libdbc/signal.hpp | 1 + 1 file changed, 1 insertion(+) diff --git a/include/libdbc/signal.hpp b/include/libdbc/signal.hpp index f41cef6..b33b3ff 100644 --- a/include/libdbc/signal.hpp +++ b/include/libdbc/signal.hpp @@ -5,6 +5,7 @@ #include #include #include +#include namespace libdbc { struct Signal { From f1409c6363a9edce1bd231e5e9ce2deb2ee62705 Mon Sep 17 00:00:00 2001 From: Martin Marmsoler Date: Sat, 29 Jul 2023 15:04:58 +0200 Subject: [PATCH 020/131] format code --- include/libdbc/signal.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/libdbc/signal.hpp b/include/libdbc/signal.hpp index b33b3ff..1b7076f 100644 --- a/include/libdbc/signal.hpp +++ b/include/libdbc/signal.hpp @@ -2,10 +2,10 @@ #ifndef __SIGNAL_HPP__ #define __SIGNAL_HPP__ +#include #include #include #include -#include namespace libdbc { struct Signal { From 0b9c0f179bdfff552e49e24abfa492770150424b Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sat, 27 Jan 2024 12:26:17 -0500 Subject: [PATCH 021/131] Adding python, editors, and other ignores for git. Updating version to 0.2.0 --- .gitignore | 11 ++++++++++- CMakeLists.txt | 2 +- Testing/Temporary/CTestCostData.txt | 1 + Testing/Temporary/LastTest.log | 3 +++ 4 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 Testing/Temporary/CTestCostData.txt create mode 100644 Testing/Temporary/LastTest.log diff --git a/.gitignore b/.gitignore index 781c60c..20445c6 100644 --- a/.gitignore +++ b/.gitignore @@ -3,4 +3,13 @@ bin/ build/ # -- Git -- # -*.bak \ No newline at end of file +*.bak + +# -- Python -- # +venv*/ +__pycache__/ + +# -- IDEs / Editors -- # +.idea/ +.vscode/ +*.sublime-* \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index 361d563..e4b9f15 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ cmake_minimum_required(VERSION 3.16) -project(dbc VERSION 0.1.1 DESCRIPTION "C++ DBC Parser") +project(dbc VERSION 0.2.0 DESCRIPTION "C++ DBC Parser") set(CMAKE_EXPORT_COMPILE_COMMANDS ON) diff --git a/Testing/Temporary/CTestCostData.txt b/Testing/Temporary/CTestCostData.txt new file mode 100644 index 0000000..ed97d53 --- /dev/null +++ b/Testing/Temporary/CTestCostData.txt @@ -0,0 +1 @@ +--- diff --git a/Testing/Temporary/LastTest.log b/Testing/Temporary/LastTest.log new file mode 100644 index 0000000..17d9c4a --- /dev/null +++ b/Testing/Temporary/LastTest.log @@ -0,0 +1,3 @@ +Start testing: Mar 19 09:21 EDT +---------------------------------------------------------- +End testing: Mar 19 09:21 EDT From 41cd2c9a24b92f68cb5c024d59f2eb2096296ad8 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sat, 27 Jan 2024 12:27:07 -0500 Subject: [PATCH 022/131] Remove the accidentally committed files --- Testing/Temporary/CTestCostData.txt | 1 - Testing/Temporary/LastTest.log | 3 --- 2 files changed, 4 deletions(-) delete mode 100644 Testing/Temporary/CTestCostData.txt delete mode 100644 Testing/Temporary/LastTest.log diff --git a/Testing/Temporary/CTestCostData.txt b/Testing/Temporary/CTestCostData.txt deleted file mode 100644 index ed97d53..0000000 --- a/Testing/Temporary/CTestCostData.txt +++ /dev/null @@ -1 +0,0 @@ ---- diff --git a/Testing/Temporary/LastTest.log b/Testing/Temporary/LastTest.log deleted file mode 100644 index 17d9c4a..0000000 --- a/Testing/Temporary/LastTest.log +++ /dev/null @@ -1,3 +0,0 @@ -Start testing: Mar 19 09:21 EDT ----------------------------------------------------------- -End testing: Mar 19 09:21 EDT From 4ff2895abb764d0b7c82102b07da59c5c65e57e0 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sat, 27 Jan 2024 13:19:20 -0500 Subject: [PATCH 023/131] Removing the .cache directory accidentally committed. Cleaned up test cmake to only have one executable --- .../index/common.cpp.E08560EA7108A3D6.idx | Bin 0 -> 688 bytes .../index/common.hpp.41CE9FCA42FA7760.idx | Bin 0 -> 308 bytes .../clangd/index/dbc.cpp.E3E6A77857D7C47A.idx | Bin 0 -> 8106 bytes .../clangd/index/dbc.hpp.1AE231EB8F8FCC79.idx | Bin 0 -> 2258 bytes .../index/defines.hpp.EC68A617B863B96B.idx | Bin 0 -> 1340 bytes .../index/error.hpp.A77A640A32416EE9.idx | Bin 0 -> 624 bytes .../index/message.cpp.F7C838DC6F61B691.idx | Bin 0 -> 3034 bytes .../index/message.hpp.9D53D7219D8F51C0.idx | Bin 0 -> 2272 bytes .../index/signal.cpp.BB48951555CC5AC5.idx | Bin 0 -> 2252 bytes .../index/signal.hpp.CBDEE5D1701AED97.idx | Bin 0 -> 2032 bytes .../index/test_dbc.cpp.BFE2FBF6ECE46A43.idx | Bin 0 -> 26470 bytes ...test_parseMessage.cpp.8E39780016C24013.idx | Bin 0 -> 15392 bytes .../index/test_utils.cpp.3E9CD9BC8124FDE8.idx | Bin 0 -> 6604 bytes .../index/utils.cpp.2A152B1CE2336D05.idx | Bin 0 -> 1740 bytes .../index/utils.hpp.9998710C28E0D597.idx | Bin 0 -> 1110 bytes .gitignore | 5 ++- test/CMakeLists.txt | 33 ++++++------------ 17 files changed, 14 insertions(+), 24 deletions(-) create mode 100644 .cache/clangd/index/common.cpp.E08560EA7108A3D6.idx create mode 100644 .cache/clangd/index/common.hpp.41CE9FCA42FA7760.idx create mode 100644 .cache/clangd/index/dbc.cpp.E3E6A77857D7C47A.idx create mode 100644 .cache/clangd/index/dbc.hpp.1AE231EB8F8FCC79.idx create mode 100644 .cache/clangd/index/defines.hpp.EC68A617B863B96B.idx create mode 100644 .cache/clangd/index/error.hpp.A77A640A32416EE9.idx create mode 100644 .cache/clangd/index/message.cpp.F7C838DC6F61B691.idx create mode 100644 .cache/clangd/index/message.hpp.9D53D7219D8F51C0.idx create mode 100644 .cache/clangd/index/signal.cpp.BB48951555CC5AC5.idx create mode 100644 .cache/clangd/index/signal.hpp.CBDEE5D1701AED97.idx create mode 100644 .cache/clangd/index/test_dbc.cpp.BFE2FBF6ECE46A43.idx create mode 100644 .cache/clangd/index/test_parseMessage.cpp.8E39780016C24013.idx create mode 100644 .cache/clangd/index/test_utils.cpp.3E9CD9BC8124FDE8.idx create mode 100644 .cache/clangd/index/utils.cpp.2A152B1CE2336D05.idx create mode 100644 .cache/clangd/index/utils.hpp.9998710C28E0D597.idx diff --git a/.cache/clangd/index/common.cpp.E08560EA7108A3D6.idx b/.cache/clangd/index/common.cpp.E08560EA7108A3D6.idx new file mode 100644 index 0000000000000000000000000000000000000000..1f0d602611925d50e0d828eadbe6bb72d6b729a8 GIT binary patch literal 688 zcmWIYbaPw5#K7R3;#rZKT9U}Zz`!5`#Kk2=nI()23?i%y3>9ug)|`I9`o zW&7G^ZrFRe`IKjO)4pSS4?h2LKGdT6(!bYDyyrEK?KSS#mw2A&x!Uf;r$ZjImM<23 zy!!dos*hFTe80cu?T^wi=kI?VyJzp+`{#d8nAzkY=gOts94ctRH_egzw$@3}W6|07 zIGTgiB&Hv-+GIFQwW4U>x1Dy6`Ts9dnR-g~$Rsaz4V$#!x}v2^PICEA((bKPJy|Mq zEV89)zE8)ZbwAi2{!uhPWUg4ZDWCa0ALCB1L%z~MD^~XIc_(!&ew_rr#Ni#P=~~@K zmToFuF=uTs%b8Zc#G=DHJ{QenbMk zc}>o4xc_n871!d*+$2R{9Q?Em{^zrO?nfR5Nd^WfW>#hiX%NA{$;8MYF2N|x%21S= zRy+f!vTm;Q;vLSaFfnU3rW=C=n5vk0?Dz=T^rCS1F2{5BdW%*n$k z2@_5*U6Rwvo${CoD9pym4HM>(;$q{1^Y;F?F?wS->mx|76sJ5)5sYT!0=pCFBrqsS z%}E3?ii?tqm4P&))UrjJ7Kl%MT*@RZ!ypY-114k;%;emZ98n-wSXh*Wjfabuo0Ef` Ok5x!Oj9-vhgaH6}s1N@D literal 0 HcmV?d00001 diff --git a/.cache/clangd/index/common.hpp.41CE9FCA42FA7760.idx b/.cache/clangd/index/common.hpp.41CE9FCA42FA7760.idx new file mode 100644 index 0000000000000000000000000000000000000000..9651fa27d618774bd216b48b6854d672abb6b445 GIT binary patch literal 308 zcmWIYbaT^TWMFVk@vO*AElFfyU|<`W`BKadsZZO!QQJ^zx|lq zrz4V@A5yCtRa=-hC3&9cH@`$R?GzOiV=I%_DsgkSu``@+Oo(~Q9@pb-k!BXnpUg_6fdrLbvQJ7?^#AJHbxFc0kB#i0W*M+6QU6+ dUX+@X2x1l&B^Psp7;Ivf89&uW>1r`B006g^VN3u3 literal 0 HcmV?d00001 diff --git a/.cache/clangd/index/dbc.cpp.E3E6A77857D7C47A.idx b/.cache/clangd/index/dbc.cpp.E3E6A77857D7C47A.idx new file mode 100644 index 0000000000000000000000000000000000000000..9667712361b6624dbc0bf845b9412c2808eb6ea1 GIT binary patch literal 8106 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 literal 0 HcmV?d00001 diff --git a/.cache/clangd/index/dbc.hpp.1AE231EB8F8FCC79.idx b/.cache/clangd/index/dbc.hpp.1AE231EB8F8FCC79.idx new file mode 100644 index 0000000000000000000000000000000000000000..2600ce255ed01d853e0bc172c876804faf40529e GIT binary patch literal 2258 zcmYjS3s6*57(VCh;V!!zcJD5-!0x(t=gRK7%R^X6@r4hRP)AV2XE92$K2R({3r!r$ zN9y>9vB^LzYAiI-G06xSG7w+nqsed>mBgG>CN)#jd{yUO{h>Rv|K9!o?|+^1fB$BU zPD^VEMkqCJba6poaV|v&nfa$^apAlmj8Luyq2h{zTN@W1ak8~b%W_s-XfM39Y{v)v zhpjGNy&fIN{eAb@lwj{kO_I6knzrOv+y0BYg!S}9zrN+YKbyAk9C@e27Bb}e@&_Sz zIy3WE-1EhC$bV)I#nMl6H<>k$rSa1$(p*hr%s#rX;(%AGnSE+dpmuv|@k^H5`VmRL zn6x9e%xRvwGCe<8GcIk=ytB@#xv{N}T*Xb(Q06%lAJXrM@ma%Q11eft@Y-d9(DJGW&r%-; zh=KGlA{uLsjZy{T2dF$}!VZmmWA^o6kuW3D)#B({97iRq)C&OH3j6r7pVWjHh@Jbp zLR~#n0p@#cXu|!^!u zoR{dfx+PVBx$Ny9ThE-_E|N$d{w5Z0Vww5{eUE?(L^CJ8~`m zZjLd>NU8v{SoB9(SbI{rNJ4q|8XQr>^E*NvUHNy^<1bV8joNJ>Htrv9j<=}-{3GTs zDXGtC-D@BkZuXgdk}AMFF$;~W*A*QXiIs=1#9}43QoF(46@Js4jmJ{fq;wdFnfrSj z9=9sMKU#OEYWS})*DVBd|56-MihIyV9H|F@bYQw>Ws4y_QD1onloww>MQ=i(1hEZp@(+)$!sEp-cm@!5@;T}754Aj7Sl@c(@*%@Zf zjnctET1F*7V!#j{S8%fb#Z8wpy5q`ua(?$Ox8PlVM%m*M-o(xU3yx<~7D?|kJMBS){f`GW0 zU%4sTI=v-<5gnh;np#*$zkdbKQ)lDerra@KQ)H342aegy3{|Kgw2t z3Sr(kT3IQe)>q#-J-GazYf9_{IT>QZlHoy=)dFak53W`g3aFu79$VQapoUxHXk~%G z%)tWTqo`~TKo0>Rfr28k*-#=)U3@!?S*9;j9O;vsXext8Clx$hb%2h zU8RNX9mh4%4~0#=h^>+ScgdMc*3&Un~*x))z|ki-T3x-Qf@7 zOAaPgr&T*V$9{Kt-lpFg6MVby&9%{?HcdzA*Z0<{dwQE;e=Is)_*16~uBkB1aha+zibb>{`3QrUR`&xuWF7y zYeii=J4E?cOQOiEbndm+_QYkUSodQ(T>YqX0PxfGiGG_iZdVT zkeD1#9tZWFH?W;SHJ5H|(3EqJe_Rc6TN0w0x>pTMu-(t@@9bwkZ7Oj%3v!n|qe-3Qqauu!3HKGmBjh(sKv}NtH7A^WjEHE;gw?W>d_|TSD&K7tiUZF@EEEw( zWvs5b5aKH!Pn(~yv#n&R zS48w!39sdiz5=o>q0!ypW#7~88FcI`Z7_^Rws2br1KH=LcVK79Rf;_SZbU*rH z4@CwL!o)BsgQOe?HsNFiv5D+L1##24GzIY%K3zeAK`;Y?p6Q<+IkIwFlxuDP zbv=uj4V_Wfsd&~9*O}}h_yTpkfJ-0ZI)l#~;yO{739i!~d6QqS>z((XB9$)+L<+4^ zd-C-HdmvLIvpLs3yj-LQpk^cpgCYZCQV>>S3HGCh6OAV;h*h%^ z1VsoN&sr43sW}N^BZQm6B`Anj^Adze2p`9r6(pzy2|6Z3h!CO`MASqAlkf(0CI1EB m3O1p%eEWfR*mJVvwbPO9)W{1_E`x*QxZ@g@9C)r*iRd4stdchX literal 0 HcmV?d00001 diff --git a/.cache/clangd/index/error.hpp.A77A640A32416EE9.idx b/.cache/clangd/index/error.hpp.A77A640A32416EE9.idx new file mode 100644 index 0000000000000000000000000000000000000000..71002806a83fe0f6ecfcf31956bb686e3e680b05 GIT binary patch literal 624 zcmWIYbaTsKVqkDi@vO*AElFfyU|h9N@k@E&+@7Z^1Bzl zR$Qu+BK~#d&#r54Gxyr(Y@R3ke0imQ=wta6wc8^1G90!Ht}L$1O_~pMAOGCt86GRs zOa+)Y*%_Dwcm)K(1Oo?94hWcoIyTKbAYsYG1o9jRFtKv63NUa&ID4Od`$0F!~KWQ6&xxG1?;9OMjUm|K9st;U`;huyIuijkQC03x=xod5s; literal 0 HcmV?d00001 diff --git a/.cache/clangd/index/message.cpp.F7C838DC6F61B691.idx b/.cache/clangd/index/message.cpp.F7C838DC6F61B691.idx new file mode 100644 index 0000000000000000000000000000000000000000..d33266e6ea6f111061ea4309f9aa7c99bf1b83a8 GIT binary patch literal 3034 zcmY*b3s6&68oo*HC9jhQA-OjY$U_nWlmL>JhZ5~dlnP5!paFzk@{kGwr3I^~Xqz1z z=~Aji+iqQJDOEdFw1RyhqOmNt;IOXjx}8$BpsUylEVc?NZQT=R&b@at1C#In?tlL8 zf1Lj&clokq!(t4}ShKvox@^50$1qF*|LWG)R_x(m*mpb(tKWAt@4I!H`SN#H6g6oS z;giRc@45%bkRIWtuZbmdC(93Zb~vA~oHWV|kF*a~?>%*i@Ez#hmsYpzPbV%`KD#6O z_Q>{Iug>;=lznHiUES+gH&)fuAF#?-ftKaQH}%qt3c`n-~GQV_+aVWtt$zNZ=)AplwRilbW|NQ z(VDC%UY_AM$zH4o-x*i$8xid`M(}>q>61cSvOL$OI)6Ix_9=bTr!|Sh&Se{;!RMkQ zAN#xZwRBaaAB#fyo5=f1i>eD?Vn z|G{4da@q-E?4JD76aF2(j)vjET3)+$XliZu58wW?<2$dNZrOiZ z-Nk#WyP>6iqVSvHwHJJIv9p`w?q*KT)K>~;%lh9Qc=nHlIp>!b8Bzu}MHJYg|6KeB zZn>~{!%JIJC-R5LlwIQ&ADlnm*ID7p@XDrV&opk-&K5V;ZL0P>ggx5ae7Q5Xe>Pdp z4GYJpTt%*u)Qj{06F?4r?7aA6GZWn_0T!Xbs8VSuNhV2?NKDA(V0smYB=QEzrr-Vf zV~?C03jH0C4hyN%=uF7}@KDsP&8<;e$UR5C#23UlSC0f2H6PJlE6sx+xI4OM?o zQ-4iZFC{oQwL-8W7#)!BP?&GMkxt++rcIW?#FQ1uN*Ux3J7^aeCC8bEqRfx$D<9aR z2;%@s5ur#xE_bK?^W|5&3Qf>lC@7>g1%J|SFP1)d5}M5tGl`x?3Ge^~RDeQN5j`Fz zrhYEHYaYsHD4}DX>Ud8|5TIgHV;7;50A)$DEM`z*S|STs)2u9HOSQ55>)Qpc;^vM{ah=3PC z=BK$h6~qgo&&4SLPe3C>Wy+hk2NE*)fQk%@)FNM4F@xE}plC%jT|Ypj#HA!M+ydi* zXa=Q6rkfd*5t>2kL2^0V$M=$#+tl@rU!7L+{*#KUC7-O~!Vw}$0eT7|ZK(;Nt1qFT=%wW@Sv6zqEPdmB7<_i9QrPU8%Qy*7&Qf zEHE_DvGK?Z<-}O%(SF{j zJ4!U+%}`FZI9rKCx5N5H3a7yqPJb{seuf&}Ua$1~L zuixQERA@pYJ3k+MjI%<=tCgdMs$)k*+L$x#ZCNOjO2v_IKlF76yXltVlsDK*BWc>uqgU2|K3GwiP^Ljg z!SyRtuu!HTGYoOB{r9D3B+6I%U{dTw11B>N6d_FzxxrcndDUKeGX1H;OByCQgRr?p zL{SLJl{>QM)roWO{T-SMC51|4-rKo4f864`0u>TGg7r28LLgxRS8!!zmks;Fan zD1Gm5H(^!qU_2BJ1fU}L5i;ZpmmAMOFCqB4#c~BmG|CrtG4RU(by0PC?&AJ!n%i)G zU7;=wx|j>JcLpni+;;@fOt|>S43WuYW{{h3vpBcTZD2SL;bCzeorlGF2``KD>bx}f zj!)w0?i&3Gwj;}sWoCxhp>U|t{)D$S-?n+a literal 0 HcmV?d00001 diff --git a/.cache/clangd/index/message.hpp.9D53D7219D8F51C0.idx b/.cache/clangd/index/message.hpp.9D53D7219D8F51C0.idx new file mode 100644 index 0000000000000000000000000000000000000000..8533b199c9c30ddb0426701cf6aa380e7eb67f47 GIT binary patch literal 2272 zcmYjT4Nz276u$2*yRhrsyN~_jZ`}o5R)JkuS0OO+4>6HK7s=2_lf=+~2*eCbArzSu zMUZhcZDh*qE^LhNKaX}(gh);q`&NSS!)UygmOd(Z8&hW+#cI%iR{OY;)3L%`(uDrH%`){NiP)nN5#g8=hBFoc_3|FLs??l)1aSGdOal$FptUK6#pa zZj#T9shd#tr|HS3ScJYAYO0L-*N2s`u3AK7t}-GBB&E|rh#}%&bK{fq)=F0el6WDa zWR;vC1P4z{9byafblkE6wF0?N2NkRG6ok{^_X~&EB@3H0TGrJAk#Wp8H$fn}AN(`L z+?v{%r}S1JF^%U~PAv#$eD3yZ$K%_^!Z=pr@gjuy%6u`zm-WhL5mFmTSUpW2Bn?ss z0?czo!N*1i8y8{Zt93-%h)s*6EQ2P>Y5j{kQyv~1u1n@vHKaHA82lmrx3xy*-rSZo zg!Q561Lc7#L4dio+ti<1X3FE(aS*MS=#^le-8Hu_RB^mefkd=9ch;Q~gtNJ`r$_NW z;cdkn>j&{BV$wo9cVK>U+O3Z&1?+_K36^1ZFyArXXfN2k^fMK1_2hxSAl zyZbaYbL<32u2buL!Av5$pXaZ_tzzUxqX{N@L4bM3Upe#T>iky1>ZsW)H>(5z=KaT) zCET+VTqmqIH3!H7h#mD9|%O%0(%^4pbb^?oPp|rE>taW#o-MkVWa{%z#GUxy?JJU8X9C6 z!jl0|OZs}6@dNPGroF|*uhW~fc+x+2lFzEKJM}@_S^g70kaf}rq z0EZUGQwyp9YO$D1kWNs*#AO1(zzGOOV|ikM8i+-25?JMcVcU~)_Y>@6TSRo^;dmy{ zhfZv&Zn|?~K}?VvKm&_FvEZ2p7gTaf=iCfmU&7FdCKx}2i7u8#H>am?J0u>%|7fF{lh)ussyVH;nO+fl^Cu zQ2{i7HLZ~UR6yRWl(d!nS2H{7{p{EI7yeI(;~}vzAv3y{Z1NU!?h2&}abQ45<$QH_ JzABur{{j0uzQq6l literal 0 HcmV?d00001 diff --git a/.cache/clangd/index/signal.cpp.BB48951555CC5AC5.idx b/.cache/clangd/index/signal.cpp.BB48951555CC5AC5.idx new file mode 100644 index 0000000000000000000000000000000000000000..e1b81c962bf6f0165be0016beda9a0f3a9e02d42 GIT binary patch literal 2252 zcmY*a2~ZPP7~W*F3CCu0ke7tS?5-x5dl#buDq0k=r6?Bgs1=z3jn)#X1vnHIh|2UB4{$Upty%#=L7if~>axxxhoaqc~uI47}?@K$c-M=OxszV&ZdRoaxJ=*0 z1$r_nicVLyl&`Nl(R_S^Jg5GqCVE%QmQRj+rD@XD7e8At?yY(IuJ~%g8+(_Oe8HH#*J+~nN&8CY_+naT#HQnJlme%xy+RP;xbLwleH5&t;`)_x@ zx2^Wwo&P+4R+HFnShn`n;O^k1v0>W-&(8dC?Nr=575Qr&=~wJ^!z%4-pByQxS{?My zS-wTto^yW2vKtes&NQ4%OgQ*K4>m8iKz?a<(9&XjN(ZVFPRyCqbpO)o!^}^Z+0vR( zqv$`l<@)96S&s*MYG>ld;ybaTvVy!-u+uF@MMK5xt2rbVt;c|!vg>uRRIDBgmr5{m zltf3Aw4U46`D=HDUaB=<01v|{9TUN*F?ec2S1`V+zx30KEo!L|(pIGv=)7_-h3FLp z9aA2hebla&njmdaT7b?&dGv@b^e--|lw;ThbLo%ar4%8N0TXT_QO;TETKg|s6A1|k zs7OkKmj8Tsud}E2%@`R8RJclkmPtUX=qQvCA~Veh$iX^nXtSE5XQ$4mo{oV5bhs{* zjs#2sGg)w9QkhHvc^R(*1?c6QM}R{o<8cz`aecT@0h7Zl5?q)7Q;3l4^i5wzS>AY< z(|{Y~B9~Rn8VRz3C2Wu|n?;y2a3++toy*$oyT2((D*NBYWgr@l4z*!;e*8!M=lNuq zNQ-Mj%dj77B=kB_WV%{HZxvy;(LD@hstZ26d-X6e4F(a%CILH=bqU3?J~mE3d^8UQ z_@AD#o5pDGWFO6tlE6;bNwf?RZI40d&hkC?+g2*(%1NNXHKKE%=hLD#(gFH?A&V`{ zra`JBfz4odAq&GY z9szk6j~m6yXD7B+KA-4^q69byo&D*R=Wl&2`6D036-yX)YzmtuL}IhpYypijjk2P+ z)^nE!yi?OkVE`j;6bXbSS(V_z8d#HnIG*#N0B9?ch?ir!V~sNJc(CtrR(Q&(0>8Qj zY8BVvCS*kdWu!7RQgFZwlm&69p|EvB6OAJ6DfqCn&(?Pk%8%C3dQ^oBux{3i5V}L( zp>apP$|a`wr3Z#};4DkGQewjoq&9DUl>9M+WceZO7C5V={Pl~MavL5I2S_h z5x#uGUivodni^M&_Cverai|uk{mJx90XbPGhXO=2Kk7|vc=0n7Dj_E*)B+O7NiBR#U>ytVU0wBCV|yrwF=1YvnQZbh5kV9&=;+!aAA>Q s=s`F1_wteeyJFqh-Y>r|m*}vC1&ab|xJ*%MS(ri|PADTa5hSkq7gTvhng9R* literal 0 HcmV?d00001 diff --git a/.cache/clangd/index/signal.hpp.CBDEE5D1701AED97.idx b/.cache/clangd/index/signal.hpp.CBDEE5D1701AED97.idx new file mode 100644 index 0000000000000000000000000000000000000000..78ca30d745acfdb660a4749067b3c8ba74244978 GIT binary patch literal 2032 zcmY+E3rtg27{~8Dw6~|X=N@hgl+t#T=LSf%c1)3#kbyvmiufRN(P)Y=ofTbpSR5*Q zn8gV=#HfSJ#RYsN=w?+mXLQKs12Y%JJ=}Z@wjnT>kGafso6F9YI- zcYa^z7Ubm(={PQ@w4kQEtjeq5IL^erl~oll%;Gt2FXFhGw;P*R`?_87**k6FRqkiV zM}F@X_xenYclC_c#UqVVl8?7dW7!@Oyf1W+WZROWt_(TOs$}!IZ;+jI`yR`aRB~ zj-18$!DC03>|c8LeDzl;=Z4%jI$v!#l=JC|3rq9wUcOUxtuu0<>vs0=zF@7VV(0zC7~Z==|4OX zj5|HOeI&DMQg-E#$W^W_FFC|I`s?i1*yeYfCaH3TLqeTMVi|9P699eWYhn z4n;N=hlycS6^M5PZueg~tj(jy!D6dqHL3#f%@=nMoLZ-QmLfZgO`<7G6^IX7bggy8 zR~8e_B9EN~yQs^|=@HL8rsc7=Uq3&$-hZQnB8jaJ7s5@dz*lGhdI8=f7R>HhLn}Wt>bv2IWqjjo49GLq0NKO0a2W1oq zn>z(3g?RK*oqyJef&fJ^CJqw=kyU}%)$H{>nBzS~k-%b!N>QpnTwC6iJ$mNu$1;k7 z%~NTr8RD+=-t2Wh^A{+JW|i9?x2LHB@q{?HFLHnM4T>m>je;>;6^L72kxGsS`hF2m z2a&g8 zB-D{F@ghbTna8^Rh<|1)@IwW_J+l?)!3N%$t-ua8aL#N6aZ z@1~h2~5$w{s$T+{)741rdUjRK@s}K)sA?A4%@{qZk0xeyZX@EF;Tj3kt2DF*2 za1Azek=Y8*U<1m`RyYP5`pWCEf-cyAE)rE_!Dcrj*%RPq=IL`!mY2y}bOcK}Ndn{u zmIax>KN7)K!AhW6?4nIJ3zSH(!|bp_2?QsL$>SHzuHBq6p24iJ>Xku(dSFIa!<5+o z8)k#OtqcYn1`1@hG7w zhyE}Y-L7=Ni>oMG=~X7DvSMlF)5?QEk+IL%kgCrFJdP6|J>nx(F~=q}4Su81iw45| E1AD8r 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 literal 0 HcmV?d00001 diff --git a/.cache/clangd/index/test_parseMessage.cpp.8E39780016C24013.idx b/.cache/clangd/index/test_parseMessage.cpp.8E39780016C24013.idx new file mode 100644 index 0000000000000000000000000000000000000000..2a12242f20a960b928cf61a14aee852dcb8fbd50 GIT binary patch literal 15392 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 ZBdc&tfiDA8DlsXOQj#eOwOlEp{{gu&lDGf> literal 0 HcmV?d00001 diff --git a/.cache/clangd/index/utils.hpp.9998710C28E0D597.idx b/.cache/clangd/index/utils.hpp.9998710C28E0D597.idx new file mode 100644 index 0000000000000000000000000000000000000000..b442b46c08ad6d4952b16a4de5861b11ff471a1b GIT binary patch literal 1110 zcmWIYbaV4#VPJ4h@vO*AElC728H9kixTGla5|IAP$iPrBXX?a*d50Bv+A3$pCU4#S z^v2r_$xCe+l#clBk?J{+QT=Dpg3!0RQ!nuU`}@*e;`3U`*dIlOX=j#&iij609us5; z{`C%HvC6Smo@E_kuitS2)|c7<2WF1~E9 z??0kG$$rg09vodzA>VhHQAU4~=k*Qj`=-1VtPYqY9&z+d$S1jNZ~Ap>k8!U`?b;!$ z^v`r+hI-k@TYrm|ri50#zv%Ci73E=Y+hcd%4VCKx!uvW(2E zJ+Gtgmeo&k5@O;51sD)8D~c#e!1Ui2JG1Pqaf3O`KaTz2e;YsJDH{tb8#@Ol13OF+11uGR1XvNGYzQU*K_Ou~ literal 0 HcmV?d00001 diff --git a/.gitignore b/.gitignore index 20445c6..4705a45 100644 --- a/.gitignore +++ b/.gitignore @@ -12,4 +12,7 @@ __pycache__/ # -- IDEs / Editors -- # .idea/ .vscode/ -*.sublime-* \ No newline at end of file +*.sublime-* + +# -- Static Analyzers -- # +.cache/ \ No newline at end of file diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index d856c08..ce3bd4f 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -5,33 +5,20 @@ Include(FetchContent) FetchContent_Declare( Catch2 GIT_REPOSITORY https://github.com/catchorg/Catch2.git - GIT_TAG v3.2.1 + GIT_TAG v3.5.2 ) FetchContent_MakeAvailable(Catch2) include(Catch) -add_executable(dbcParserTests test_dbc.cpp test_utils.cpp common.cpp) +add_executable(dbcParserTests + test_dbc.cpp + test_utils.cpp + test_parseMessage.cpp + common.cpp +) + target_compile_definitions(dbcParserTests PRIVATE TESTDBCFILES_PATH="${CMAKE_CURRENT_SOURCE_DIR}/dbcs") target_link_libraries(dbcParserTests PRIVATE dbc Catch2::Catch2WithMain) -if (${CMAKE_MINOR_VERSION} GREATER_EQUAL 23) - target_sources(dbcParserTests PRIVATE FILE_SET HEADERS - TYPE HEADERS - BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} - FILES defines.hpp) -else() - target_include_directories(dbcParserTests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) -endif() -catch_discover_tests(dbcParserTests) +target_include_directories(dbcParserTests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) -add_executable(dbcParserParsemessageTests test_parseMessage.cpp common.cpp) -target_compile_definitions(dbcParserParsemessageTests PRIVATE TESTDBCFILES_PATH="${CMAKE_CURRENT_SOURCE_DIR}/dbcs") -target_link_libraries(dbcParserParsemessageTests PRIVATE dbc Catch2::Catch2WithMain) -if (${CMAKE_MINOR_VERSION} GREATER_EQUAL 23) - target_sources(dbcParserParsemessageTests PRIVATE FILE_SET HEADERS - TYPE HEADERS - BASE_DIRS ${CMAKE_CURRENT_SOURCE_DIR} - FILES defines.hpp) -else() - target_include_directories(dbcParserParsemessageTests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) -endif() -catch_discover_tests(dbcParserParsemessageTests) +catch_discover_tests(dbcParserTests) From cb415c7fb6ab40478574f6a5983f1618f2707208 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sat, 27 Jan 2024 13:20:02 -0500 Subject: [PATCH 024/131] Fully removed .cache directory --- .../index/common.cpp.E08560EA7108A3D6.idx | Bin 688 -> 0 bytes .../index/common.hpp.41CE9FCA42FA7760.idx | Bin 308 -> 0 bytes .../clangd/index/dbc.cpp.E3E6A77857D7C47A.idx | Bin 8106 -> 0 bytes .../clangd/index/dbc.hpp.1AE231EB8F8FCC79.idx | Bin 2258 -> 0 bytes .../index/defines.hpp.EC68A617B863B96B.idx | Bin 1340 -> 0 bytes .../clangd/index/error.hpp.A77A640A32416EE9.idx | Bin 624 -> 0 bytes .../index/message.cpp.F7C838DC6F61B691.idx | Bin 3034 -> 0 bytes .../index/message.hpp.9D53D7219D8F51C0.idx | Bin 2272 -> 0 bytes .../index/signal.cpp.BB48951555CC5AC5.idx | Bin 2252 -> 0 bytes .../index/signal.hpp.CBDEE5D1701AED97.idx | Bin 2032 -> 0 bytes .../index/test_dbc.cpp.BFE2FBF6ECE46A43.idx | Bin 26470 -> 0 bytes .../test_parseMessage.cpp.8E39780016C24013.idx | Bin 15392 -> 0 bytes .../index/test_utils.cpp.3E9CD9BC8124FDE8.idx | Bin 6604 -> 0 bytes .../clangd/index/utils.cpp.2A152B1CE2336D05.idx | Bin 1740 -> 0 bytes .../clangd/index/utils.hpp.9998710C28E0D597.idx | Bin 1110 -> 0 bytes 15 files changed, 0 insertions(+), 0 deletions(-) delete mode 100644 .cache/clangd/index/common.cpp.E08560EA7108A3D6.idx delete mode 100644 .cache/clangd/index/common.hpp.41CE9FCA42FA7760.idx delete mode 100644 .cache/clangd/index/dbc.cpp.E3E6A77857D7C47A.idx delete mode 100644 .cache/clangd/index/dbc.hpp.1AE231EB8F8FCC79.idx delete mode 100644 .cache/clangd/index/defines.hpp.EC68A617B863B96B.idx delete mode 100644 .cache/clangd/index/error.hpp.A77A640A32416EE9.idx delete mode 100644 .cache/clangd/index/message.cpp.F7C838DC6F61B691.idx delete mode 100644 .cache/clangd/index/message.hpp.9D53D7219D8F51C0.idx delete mode 100644 .cache/clangd/index/signal.cpp.BB48951555CC5AC5.idx delete mode 100644 .cache/clangd/index/signal.hpp.CBDEE5D1701AED97.idx delete mode 100644 .cache/clangd/index/test_dbc.cpp.BFE2FBF6ECE46A43.idx delete mode 100644 .cache/clangd/index/test_parseMessage.cpp.8E39780016C24013.idx delete mode 100644 .cache/clangd/index/test_utils.cpp.3E9CD9BC8124FDE8.idx delete mode 100644 .cache/clangd/index/utils.cpp.2A152B1CE2336D05.idx delete mode 100644 .cache/clangd/index/utils.hpp.9998710C28E0D597.idx diff --git a/.cache/clangd/index/common.cpp.E08560EA7108A3D6.idx b/.cache/clangd/index/common.cpp.E08560EA7108A3D6.idx deleted file mode 100644 index 1f0d602611925d50e0d828eadbe6bb72d6b729a8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 688 zcmWIYbaPw5#K7R3;#rZKT9U}Zz`!5`#Kk2=nI()23?i%y3>9ug)|`I9`o zW&7G^ZrFRe`IKjO)4pSS4?h2LKGdT6(!bYDyyrEK?KSS#mw2A&x!Uf;r$ZjImM<23 zy!!dos*hFTe80cu?T^wi=kI?VyJzp+`{#d8nAzkY=gOts94ctRH_egzw$@3}W6|07 zIGTgiB&Hv-+GIFQwW4U>x1Dy6`Ts9dnR-g~$Rsaz4V$#!x}v2^PICEA((bKPJy|Mq zEV89)zE8)ZbwAi2{!uhPWUg4ZDWCa0ALCB1L%z~MD^~XIc_(!&ew_rr#Ni#P=~~@K zmToFuF=uTs%b8Zc#G=DHJ{QenbMk zc}>o4xc_n871!d*+$2R{9Q?Em{^zrO?nfR5Nd^WfW>#hiX%NA{$;8MYF2N|x%21S= zRy+f!vTm;Q;vLSaFfnU3rW=C=n5vk0?Dz=T^rCS1F2{5BdW%*n$k z2@_5*U6Rwvo${CoD9pym4HM>(;$q{1^Y;F?F?wS->mx|76sJ5)5sYT!0=pCFBrqsS z%}E3?ii?tqm4P&))UrjJ7Kl%MT*@RZ!ypY-114k;%;emZ98n-wSXh*Wjfabuo0Ef` Ok5x!Oj9-vhgaH6}s1N@D diff --git a/.cache/clangd/index/common.hpp.41CE9FCA42FA7760.idx b/.cache/clangd/index/common.hpp.41CE9FCA42FA7760.idx deleted file mode 100644 index 9651fa27d618774bd216b48b6854d672abb6b445..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 308 zcmWIYbaT^TWMFVk@vO*AElFfyU|<`W`BKadsZZO!QQJ^zx|lq zrz4V@A5yCtRa=-hC3&9cH@`$R?GzOiV=I%_DsgkSu``@+Oo(~Q9@pb-k!BXnpUg_6fdrLbvQJ7?^#AJHbxFc0kB#i0W*M+6QU6+ dUX+@X2x1l&B^Psp7;Ivf89&uW>1r`B006g^VN3u3 diff --git a/.cache/clangd/index/dbc.cpp.E3E6A77857D7C47A.idx b/.cache/clangd/index/dbc.cpp.E3E6A77857D7C47A.idx deleted file mode 100644 index 9667712361b6624dbc0bf845b9412c2808eb6ea1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 8106 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 diff --git a/.cache/clangd/index/dbc.hpp.1AE231EB8F8FCC79.idx b/.cache/clangd/index/dbc.hpp.1AE231EB8F8FCC79.idx deleted file mode 100644 index 2600ce255ed01d853e0bc172c876804faf40529e..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2258 zcmYjS3s6*57(VCh;V!!zcJD5-!0x(t=gRK7%R^X6@r4hRP)AV2XE92$K2R({3r!r$ zN9y>9vB^LzYAiI-G06xSG7w+nqsed>mBgG>CN)#jd{yUO{h>Rv|K9!o?|+^1fB$BU zPD^VEMkqCJba6poaV|v&nfa$^apAlmj8Luyq2h{zTN@W1ak8~b%W_s-XfM39Y{v)v zhpjGNy&fIN{eAb@lwj{kO_I6knzrOv+y0BYg!S}9zrN+YKbyAk9C@e27Bb}e@&_Sz zIy3WE-1EhC$bV)I#nMl6H<>k$rSa1$(p*hr%s#rX;(%AGnSE+dpmuv|@k^H5`VmRL zn6x9e%xRvwGCe<8GcIk=ytB@#xv{N}T*Xb(Q06%lAJXrM@ma%Q11eft@Y-d9(DJGW&r%-; zh=KGlA{uLsjZy{T2dF$}!VZmmWA^o6kuW3D)#B({97iRq)C&OH3j6r7pVWjHh@Jbp zLR~#n0p@#cXu|!^!u zoR{dfx+PVBx$Ny9ThE-_E|N$d{w5Z0Vww5{eUE?(L^CJ8~`m zZjLd>NU8v{SoB9(SbI{rNJ4q|8XQr>^E*NvUHNy^<1bV8joNJ>Htrv9j<=}-{3GTs zDXGtC-D@BkZuXgdk}AMFF$;~W*A*QXiIs=1#9}43QoF(46@Js4jmJ{fq;wdFnfrSj z9=9sMKU#OEYWS})*DVBd|56-MihIyV9H|F@bYQw>Ws4y_QD1onloww>MQ=i(1hEZp@(+)$!sEp-cm@!5@;T}754Aj7Sl@c(@*%@Zf zjnctET1F*7V!#j{S8%fb#Z8wpy5q`ua(?$Ox8PlVM%m*M-o(xU3yx<~7D?|kJMBS){f`GW0 zU%4sTI=v-<5gnh;np#*$zkdbKQ)lDerra@KQ)H342aegy3{|Kgw2t z3Sr(kT3IQe)>q#-J-GazYf9_{IT>QZlHoy=)dFak53W`g3aFu79$VQapoUxHXk~%G z%)tWTqo`~TKo0>Rfr28k*-#=)U3@!?S*9;j9O;vsXext8Clx$hb%2h zU8RNX9mh4%4~0#=h^>+ScgdMc*3&Un~*x))z|ki-T3x-Qf@7 zOAaPgr&T*V$9{Kt-lpFg6MVby&9%{?HcdzA*Z0<{dwQE;e=Is)_*16~uBkB1aha+zibb>{`3QrUR`&xuWF7y zYeii=J4E?cOQOiEbndm+_QYkUSodQ(T>YqX0PxfGiGG_iZdVT zkeD1#9tZWFH?W;SHJ5H|(3EqJe_Rc6TN0w0x>pTMu-(t@@9bwkZ7Oj%3v!n|qe-3Qqauu!3HKGmBjh(sKv}NtH7A^WjEHE;gw?W>d_|TSD&K7tiUZF@EEEw( zWvs5b5aKH!Pn(~yv#n&R zS48w!39sdiz5=o>q0!ypW#7~88FcI`Z7_^Rws2br1KH=LcVK79Rf;_SZbU*rH z4@CwL!o)BsgQOe?HsNFiv5D+L1##24GzIY%K3zeAK`;Y?p6Q<+IkIwFlxuDP zbv=uj4V_Wfsd&~9*O}}h_yTpkfJ-0ZI)l#~;yO{739i!~d6QqS>z((XB9$)+L<+4^ zd-C-HdmvLIvpLs3yj-LQpk^cpgCYZCQV>>S3HGCh6OAV;h*h%^ z1VsoN&sr43sW}N^BZQm6B`Anj^Adze2p`9r6(pzy2|6Z3h!CO`MASqAlkf(0CI1EB m3O1p%eEWfR*mJVvwbPO9)W{1_E`x*QxZ@g@9C)r*iRd4stdchX diff --git a/.cache/clangd/index/error.hpp.A77A640A32416EE9.idx b/.cache/clangd/index/error.hpp.A77A640A32416EE9.idx deleted file mode 100644 index 71002806a83fe0f6ecfcf31956bb686e3e680b05..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 624 zcmWIYbaTsKVqkDi@vO*AElFfyU|h9N@k@E&+@7Z^1Bzl zR$Qu+BK~#d&#r54Gxyr(Y@R3ke0imQ=wta6wc8^1G90!Ht}L$1O_~pMAOGCt86GRs zOa+)Y*%_Dwcm)K(1Oo?94hWcoIyTKbAYsYG1o9jRFtKv63NUa&ID4Od`$0F!~KWQ6&xxG1?;9OMjUm|K9st;U`;huyIuijkQC03x=xod5s; diff --git a/.cache/clangd/index/message.cpp.F7C838DC6F61B691.idx b/.cache/clangd/index/message.cpp.F7C838DC6F61B691.idx deleted file mode 100644 index d33266e6ea6f111061ea4309f9aa7c99bf1b83a8..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 3034 zcmY*b3s6&68oo*HC9jhQA-OjY$U_nWlmL>JhZ5~dlnP5!paFzk@{kGwr3I^~Xqz1z z=~Aji+iqQJDOEdFw1RyhqOmNt;IOXjx}8$BpsUylEVc?NZQT=R&b@at1C#In?tlL8 zf1Lj&clokq!(t4}ShKvox@^50$1qF*|LWG)R_x(m*mpb(tKWAt@4I!H`SN#H6g6oS z;giRc@45%bkRIWtuZbmdC(93Zb~vA~oHWV|kF*a~?>%*i@Ez#hmsYpzPbV%`KD#6O z_Q>{Iug>;=lznHiUES+gH&)fuAF#?-ftKaQH}%qt3c`n-~GQV_+aVWtt$zNZ=)AplwRilbW|NQ z(VDC%UY_AM$zH4o-x*i$8xid`M(}>q>61cSvOL$OI)6Ix_9=bTr!|Sh&Se{;!RMkQ zAN#xZwRBaaAB#fyo5=f1i>eD?Vn z|G{4da@q-E?4JD76aF2(j)vjET3)+$XliZu58wW?<2$dNZrOiZ z-Nk#WyP>6iqVSvHwHJJIv9p`w?q*KT)K>~;%lh9Qc=nHlIp>!b8Bzu}MHJYg|6KeB zZn>~{!%JIJC-R5LlwIQ&ADlnm*ID7p@XDrV&opk-&K5V;ZL0P>ggx5ae7Q5Xe>Pdp z4GYJpTt%*u)Qj{06F?4r?7aA6GZWn_0T!Xbs8VSuNhV2?NKDA(V0smYB=QEzrr-Vf zV~?C03jH0C4hyN%=uF7}@KDsP&8<;e$UR5C#23UlSC0f2H6PJlE6sx+xI4OM?o zQ-4iZFC{oQwL-8W7#)!BP?&GMkxt++rcIW?#FQ1uN*Ux3J7^aeCC8bEqRfx$D<9aR z2;%@s5ur#xE_bK?^W|5&3Qf>lC@7>g1%J|SFP1)d5}M5tGl`x?3Ge^~RDeQN5j`Fz zrhYEHYaYsHD4}DX>Ud8|5TIgHV;7;50A)$DEM`z*S|STs)2u9HOSQ55>)Qpc;^vM{ah=3PC z=BK$h6~qgo&&4SLPe3C>Wy+hk2NE*)fQk%@)FNM4F@xE}plC%jT|Ypj#HA!M+ydi* zXa=Q6rkfd*5t>2kL2^0V$M=$#+tl@rU!7L+{*#KUC7-O~!Vw}$0eT7|ZK(;Nt1qFT=%wW@Sv6zqEPdmB7<_i9QrPU8%Qy*7&Qf zEHE_DvGK?Z<-}O%(SF{j zJ4!U+%}`FZI9rKCx5N5H3a7yqPJb{seuf&}Ua$1~L zuixQERA@pYJ3k+MjI%<=tCgdMs$)k*+L$x#ZCNOjO2v_IKlF76yXltVlsDK*BWc>uqgU2|K3GwiP^Ljg z!SyRtuu!HTGYoOB{r9D3B+6I%U{dTw11B>N6d_FzxxrcndDUKeGX1H;OByCQgRr?p zL{SLJl{>QM)roWO{T-SMC51|4-rKo4f864`0u>TGg7r28LLgxRS8!!zmks;Fan zD1Gm5H(^!qU_2BJ1fU}L5i;ZpmmAMOFCqB4#c~BmG|CrtG4RU(by0PC?&AJ!n%i)G zU7;=wx|j>JcLpni+;;@fOt|>S43WuYW{{h3vpBcTZD2SL;bCzeorlGF2``KD>bx}f zj!)w0?i&3Gwj;}sWoCxhp>U|t{)D$S-?n+a diff --git a/.cache/clangd/index/message.hpp.9D53D7219D8F51C0.idx b/.cache/clangd/index/message.hpp.9D53D7219D8F51C0.idx deleted file mode 100644 index 8533b199c9c30ddb0426701cf6aa380e7eb67f47..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2272 zcmYjT4Nz276u$2*yRhrsyN~_jZ`}o5R)JkuS0OO+4>6HK7s=2_lf=+~2*eCbArzSu zMUZhcZDh*qE^LhNKaX}(gh);q`&NSS!)UygmOd(Z8&hW+#cI%iR{OY;)3L%`(uDrH%`){NiP)nN5#g8=hBFoc_3|FLs??l)1aSGdOal$FptUK6#pa zZj#T9shd#tr|HS3ScJYAYO0L-*N2s`u3AK7t}-GBB&E|rh#}%&bK{fq)=F0el6WDa zWR;vC1P4z{9byafblkE6wF0?N2NkRG6ok{^_X~&EB@3H0TGrJAk#Wp8H$fn}AN(`L z+?v{%r}S1JF^%U~PAv#$eD3yZ$K%_^!Z=pr@gjuy%6u`zm-WhL5mFmTSUpW2Bn?ss z0?czo!N*1i8y8{Zt93-%h)s*6EQ2P>Y5j{kQyv~1u1n@vHKaHA82lmrx3xy*-rSZo zg!Q561Lc7#L4dio+ti<1X3FE(aS*MS=#^le-8Hu_RB^mefkd=9ch;Q~gtNJ`r$_NW z;cdkn>j&{BV$wo9cVK>U+O3Z&1?+_K36^1ZFyArXXfN2k^fMK1_2hxSAl zyZbaYbL<32u2buL!Av5$pXaZ_tzzUxqX{N@L4bM3Upe#T>iky1>ZsW)H>(5z=KaT) zCET+VTqmqIH3!H7h#mD9|%O%0(%^4pbb^?oPp|rE>taW#o-MkVWa{%z#GUxy?JJU8X9C6 z!jl0|OZs}6@dNPGroF|*uhW~fc+x+2lFzEKJM}@_S^g70kaf}rq z0EZUGQwyp9YO$D1kWNs*#AO1(zzGOOV|ikM8i+-25?JMcVcU~)_Y>@6TSRo^;dmy{ zhfZv&Zn|?~K}?VvKm&_FvEZ2p7gTaf=iCfmU&7FdCKx}2i7u8#H>am?J0u>%|7fF{lh)ussyVH;nO+fl^Cu zQ2{i7HLZ~UR6yRWl(d!nS2H{7{p{EI7yeI(;~}vzAv3y{Z1NU!?h2&}abQ45<$QH_ JzABur{{j0uzQq6l diff --git a/.cache/clangd/index/signal.cpp.BB48951555CC5AC5.idx b/.cache/clangd/index/signal.cpp.BB48951555CC5AC5.idx deleted file mode 100644 index e1b81c962bf6f0165be0016beda9a0f3a9e02d42..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2252 zcmY*a2~ZPP7~W*F3CCu0ke7tS?5-x5dl#buDq0k=r6?Bgs1=z3jn)#X1vnHIh|2UB4{$Upty%#=L7if~>axxxhoaqc~uI47}?@K$c-M=OxszV&ZdRoaxJ=*0 z1$r_nicVLyl&`Nl(R_S^Jg5GqCVE%QmQRj+rD@XD7e8At?yY(IuJ~%g8+(_Oe8HH#*J+~nN&8CY_+naT#HQnJlme%xy+RP;xbLwleH5&t;`)_x@ zx2^Wwo&P+4R+HFnShn`n;O^k1v0>W-&(8dC?Nr=575Qr&=~wJ^!z%4-pByQxS{?My zS-wTto^yW2vKtes&NQ4%OgQ*K4>m8iKz?a<(9&XjN(ZVFPRyCqbpO)o!^}^Z+0vR( zqv$`l<@)96S&s*MYG>ld;ybaTvVy!-u+uF@MMK5xt2rbVt;c|!vg>uRRIDBgmr5{m zltf3Aw4U46`D=HDUaB=<01v|{9TUN*F?ec2S1`V+zx30KEo!L|(pIGv=)7_-h3FLp z9aA2hebla&njmdaT7b?&dGv@b^e--|lw;ThbLo%ar4%8N0TXT_QO;TETKg|s6A1|k zs7OkKmj8Tsud}E2%@`R8RJclkmPtUX=qQvCA~Veh$iX^nXtSE5XQ$4mo{oV5bhs{* zjs#2sGg)w9QkhHvc^R(*1?c6QM}R{o<8cz`aecT@0h7Zl5?q)7Q;3l4^i5wzS>AY< z(|{Y~B9~Rn8VRz3C2Wu|n?;y2a3++toy*$oyT2((D*NBYWgr@l4z*!;e*8!M=lNuq zNQ-Mj%dj77B=kB_WV%{HZxvy;(LD@hstZ26d-X6e4F(a%CILH=bqU3?J~mE3d^8UQ z_@AD#o5pDGWFO6tlE6;bNwf?RZI40d&hkC?+g2*(%1NNXHKKE%=hLD#(gFH?A&V`{ zra`JBfz4odAq&GY z9szk6j~m6yXD7B+KA-4^q69byo&D*R=Wl&2`6D036-yX)YzmtuL}IhpYypijjk2P+ z)^nE!yi?OkVE`j;6bXbSS(V_z8d#HnIG*#N0B9?ch?ir!V~sNJc(CtrR(Q&(0>8Qj zY8BVvCS*kdWu!7RQgFZwlm&69p|EvB6OAJ6DfqCn&(?Pk%8%C3dQ^oBux{3i5V}L( zp>apP$|a`wr3Z#};4DkGQewjoq&9DUl>9M+WceZO7C5V={Pl~MavL5I2S_h z5x#uGUivodni^M&_Cverai|uk{mJx90XbPGhXO=2Kk7|vc=0n7Dj_E*)B+O7NiBR#U>ytVU0wBCV|yrwF=1YvnQZbh5kV9&=;+!aAA>Q s=s`F1_wteeyJFqh-Y>r|m*}vC1&ab|xJ*%MS(ri|PADTa5hSkq7gTvhng9R* diff --git a/.cache/clangd/index/signal.hpp.CBDEE5D1701AED97.idx b/.cache/clangd/index/signal.hpp.CBDEE5D1701AED97.idx deleted file mode 100644 index 78ca30d745acfdb660a4749067b3c8ba74244978..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 2032 zcmY+E3rtg27{~8Dw6~|X=N@hgl+t#T=LSf%c1)3#kbyvmiufRN(P)Y=ofTbpSR5*Q zn8gV=#HfSJ#RYsN=w?+mXLQKs12Y%JJ=}Z@wjnT>kGafso6F9YI- zcYa^z7Ubm(={PQ@w4kQEtjeq5IL^erl~oll%;Gt2FXFhGw;P*R`?_87**k6FRqkiV zM}F@X_xenYclC_c#UqVVl8?7dW7!@Oyf1W+WZROWt_(TOs$}!IZ;+jI`yR`aRB~ zj-18$!DC03>|c8LeDzl;=Z4%jI$v!#l=JC|3rq9wUcOUxtuu0<>vs0=zF@7VV(0zC7~Z==|4OX zj5|HOeI&DMQg-E#$W^W_FFC|I`s?i1*yeYfCaH3TLqeTMVi|9P699eWYhn z4n;N=hlycS6^M5PZueg~tj(jy!D6dqHL3#f%@=nMoLZ-QmLfZgO`<7G6^IX7bggy8 zR~8e_B9EN~yQs^|=@HL8rsc7=Uq3&$-hZQnB8jaJ7s5@dz*lGhdI8=f7R>HhLn}Wt>bv2IWqjjo49GLq0NKO0a2W1oq zn>z(3g?RK*oqyJef&fJ^CJqw=kyU}%)$H{>nBzS~k-%b!N>QpnTwC6iJ$mNu$1;k7 z%~NTr8RD+=-t2Wh^A{+JW|i9?x2LHB@q{?HFLHnM4T>m>je;>;6^L72kxGsS`hF2m z2a&g8 zB-D{F@ghbTna8^Rh<|1)@IwW_J+l?)!3N%$t-ua8aL#N6aZ z@1~h2~5$w{s$T+{)741rdUjRK@s}K)sA?A4%@{qZk0xeyZX@EF;Tj3kt2DF*2 za1Azek=Y8*U<1m`RyYP5`pWCEf-cyAE)rE_!Dcrj*%RPq=IL`!mY2y}bOcK}Ndn{u zmIax>KN7)K!AhW6?4nIJ3zSH(!|bp_2?QsL$>SHzuHBq6p24iJ>Xku(dSFIa!<5+o z8)k#OtqcYn1`1@hG7w zhyE}Y-L7=Ni>oMG=~X7DvSMlF)5?QEk+IL%kgCrFJdP6|J>nx(F~=q}4Su81iw45| E1AD8r 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 diff --git a/.cache/clangd/index/test_parseMessage.cpp.8E39780016C24013.idx b/.cache/clangd/index/test_parseMessage.cpp.8E39780016C24013.idx deleted file mode 100644 index 2a12242f20a960b928cf61a14aee852dcb8fbd50..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 15392 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 ZBdc&tfiDA8DlsXOQj#eOwOlEp{{gu&lDGf> diff --git a/.cache/clangd/index/utils.hpp.9998710C28E0D597.idx b/.cache/clangd/index/utils.hpp.9998710C28E0D597.idx deleted file mode 100644 index b442b46c08ad6d4952b16a4de5861b11ff471a1b..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 1110 zcmWIYbaV4#VPJ4h@vO*AElC728H9kixTGla5|IAP$iPrBXX?a*d50Bv+A3$pCU4#S z^v2r_$xCe+l#clBk?J{+QT=Dpg3!0RQ!nuU`}@*e;`3U`*dIlOX=j#&iij609us5; z{`C%HvC6Smo@E_kuitS2)|c7<2WF1~E9 z??0kG$$rg09vodzA>VhHQAU4~=k*Qj`=-1VtPYqY9&z+d$S1jNZ~Ap>k8!U`?b;!$ z^v`r+hI-k@TYrm|ri50#zv%Ci73E=Y+hcd%4VCKx!uvW(2E zJ+Gtgmeo&k5@O;51sD)8D~c#e!1Ui2JG1Pqaf3O`KaTz2e;YsJDH{tb8#@Ol13OF+11uGR1XvNGYzQU*K_Ou~ From fb72986bac2e67d90e33eca416062e05aaae849d Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sat, 27 Jan 2024 13:31:38 -0500 Subject: [PATCH 025/131] Updated the test yaml to use pure cmake commands. Updated the README to reflect how to build. --- .github/workflows/tests.yml | 8 ++------ .gitignore | 4 +++- README.md | 29 ++++++++++++----------------- 3 files changed, 17 insertions(+), 24 deletions(-) diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index dd213b5..4cf02b7 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -22,14 +22,10 @@ jobs: run: cmake -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -Bbuild -H. - name: Build the library - run: | - cd build - make -j$(nproc) + run: cmake --build build - name: Run unit tests - run: | - cd build - ctest --output-on-failure + run: ctest --output-on-failure --test-dir build format-check: runs-on: ubuntu-latest diff --git a/.gitignore b/.gitignore index 4705a45..fcb11cc 100644 --- a/.gitignore +++ b/.gitignore @@ -1,6 +1,7 @@ # Build folders bin/ build/ +Testing/ # -- Git -- # *.bak @@ -15,4 +16,5 @@ __pycache__/ *.sublime-* # -- Static Analyzers -- # -.cache/ \ No newline at end of file +.cache/ + diff --git a/README.md b/README.md index 438ef36..03c475f 100644 --- a/README.md +++ b/README.md @@ -4,19 +4,6 @@ This is to provide a library header only file to read in DBC files. I was lookin find a simple library that didn't have dependencies. So here we are making one. I got some inspiration from the python dbc library here: https://pypi.org/project/cantools/ -## Testing - -I am trying to always make sure that this is very well tested code. I am using Catch2 to do this -testing and if you aren't familiar here is the documentation: https://github.com/catchorg/Catch2/blob/master/docs/Readme.md#top - -To run the tests locally you can use the following: -```bash -mkdir build -cd build -cmake .. -make test -j -``` - ## Building I am using Cmake to be able to build the tests and the lib. I plan on doing more with it but this is what it @@ -26,10 +13,18 @@ needs. Feel free to submit changes so the building process will be more robust. Here are the steps to get started: ```bash -mkdir build -cd build -cmake .. -make +cmake -DCMAKE_BUILD_TYPE=Release -Bbuild -H. +cmake --build build +``` + +## Testing + +I am trying to always make sure that this is very well tested code. I am using Catch2 to do this +testing and if you aren't familiar here is the documentation: https://github.com/catchorg/Catch2/blob/master/docs/Readme.md#top + +To run the tests locally you can use the following. Assuming you have built the project you should get a test executable. +```bash +ctest --output-on-failure --test-dir build ``` ## Scripts From 915c8a22a19c0e00ae0224c1269870beee77611c Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sat, 27 Jan 2024 13:44:23 -0500 Subject: [PATCH 026/131] Cleaning up the cmake some by moving options to the top and adding a documentation flag to generate doxygen documentation --- CMakeLists.txt | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e4b9f15..d038399 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,14 @@ cmake_minimum_required(VERSION 3.16) project(dbc VERSION 0.2.0 DESCRIPTION "C++ DBC Parser") +# -- PROJECT OPTIONS -- # +option(DEBUG "use debug flag" NO) +option(ENABLE_TESTS "Enable Unittests" ON) +# Turn OFF, if you are using FetchContent to include it to your project +option(FETCH_CONTENT_INCLUSION "Include project with FetchContent_Declare in another project. In this case the headers and the cmake files are not needed, only the library" OFF) +option(GENERATE_DOCS "Use doxygen if installed to generated documentation files" OFF) +# ---------------------- # + set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # package @@ -12,11 +20,6 @@ set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE) set(CPACK_RESOURCE_FILE_README ${CMAKE_CURRENT_SOURCE_DIR}/README.md) include(CPack) -option(DEBUG "use debug flag" NO) -option(ENABLE_TESTS "Enable Unittests" ON) -# Turn OFF, if you are using FetchContent to include it to your project -option(FETCH_CONTENT_INCLUSION "Include project with FetchContent_Declare in another project. In this case the headers and the cmake files are not needed, only the library" OFF) - # defines variables used in the dbc.pc.in include(GNUInstallDirs) @@ -73,7 +76,9 @@ if(ENABLE_TESTS) add_subdirectory(test) endif() -add_subdirectory(doc) +if(GENERATE_DOCS) + add_subdirectory(doc) +endif() add_library(${PROJECT_NAME} STATIC ${SOURCE}) target_link_libraries(${PROJECT_NAME} FastFloat::fast_float) From d20f5a7fbd027441d949930258ea981afb61e4ec Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sat, 27 Jan 2024 14:02:02 -0500 Subject: [PATCH 027/131] Adding commands to show the options of this library for cmake --- README.md | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/README.md b/README.md index 03c475f..27c42bb 100644 --- a/README.md +++ b/README.md @@ -17,6 +17,19 @@ cmake -DCMAKE_BUILD_TYPE=Release -Bbuild -H. cmake --build build ``` +### Listing Build Options + +You can check the latest build options with cmake. After you configure cmake you can run this. +```shell +cd build + +# List this projects options +cmake -LH .. | grep -B1 "DBC_" + +# To see all the included project cache variables and options +cmake -LAH .. +``` + ## Testing I am trying to always make sure that this is very well tested code. I am using Catch2 to do this From bdb526ecfc460b9062f729b9686cd085fdb9f264 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sat, 27 Jan 2024 14:10:39 -0500 Subject: [PATCH 028/131] Adding prefix to the options in cmake and removing global include directories --- CMakeLists.txt | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d038399..3d5d16c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -4,10 +4,10 @@ project(dbc VERSION 0.2.0 DESCRIPTION "C++ DBC Parser") # -- PROJECT OPTIONS -- # option(DEBUG "use debug flag" NO) -option(ENABLE_TESTS "Enable Unittests" ON) +option(DBC_ENABLE_TESTS "Enable Unittests" ON) # Turn OFF, if you are using FetchContent to include it to your project -option(FETCH_CONTENT_INCLUSION "Include project with FetchContent_Declare in another project. In this case the headers and the cmake files are not needed, only the library" OFF) -option(GENERATE_DOCS "Use doxygen if installed to generated documentation files" OFF) +option(DBC_FETCH_CONTENT_INCLUSION "Include project with FetchContent_Declare in another project. In this case the headers and the cmake files are not needed, only the library" OFF) +option(DBC_GENERATE_DOCS "Use doxygen if installed to generated documentation files" OFF) # ---------------------- # set(CMAKE_EXPORT_COMPILE_COMMANDS ON) @@ -68,27 +68,26 @@ set(HEADER_FILES ${PROJECT_SOURCE_DIR}/include/libdbc/exceptions/error.hpp ) -include_directories(src) -include_directories(include) - -if(ENABLE_TESTS) +if(DBC_ENABLE_TESTS) include(CTest) add_subdirectory(test) endif() -if(GENERATE_DOCS) +if(DBC_GENERATE_DOCS) add_subdirectory(doc) endif() add_library(${PROJECT_NAME} STATIC ${SOURCE}) target_link_libraries(${PROJECT_NAME} FastFloat::fast_float) +target_include_directories(${PROJECT_NAME} PUBLIC + $ + $ +) -if (${CMAKE_MINOR_VERSION} GREATER_EQUAL 23) - target_sources(${PROJECT_NAME} INTERFACE FILE_SET HEADERS - TYPE HEADERS - BASE_DIRS ${PROJECT_SOURCE_DIR}/include/libdbc - FILES ${HEADER_FILES}) -endif() +target_sources(${PROJECT_NAME} INTERFACE FILE_SET HEADERS + TYPE HEADERS + BASE_DIRS ${PROJECT_SOURCE_DIR}/include/libdbc + FILES ${HEADER_FILES}) add_custom_target(release WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} @@ -107,12 +106,12 @@ if (${CMAKE_MINOR_VERSION} GREATER_EQUAL 23 AND NOT FETCH_CONTENT_INCLUSION) DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lib${PROJECT_NAME} INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} ) -elseif(NOT FETCH_CONTENT_INCLUSION) +elseif(NOT DBC_FETCH_CONTENT_INCLUSION) install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/libdbc DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) endif() -if (NOT FETCH_CONTENT_INCLUSION) +if (NOT DBC_FETCH_CONTENT_INCLUSION) # Generate pkg-config file configure_file(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY) install( From 8b92f62a0b26b3d9f56a3cd811330642a965a521 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sat, 27 Jan 2024 15:18:56 -0500 Subject: [PATCH 029/131] Removing anonymous name space --- src/dbc.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/dbc.cpp b/src/dbc.cpp index 63043d3..3849e65 100644 --- a/src/dbc.cpp +++ b/src/dbc.cpp @@ -5,7 +5,7 @@ #include -namespace { +namespace libdbc { const auto floatPattern = "(-?\\d+\\.?(\\d+)?)"; // Can be negative @@ -139,9 +139,6 @@ bool parseVal(const std::string& str, VALObject& obj) { return false; } -} // anonymous namespace - -namespace libdbc { DbcParser::DbcParser() : version("") From 5e1a8fc6c4311f44ec5278d6ab4fc9c4c6337bd7 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sat, 27 Jan 2024 20:36:39 -0500 Subject: [PATCH 030/131] Adding in a locale test to ensure we aren't dependent on the system locale settings when converting floats See #8 for an example --- include/libdbc/utils/utils.hpp | 2 + src/dbc.cpp | 17 ++--- src/utils.cpp | 10 +++ test/CMakeLists.txt | 13 ++++ test/locale_testing/test_locale_main.cpp | 80 ++++++++++++++++++++++++ 5 files changed, 111 insertions(+), 11 deletions(-) create mode 100644 test/locale_testing/test_locale_main.cpp diff --git a/include/libdbc/utils/utils.hpp b/include/libdbc/utils/utils.hpp index a7dde52..21ff540 100644 --- a/include/libdbc/utils/utils.hpp +++ b/include/libdbc/utils/utils.hpp @@ -42,6 +42,8 @@ class String { cont.push_back(token); } } + + static double convert_to_double(const std::string& value, double default_value = 0); }; } diff --git a/src/dbc.cpp b/src/dbc.cpp index 3849e65..fea6aea 100644 --- a/src/dbc.cpp +++ b/src/dbc.cpp @@ -1,4 +1,3 @@ -#include #include #include #include @@ -139,7 +138,6 @@ bool parseVal(const std::string& str, VALObject& obj) { return false; } - DbcParser::DbcParser() : version("") , nodes() @@ -257,15 +255,12 @@ void DbcParser::parse_dbc_messages(const std::vector& lines) { uint32_t size = std::stoul(match.str(4)); bool is_bigendian = (std::stoul(match.str(5)) == 0); bool is_signed = (match.str(6) == "-"); - // Alternate groups because a group is for the decimal portion - double factor; - fast_float::from_chars(match.str(7).data(), match.str(7).data() + match.str(7).size(), factor); - double offset; - fast_float::from_chars(match.str(9).data(), match.str(9).data() + match.str(9).size(), offset); - double min; - fast_float::from_chars(match.str(11).data(), match.str(11).data() + match.str(11).size(), min); - double max; - fast_float::from_chars(match.str(13).data(), match.str(13).data() + match.str(13).size(), max); + + double factor = utils::String::convert_to_double(match.str(7).data()); + double offset = utils::String::convert_to_double(match.str(9).data()); + double min = utils::String::convert_to_double(match.str(11).data()); + double max = utils::String::convert_to_double(match.str(13).data()); + std::string unit = match.str(15); std::vector receivers; diff --git a/src/utils.cpp b/src/utils.cpp index bd6e4fd..35cff0c 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -1,3 +1,6 @@ +#include +#include +#include #include #include @@ -69,4 +72,11 @@ std::string String::trim(const std::string& line) { return start == end ? std::string() : line.substr(start, end - start + 1); } +double String::convert_to_double(const std::string& value, double default_value) { + double converted_value = default_value; + fast_float::from_chars(value.data(), value.data() + value.size(), converted_value); + // converted_value = std::stod(value); + return converted_value; +} + } // Namespace Utils diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index ce3bd4f..791b96a 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -22,3 +22,16 @@ target_link_libraries(dbcParserTests PRIVATE dbc Catch2::Catch2WithMain) target_include_directories(dbcParserTests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) catch_discover_tests(dbcParserTests) + +# We want a seperate binary for this test. We setup global locals which mess with all of the testing. +# Opting for a sperate test running so we don't conflict +add_executable(dbcLocaleTests + locale_testing/test_locale_main.cpp + common.cpp +) + +target_compile_definitions(dbcLocaleTests PRIVATE TESTDBCFILES_PATH="${CMAKE_CURRENT_SOURCE_DIR}/dbcs") +target_link_libraries(dbcLocaleTests PRIVATE dbc Catch2::Catch2WithMain) +target_include_directories(dbcLocaleTests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) + +catch_discover_tests(dbcLocaleTests) diff --git a/test/locale_testing/test_locale_main.cpp b/test/locale_testing/test_locale_main.cpp new file mode 100644 index 0000000..7ffddfa --- /dev/null +++ b/test/locale_testing/test_locale_main.cpp @@ -0,0 +1,80 @@ +#include "common.hpp" +#include "defines.hpp" +#include +#include + +#include +#include +#include +#include + +class testRunListener : public Catch::EventListenerBase { +public: + using Catch::EventListenerBase::EventListenerBase; + + void testRunStarting(Catch::TestRunInfo const&) override { + prev_loc = std::setlocale(LC_ALL, nullptr); + // Set the locale to something that has , instead of . for floats + std::locale::global(std::locale("de_DE.UTF-8")); + } + + void testCaseEnded(Catch::TestCaseStats const&) override { + // Restore the old locale + std::locale::global(std::locale(prev_loc)); + } + +private: + std::string prev_loc; +}; + +CATCH_REGISTER_LISTENER(testRunListener) + +TEST_CASE("Should parse doubld string locale independently") { + REQUIRE(Catch::Approx(utils::String::convert_to_double("6.82")) == 6.82); +} + +TEST_CASE("Should process message with floats locale indpendently") { + const auto* filename = std::tmpnam(NULL); + + create_tmp_dbc_with(filename, R"(BO_ 234 MSG1: 8 Vector__XXX + SG_ Sig1 : 55|16@0- (0.1,0) [-3276.8|-3276.7] "C" Vector__XXX + SG_ Sig2 : 39|16@0- (0.1,0) [-3276.8|-3276.7] "C" Vector__XXX + SG_ Sig3 : 23|16@0- (10,0) [-3276.8|-3276.7] "C" Vector__XXX + SG_ Sig4 : 7|16@0- (1,-10) [0|32767] "" Vector__XXX)"); + + auto parser = libdbc::DbcParser(); + parser.parse_file(filename); + + REQUIRE(parser.get_messages().size() == 1); + REQUIRE(parser.get_messages().at(0).name() == "MSG1"); + REQUIRE(parser.get_messages().at(0).getSignals().size() == 4); + + SECTION("Evaluating first message") { + const auto signal = parser.get_messages().at(0).getSignals().at(0); + REQUIRE(signal.factor == 0.1); + REQUIRE(signal.offset == 0); + REQUIRE(signal.min == -3276.8); + REQUIRE(signal.max == -3276.7); + } + SECTION("Evaluating second message") { + const auto signal = parser.get_messages().at(0).getSignals().at(1); + REQUIRE(signal.factor == 0.1); + REQUIRE(signal.offset == 0); + REQUIRE(signal.min == -3276.8); + REQUIRE(signal.max == -3276.7); + } + SECTION("Evaluating third message") { + const auto signal = parser.get_messages().at(0).getSignals().at(2); + REQUIRE(signal.factor == 10); + REQUIRE(signal.offset == 0); + REQUIRE(signal.min == -3276.8); + REQUIRE(signal.max == -3276.7); + } + SECTION("Evaluating fourth message") { + const auto signal = parser.get_messages().at(0).getSignals().at(3); + REQUIRE(signal.factor == 1); + REQUIRE(signal.offset == -10); + REQUIRE(signal.min == 0); + REQUIRE(signal.max == 32767); + } +} From 35a9502077afca292f3cb2aa21872dec1adb34b4 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sat, 27 Jan 2024 20:56:55 -0500 Subject: [PATCH 031/131] Removing the custom debug option for in favor of CMAKE_BUILD_TYPE arg. Added an option to enable the locale testing since it is platform specific and dependent --- CMakeLists.txt | 23 +++++++++-------------- README.md | 12 +++++++++++- test/CMakeLists.txt | 20 ++++++++++++-------- 3 files changed, 32 insertions(+), 23 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 3d5d16c..1f8b384 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,8 +3,8 @@ cmake_minimum_required(VERSION 3.16) project(dbc VERSION 0.2.0 DESCRIPTION "C++ DBC Parser") # -- PROJECT OPTIONS -- # -option(DEBUG "use debug flag" NO) option(DBC_ENABLE_TESTS "Enable Unittests" ON) +option(DBC_TEST_LOCALE_INDEPENDENCE "Used to deterime if the libary is locale agnostic when it comes to converting floats. You need `de_DE.UTF-8` locale installed for this testing." OFF) # Turn OFF, if you are using FetchContent to include it to your project option(DBC_FETCH_CONTENT_INCLUSION "Include project with FetchContent_Declare in another project. In this case the headers and the cmake files are not needed, only the library" OFF) option(DBC_GENERATE_DOCS "Use doxygen if installed to generated documentation files" OFF) @@ -45,22 +45,17 @@ set(GCC_COMPILE_FLAGS "-Wextra -Wall -Wfloat-equal -Wundef -Wshadow \ -Waggregate-return -Wcast-qual -Wswitch-default -Wswitch-enum -Wconversion \ -Wunreachable-code -Wformat=2 -Werror -Wuninitialized -Winit-self") -if(DEBUG) - set(GCC_COMPILE_FLAGS ${GCC_COMPILE_FLAGS}" -g") -else() - set(GCC_COMPILE_FLAGS ${GCC_COMPILE_FLAGS}" -O2") -endif() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}") # add where to find the source files -# file(GLOB_RECURSE SOURCE ${PROJECT_SOURCE_DIR}/src/ *.cpp) -list(APPEND SOURCE ${PROJECT_SOURCE_DIR}/src/utils.cpp - ${PROJECT_SOURCE_DIR}/src/message.cpp - ${PROJECT_SOURCE_DIR}/src/signal.cpp - ${PROJECT_SOURCE_DIR}/src/dbc.cpp) +list(APPEND SOURCE_FILES + ${PROJECT_SOURCE_DIR}/src/utils.cpp + ${PROJECT_SOURCE_DIR}/src/message.cpp + ${PROJECT_SOURCE_DIR}/src/signal.cpp + ${PROJECT_SOURCE_DIR}/src/dbc.cpp +) -set(HEADER_FILES +list(APPEND HEADER_FILES ${PROJECT_SOURCE_DIR}/include/libdbc/dbc.hpp ${PROJECT_SOURCE_DIR}/include/libdbc/message.hpp ${PROJECT_SOURCE_DIR}/include/libdbc/signal.hpp @@ -77,7 +72,7 @@ if(DBC_GENERATE_DOCS) add_subdirectory(doc) endif() -add_library(${PROJECT_NAME} STATIC ${SOURCE}) +add_library(${PROJECT_NAME} STATIC ${SOURCE_FILES}) target_link_libraries(${PROJECT_NAME} FastFloat::fast_float) target_include_directories(${PROJECT_NAME} PUBLIC $ diff --git a/README.md b/README.md index 27c42bb..d9f37e8 100644 --- a/README.md +++ b/README.md @@ -7,13 +7,19 @@ from the python dbc library here: https://pypi.org/project/cantools/ ## Building I am using Cmake to be able to build the tests and the lib. I plan on doing more with it but this is what it -is for now. I am doing developement on the WSL Ubuntu 18.04 kernel. This doesn't mean that IDEs aren't +is for now. This doesn't mean that IDEs aren't welcome but the build process might not be suited for this. You will need to modify it for your needs. Feel free to submit changes so the building process will be more robust. Here are the steps to get started: ```bash +# Release Build cmake -DCMAKE_BUILD_TYPE=Release -Bbuild -H. + +# Debug Build +cmake -DCMAKE_BUILD_TYPE=Debug -Bbuild -H. + +# Run the build cmake --build build ``` @@ -35,6 +41,10 @@ cmake -LAH .. I am trying to always make sure that this is very well tested code. I am using Catch2 to do this testing and if you aren't familiar here is the documentation: https://github.com/catchorg/Catch2/blob/master/docs/Readme.md#top +There is one option you will want for testing: `DBC_TEST_LOCALE_INDEPENDENCE`. This requires the `de_DE.UTF-8` locale installed to test. It is for checking we don't rely on locale to convert floats. i.e. 1.23 vs 1,23 + +You will need to configure the project to enable this: `cmake -DCMAKE_BUILD_TYPE=Release -DDBC_TEST_LOCALE_INDEPENDENCE=ON -Bbuild -H.`. You will get a warning if it isn't enabled because it isn't enabled by default. + To run the tests locally you can use the following. Assuming you have built the project you should get a test executable. ```bash ctest --output-on-failure --test-dir build diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 791b96a..e19344a 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -25,13 +25,17 @@ catch_discover_tests(dbcParserTests) # We want a seperate binary for this test. We setup global locals which mess with all of the testing. # Opting for a sperate test running so we don't conflict -add_executable(dbcLocaleTests - locale_testing/test_locale_main.cpp - common.cpp -) +if(DBC_TEST_LOCALE_INDEPENDENCE) + add_executable(dbcLocaleTests + locale_testing/test_locale_main.cpp + common.cpp + ) -target_compile_definitions(dbcLocaleTests PRIVATE TESTDBCFILES_PATH="${CMAKE_CURRENT_SOURCE_DIR}/dbcs") -target_link_libraries(dbcLocaleTests PRIVATE dbc Catch2::Catch2WithMain) -target_include_directories(dbcLocaleTests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) + target_compile_definitions(dbcLocaleTests PRIVATE TESTDBCFILES_PATH="${CMAKE_CURRENT_SOURCE_DIR}/dbcs") + target_link_libraries(dbcLocaleTests PRIVATE dbc Catch2::Catch2WithMain) + target_include_directories(dbcLocaleTests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) -catch_discover_tests(dbcLocaleTests) + catch_discover_tests(dbcLocaleTests) +else() + message(WARNING "Locale independent testing is turned off!") +endif() From 5a7a2261b75d88913e844ed676f83fc5b978a872 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 07:24:07 -0500 Subject: [PATCH 032/131] Removed unknown include, remove setting cmake_cxx_flags, renamed `DBC_FETCH_CONTENT_INCLUSION` -> `DBC_GENERATE_PKGCONFIG` --- CMakeLists.txt | 29 +++++++---------------------- 1 file changed, 7 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 1f8b384..6868806 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,12 +1,15 @@ cmake_minimum_required(VERSION 3.16) -project(dbc VERSION 0.2.0 DESCRIPTION "C++ DBC Parser") +project(dbc + VERSION 0.2.0 + DESCRIPTION "C++ DBC Parser" +) # -- PROJECT OPTIONS -- # option(DBC_ENABLE_TESTS "Enable Unittests" ON) option(DBC_TEST_LOCALE_INDEPENDENCE "Used to deterime if the libary is locale agnostic when it comes to converting floats. You need `de_DE.UTF-8` locale installed for this testing." OFF) # Turn OFF, if you are using FetchContent to include it to your project -option(DBC_FETCH_CONTENT_INCLUSION "Include project with FetchContent_Declare in another project. In this case the headers and the cmake files are not needed, only the library" OFF) +option(DBC_GENERATE_PKGCONFIG "Include project with FetchContent_Declare in another project. In this case the headers and the cmake files are not needed, only the library" OFF) option(DBC_GENERATE_DOCS "Use doxygen if installed to generated documentation files" OFF) # ---------------------- # @@ -20,9 +23,6 @@ set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE) set(CPACK_RESOURCE_FILE_README ${CMAKE_CURRENT_SOURCE_DIR}/README.md) include(CPack) -# defines variables used in the dbc.pc.in -include(GNUInstallDirs) - # specify the C++ standard set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED True) @@ -40,13 +40,6 @@ if (NOT ${FastFloat_FOUND}) add_subdirectory(${fastfloat_SOURCE_DIR} ${fastfloat_BINARY_DIR} EXCLUDE_FROM_ALL) endif() -set(GCC_COMPILE_FLAGS "-Wextra -Wall -Wfloat-equal -Wundef -Wshadow \ --Wpointer-arith -Wcast-align -Wstrict-prototypes -Wwrite-strings \ --Waggregate-return -Wcast-qual -Wswitch-default -Wswitch-enum -Wconversion \ --Wunreachable-code -Wformat=2 -Werror -Wuninitialized -Winit-self") - -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS}") - # add where to find the source files list(APPEND SOURCE_FILES ${PROJECT_SOURCE_DIR}/src/utils.cpp @@ -95,18 +88,10 @@ install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) # install headers -if (${CMAKE_MINOR_VERSION} GREATER_EQUAL 23 AND NOT FETCH_CONTENT_INCLUSION) - install(TARGETS ${PROJECT_NAME} - FILE_SET HEADERS - DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/lib${PROJECT_NAME} - INCLUDES DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} - ) -elseif(NOT DBC_FETCH_CONTENT_INCLUSION) - install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/libdbc DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) -endif() +nstall(DIRECTORY ${PROJECT_SOURCE_DIR}/include/libdbc DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) -if (NOT DBC_FETCH_CONTENT_INCLUSION) +if (NOT DBC_GENERATE_PKGCONFIG) # Generate pkg-config file configure_file(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY) install( From 74b2750c90e05d034a578112b3c652c9cebcc4cd Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 08:09:23 -0500 Subject: [PATCH 033/131] Adding warnings and errors for each compiler and fixing code based on those. Removed option DBC_GENERATE_PKGCONFIG --- CMakeLists.txt | 30 +++++++++++++++++------------- include/libdbc/message.hpp | 1 + include/libdbc/signal.hpp | 1 + test/CMakeLists.txt | 11 +++++++++++ test/test_dbc.cpp | 5 +++-- test/test_parseMessage.cpp | 8 ++++---- 6 files changed, 37 insertions(+), 19 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6868806..ca5f356 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,8 +8,6 @@ project(dbc # -- PROJECT OPTIONS -- # option(DBC_ENABLE_TESTS "Enable Unittests" ON) option(DBC_TEST_LOCALE_INDEPENDENCE "Used to deterime if the libary is locale agnostic when it comes to converting floats. You need `de_DE.UTF-8` locale installed for this testing." OFF) -# Turn OFF, if you are using FetchContent to include it to your project -option(DBC_GENERATE_PKGCONFIG "Include project with FetchContent_Declare in another project. In this case the headers and the cmake files are not needed, only the library" OFF) option(DBC_GENERATE_DOCS "Use doxygen if installed to generated documentation files" OFF) # ---------------------- # @@ -65,22 +63,31 @@ if(DBC_GENERATE_DOCS) add_subdirectory(doc) endif() +if (MSVC) + add_compile_options(/W4 /WX) +else() + add_compile_options(-Wall -Wextra -Wpedantic -Werror) +endif() + add_library(${PROJECT_NAME} STATIC ${SOURCE_FILES}) target_link_libraries(${PROJECT_NAME} FastFloat::fast_float) target_include_directories(${PROJECT_NAME} PUBLIC $ $ ) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) target_sources(${PROJECT_NAME} INTERFACE FILE_SET HEADERS TYPE HEADERS BASE_DIRS ${PROJECT_SOURCE_DIR}/include/libdbc - FILES ${HEADER_FILES}) + FILES ${HEADER_FILES} +) add_custom_target(release WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} COMMAND ${CMAKE_SOURCE_DIR}/scripts/create_single_header.sh - DEPENDS ${PROJECT_NAME}) + DEPENDS ${PROJECT_NAME} +) ## Installation # install lib @@ -88,13 +95,10 @@ install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) # install headers -nstall(DIRECTORY ${PROJECT_SOURCE_DIR}/include/libdbc DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) - +install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/libdbc DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) -if (NOT DBC_GENERATE_PKGCONFIG) - # Generate pkg-config file - configure_file(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY) - install( - FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc - DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) -endif() +# Generate pkg-config file +configure_file(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY) +install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) diff --git a/include/libdbc/message.hpp b/include/libdbc/message.hpp index 204f5c2..a0e267a 100644 --- a/include/libdbc/message.hpp +++ b/include/libdbc/message.hpp @@ -10,6 +10,7 @@ namespace libdbc { struct Message { Message() = delete; + virtual ~Message() = default; explicit Message(uint32_t id, const std::string& name, uint8_t size, const std::string& node); enum class ParseSignalsStatus { diff --git a/include/libdbc/signal.hpp b/include/libdbc/signal.hpp index 1b7076f..c7311cb 100644 --- a/include/libdbc/signal.hpp +++ b/include/libdbc/signal.hpp @@ -29,6 +29,7 @@ struct Signal { std::vector svDescriptions; Signal() = delete; + virtual ~Signal() = default; explicit Signal(std::string name, bool is_multiplexed, uint32_t start_bit, diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index e19344a..0573542 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -10,6 +10,17 @@ FetchContent_Declare( FetchContent_MakeAvailable(Catch2) include(Catch) +if (MSVC) + add_compile_options(/W4 /WX) +else() + add_compile_options(-Wall -Wextra -Wpedantic -Werror) +endif() + +# Code coverage compiler specific +if (GCC) + add_compile_options(--coverage) +endif() + add_executable(dbcParserTests test_dbc.cpp test_utils.cpp diff --git a/test/test_dbc.cpp b/test/test_dbc.cpp index dc386b5..8edc565 100644 --- a/test/test_dbc.cpp +++ b/test/test_dbc.cpp @@ -4,6 +4,7 @@ #include #include #include +#include TEST_CASE("Testing dbc file loading error issues", "[fileio][error]") { auto parser = std::unique_ptr(new libdbc::DbcParser()); @@ -28,10 +29,10 @@ TEST_CASE("Testing dbc file loading error issues", "[fileio][error]") { SECTION("Verify that what() method is accessible for all exceptions", "[error]") { auto generic_error = libdbc::exception(); - REQUIRE(generic_error.what() == "libdbc exception occurred"); + REQUIRE(std::string{generic_error.what()} == "libdbc exception occurred"); auto validity_check = libdbc::validity_error(); - REQUIRE(validity_check.what() == "Invalid DBC file"); + REQUIRE(std::string{validity_check.what()} == "Invalid DBC file"); } } diff --git a/test/test_parseMessage.cpp b/test/test_parseMessage.cpp index 7ccb971..d0e865f 100644 --- a/test/test_parseMessage.cpp +++ b/test/test_parseMessage.cpp @@ -24,7 +24,7 @@ BO_ 123 MSG2: 8 Vector__XXX parser.parse_file(filename); - SECTION("Evaluating unknown message id") { + SECTION("Evaluating unknown` message id") { std::vector out_values; CHECK(parser.parseMessage(578, std::vector({0xFF, 0xA2}), out_values) == libdbc::Message::ParseSignalsStatus::ErrorUnknownID); } @@ -54,7 +54,7 @@ TEST_CASE("Parse Message Big Number not aligned little endian") { std::vector refData{2, 0, 0, 1, 0, 0, 0}; CHECK(refData.size() == 7); CHECK(out_values.size() == refData.size()); - for (int i = 0; i < refData.size(); i++) { + for (size_t i = 0; i < refData.size(); i++) { CHECK(out_values.at(i) == refData.at(i)); } } @@ -65,7 +65,7 @@ TEST_CASE("Parse Message Big Number not aligned little endian") { std::vector refData{3, 32, 0, 1, 0, 0, 47}; CHECK(refData.size() == 7); CHECK(out_values.size() == refData.size()); - for (int i = 0; i < refData.size(); i++) { + for (size_t i = 0; i < refData.size(); i++) { CHECK(out_values.at(i) == refData.at(i)); } } @@ -76,7 +76,7 @@ TEST_CASE("Parse Message Big Number not aligned little endian") { std::vector refData{3, 51, 0, 1, 0, 0, 57}; CHECK(refData.size() == 7); CHECK(out_values.size() == refData.size()); - for (int i = 0; i < refData.size(); i++) { + for (size_t i = 0; i < refData.size(); i++) { CHECK(out_values.at(i) == refData.at(i)); } } From f3e656a7c2c108d6bd751e9e0a2e037ccab21b62 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 08:33:56 -0500 Subject: [PATCH 034/131] renaming tests.yml to pipeline.yml --- .github/workflows/pipeline.yml | 65 ++++++++++++++++++++++++++++++++++ .github/workflows/tests.yml | 38 -------------------- 2 files changed, 65 insertions(+), 38 deletions(-) create mode 100644 .github/workflows/pipeline.yml delete mode 100644 .github/workflows/tests.yml diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml new file mode 100644 index 0000000..401642a --- /dev/null +++ b/.github/workflows/pipeline.yml @@ -0,0 +1,65 @@ +name: Libdbc Tests + +on: [push, pull_request] + +env: + # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) + BUILD_TYPE: Release + +jobs: + linux-builds: + name: ${{matrix.cxx}}, C++${{matrix.std}}, ${{matrix.build_type}} + runs-on: ubuntu-latest + strategy: + matrix: + cxx: + - g++-13 + - clang++-16 + build_type: [Debug, Release] + std: [11] + include: + - cxx: g++-13 + other_pkgs: g++-13 + - cxx: clang++-16 + other_pkgs: clang-16 + + steps: + - uses: actions/checkout@v4 + + - name: Prepare environment + run: | + sudo apt-get update + sudo apt-get install -y ninja-build ${{matrix.other_pkgs}} + + - name: Configure build + working-directory: ${{runner.workspace}} + env: + CXX: ${{matrix.cxx}} + CXXFLAGS: ${{matrix.cxxflags}} + run: | + cmake -Bbuild -H$GITHUB_WORKSPACE \ + -DCMAKE_BUILD_TYPE=${{matrix.build_type}} \ + -DCMAKE_CXX_STANDARD=${{matrix.std}} \ + -DCMAKE_CXX_STANDARD_REQUIRED=ON \ + -DCMAKE_CXX_EXTENSIONS=ON \ + -DDBC_TEST_LOCALE_INDEPENDENCE=ON + + - name: Build tests + lib + working-directory: ${{runner.workspace}} + run: cmake --build build + + - name: Run tests + env: + CTEST_OUTPUT_ON_FAILURE: 1 + working-directory: ${{runner.workspace}} + run: ctest --output-on-failure --test-dir build -j `nproc` + + format-check: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + + - name: Test format with clang format + run: ./scripts/fmt.sh + diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml deleted file mode 100644 index 4cf02b7..0000000 --- a/.github/workflows/tests.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Libdbc Tests - -on: - push: - branches: - - "master" - pull_request: - workflow_dispatch: - -env: - # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) - BUILD_TYPE: Release - -jobs: - build-and-test: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - name: Configure CMake - run: cmake -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}} -Bbuild -H. - - - name: Build the library - run: cmake --build build - - - name: Run unit tests - run: ctest --output-on-failure --test-dir build - - format-check: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - - name: Test format with clang format - run: ./scripts/fmt.sh - From 66b8e74717c0ac67e7b338f8b9eebb194b0d8e1f Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 09:52:33 -0500 Subject: [PATCH 035/131] Attempt getting clang installed and working first in the pipeline --- .github/workflows/pipeline.yml | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 401642a..0f8617a 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -1,6 +1,6 @@ name: Libdbc Tests -on: [push, pull_request] +on: [push] env: # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) @@ -10,22 +10,29 @@ jobs: linux-builds: name: ${{matrix.cxx}}, C++${{matrix.std}}, ${{matrix.build_type}} runs-on: ubuntu-latest + continue-on-error: true strategy: matrix: cxx: - - g++-13 + # - g++-13 - clang++-16 build_type: [Debug, Release] std: [11] include: - - cxx: g++-13 - other_pkgs: g++-13 + # - cxx: g++-13 - cxx: clang++-16 - other_pkgs: clang-16 + llvm_version: 16 steps: - uses: actions/checkout@v4 + - name: Install clang + if: ${{ matrix.llvm_version }} != "" + run: | + wget https://apt.llvm.org/llvm.sh + chmod +x llvm.sh + sudo ./llvm.sh ${{ matrix.llvm_version }} + - name: Prepare environment run: | sudo apt-get update From 1abdf357055b8910e833242d66e249d677d1c978 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 10:05:13 -0500 Subject: [PATCH 036/131] renamed pipeline name, added CC env, installing and enabling the locale for the tests --- .github/workflows/pipeline.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 0f8617a..e970b83 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -1,4 +1,4 @@ -name: Libdbc Tests +name: Libdbc Pipeline on: [push] @@ -21,6 +21,7 @@ jobs: include: # - cxx: g++-13 - cxx: clang++-16 + cc: clang-16 llvm_version: 16 steps: @@ -36,13 +37,15 @@ jobs: - name: Prepare environment run: | sudo apt-get update - sudo apt-get install -y ninja-build ${{matrix.other_pkgs}} + sudo apt-get install -y locales ${{matrix.other_pkgs}} + + locale-gen de_DE.UTF-8 - name: Configure build working-directory: ${{runner.workspace}} env: + CC: ${{matrix.cc}} CXX: ${{matrix.cxx}} - CXXFLAGS: ${{matrix.cxxflags}} run: | cmake -Bbuild -H$GITHUB_WORKSPACE \ -DCMAKE_BUILD_TYPE=${{matrix.build_type}} \ From ddda0d58d58ebca2538dcfa6a55a5b6e9e5def05 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 10:09:22 -0500 Subject: [PATCH 037/131] Attempting root to generate the locale --- .github/workflows/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index e970b83..5f01215 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -39,7 +39,7 @@ jobs: sudo apt-get update sudo apt-get install -y locales ${{matrix.other_pkgs}} - locale-gen de_DE.UTF-8 + sudo locale-gen de_DE.UTF-8 - name: Configure build working-directory: ${{runner.workspace}} From a96e134d1e45d0b3b29764d484a46547d15e5555 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 10:11:51 -0500 Subject: [PATCH 038/131] Changing continue-on-error to fail-fast. This was the original intent to continue matrix builds if one failed --- .github/workflows/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 5f01215..a8c3bd7 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -10,9 +10,9 @@ jobs: linux-builds: name: ${{matrix.cxx}}, C++${{matrix.std}}, ${{matrix.build_type}} runs-on: ubuntu-latest - continue-on-error: true strategy: matrix: + fail-fast: false cxx: # - g++-13 - clang++-16 From 199617ae31806e1765be496ed5b0d717ee015783 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 10:19:57 -0500 Subject: [PATCH 039/131] Attempt to run g++ on build --- .github/workflows/pipeline.yml | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index a8c3bd7..850ec9f 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -14,12 +14,14 @@ jobs: matrix: fail-fast: false cxx: - # - g++-13 + - g++-13 - clang++-16 build_type: [Debug, Release] std: [11] include: - # - cxx: g++-13 + - cxx: g++-13 + cc: gcc-13 + gcc_version: 13 - cxx: clang++-16 cc: clang-16 llvm_version: 16 @@ -34,10 +36,21 @@ jobs: chmod +x llvm.sh sudo ./llvm.sh ${{ matrix.llvm_version }} + - name: Install gcc + if: ${{ matrix.gcc_version }} != "" + run: | + update-alternatives --remove-all gcc + update-alternatives --remove-all g++ + add-apt-repository ppa:ubuntu-toolchain-r/test + apt-get update + apt-get install -y ${{ matrix.gcc_version }} + + gcc --version + - name: Prepare environment run: | sudo apt-get update - sudo apt-get install -y locales ${{matrix.other_pkgs}} + sudo apt-get install -y locales sudo locale-gen de_DE.UTF-8 From 9bbc8213548289495811559d21177b306d15b885 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 10:21:07 -0500 Subject: [PATCH 040/131] Fail fast was in the wrong section of the matrix --- .github/workflows/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 850ec9f..4455370 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -11,8 +11,8 @@ jobs: name: ${{matrix.cxx}}, C++${{matrix.std}}, ${{matrix.build_type}} runs-on: ubuntu-latest strategy: + fail-fast: false matrix: - fail-fast: false cxx: - g++-13 - clang++-16 From a2290994ccf283343bb099d4af409f2e86e4ddf3 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 10:23:54 -0500 Subject: [PATCH 041/131] Don't need to remove the alternatives for gcc in github actions before installing. Also changing the if to not check string but rather if it was defined to skip install step --- .github/workflows/pipeline.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 4455370..cf90d77 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -30,17 +30,15 @@ jobs: - uses: actions/checkout@v4 - name: Install clang - if: ${{ matrix.llvm_version }} != "" + if: ${{ matrix.llvm_version }} run: | wget https://apt.llvm.org/llvm.sh chmod +x llvm.sh sudo ./llvm.sh ${{ matrix.llvm_version }} - name: Install gcc - if: ${{ matrix.gcc_version }} != "" + if: ${{ matrix.gcc_version }} run: | - update-alternatives --remove-all gcc - update-alternatives --remove-all g++ add-apt-repository ppa:ubuntu-toolchain-r/test apt-get update apt-get install -y ${{ matrix.gcc_version }} From ccc60601725bccc0b407f9fbd141c3c555a356f2 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 10:25:06 -0500 Subject: [PATCH 042/131] Need to run the apt repo add as root in github action --- .github/workflows/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index cf90d77..13b9795 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -39,7 +39,7 @@ jobs: - name: Install gcc if: ${{ matrix.gcc_version }} run: | - add-apt-repository ppa:ubuntu-toolchain-r/test + sudo add-apt-repository ppa:ubuntu-toolchain-r/test apt-get update apt-get install -y ${{ matrix.gcc_version }} From b41247c4b8af9230f8a8fd23a55b25f2df06deaa Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 10:28:04 -0500 Subject: [PATCH 043/131] attempting root install for the ubuntu toolchain gcc install --- .github/workflows/pipeline.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 13b9795..c362094 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -40,8 +40,8 @@ jobs: if: ${{ matrix.gcc_version }} run: | sudo add-apt-repository ppa:ubuntu-toolchain-r/test - apt-get update - apt-get install -y ${{ matrix.gcc_version }} + sudo apt-get update + sudo apt-get install -y ${{ matrix.gcc_version }} gcc --version From 9e9a6058a8e78ad57feb025772fdaeeba65e0556 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 10:29:42 -0500 Subject: [PATCH 044/131] need to specify gcc and g++ on the apt install --- .github/workflows/pipeline.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index c362094..86bae9b 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -41,9 +41,10 @@ jobs: run: | sudo add-apt-repository ppa:ubuntu-toolchain-r/test sudo apt-get update - sudo apt-get install -y ${{ matrix.gcc_version }} + sudo apt-get install -y gcc-${{ matrix.gcc_version }} g++-${{ matrix.gcc_version }} gcc --version + g++ --version - name: Prepare environment run: | From cd0ff363b87dfb4901fb21ab90148701c3fa90be Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 10:32:28 -0500 Subject: [PATCH 045/131] Checking if we need to install gcc in github actions. Based on last it looks like it comes pre installed --- .github/workflows/pipeline.yml | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 86bae9b..7436182 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -21,7 +21,6 @@ jobs: include: - cxx: g++-13 cc: gcc-13 - gcc_version: 13 - cxx: clang++-16 cc: clang-16 llvm_version: 16 @@ -36,16 +35,6 @@ jobs: chmod +x llvm.sh sudo ./llvm.sh ${{ matrix.llvm_version }} - - name: Install gcc - if: ${{ matrix.gcc_version }} - run: | - sudo add-apt-repository ppa:ubuntu-toolchain-r/test - sudo apt-get update - sudo apt-get install -y gcc-${{ matrix.gcc_version }} g++-${{ matrix.gcc_version }} - - gcc --version - g++ --version - - name: Prepare environment run: | sudo apt-get update From e80fbd6a8762a133d39bd3d0c23b6a48c0b38586 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 10:39:15 -0500 Subject: [PATCH 046/131] First attempt at using windows build for actions --- .github/workflows/pipeline.yml | 122 +++++++++++++++++++++++---------- 1 file changed, 84 insertions(+), 38 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 7436182..92e1b3a 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -26,44 +26,90 @@ jobs: llvm_version: 16 steps: - - uses: actions/checkout@v4 - - - name: Install clang - if: ${{ matrix.llvm_version }} - run: | - wget https://apt.llvm.org/llvm.sh - chmod +x llvm.sh - sudo ./llvm.sh ${{ matrix.llvm_version }} - - - name: Prepare environment - run: | - sudo apt-get update - sudo apt-get install -y locales - - sudo locale-gen de_DE.UTF-8 - - - name: Configure build - working-directory: ${{runner.workspace}} - env: - CC: ${{matrix.cc}} - CXX: ${{matrix.cxx}} - run: | - cmake -Bbuild -H$GITHUB_WORKSPACE \ - -DCMAKE_BUILD_TYPE=${{matrix.build_type}} \ - -DCMAKE_CXX_STANDARD=${{matrix.std}} \ - -DCMAKE_CXX_STANDARD_REQUIRED=ON \ - -DCMAKE_CXX_EXTENSIONS=ON \ - -DDBC_TEST_LOCALE_INDEPENDENCE=ON - - - name: Build tests + lib - working-directory: ${{runner.workspace}} - run: cmake --build build - - - name: Run tests - env: - CTEST_OUTPUT_ON_FAILURE: 1 - working-directory: ${{runner.workspace}} - run: ctest --output-on-failure --test-dir build -j `nproc` + - uses: actions/checkout@v4 + + - name: Install clang + if: ${{ matrix.llvm_version }} + run: | + wget https://apt.llvm.org/llvm.sh + chmod +x llvm.sh + sudo ./llvm.sh ${{ matrix.llvm_version }} + + - name: Prepare environment + run: | + sudo apt-get update + sudo apt-get install -y locales + + sudo locale-gen de_DE.UTF-8 + + - name: Configure build + working-directory: ${{runner.workspace}} + env: + CC: ${{matrix.cc}} + CXX: ${{matrix.cxx}} + run: | + cmake -Bbuild -H$GITHUB_WORKSPACE \ + -DCMAKE_BUILD_TYPE=${{matrix.build_type}} \ + -DCMAKE_CXX_STANDARD=${{matrix.std}} \ + -DCMAKE_CXX_STANDARD_REQUIRED=ON \ + -DCMAKE_CXX_EXTENSIONS=ON \ + -DDBC_TEST_LOCALE_INDEPENDENCE=ON + + - name: Build tests + lib + working-directory: ${{runner.workspace}} + run: cmake --build build + + - name: Run tests + env: + CTEST_OUTPUT_ON_FAILURE: 1 + working-directory: ${{runner.workspace}} + run: ctest --output-on-failure --test-dir build -j `nproc` + + windows-build: + name: ${{matrix.os}}, ${{matrix.std}}, ${{matrix.build_type}}, ${{matrix.platform}} + runs-on: ${{matrix.os}} + strategy: + matrix: + os: [windows-2019, windows-2022] + platform: [Win32, x64] + build_type: [Debug, Release] + std: [11] + + steps: + - uses: actions/checkout@v4 + + - name: Prepare environment + run: | + sudo apt-get update + sudo apt-get install -y locales + + sudo locale-gen de_DE.UTF-8 + + - name: Configure build + working-directory: ${{runner.workspace}} + env: + CC: ${{matrix.cc}} + CXX: ${{matrix.cxx}} + run: | + cmake -Bbuild -H$GITHUB_WORKSPACE ` + -A ${{matrix.platform}} ` + -DCMAKE_BUILD_TYPE=${{matrix.build_type}} ` + -DCMAKE_CXX_STANDARD=${{matrix.std}} ` + -DCMAKE_CXX_STANDARD_REQUIRED=ON ` + -DCMAKE_CXX_EXTENSIONS=ON ` + -DDBC_TEST_LOCALE_INDEPENDENCE=ON + + - name: Build tests + lib + working-directory: ${{runner.workspace}} + run: cmake --build build --config ${{matrix.build_type}} --parallel %NUMBER_OF_PROCESSORS% + shell: cmd + + - name: Run tests + env: + CTEST_OUTPUT_ON_FAILURE: 1 + working-directory: ${{runner.workspace}} + run: ctest --output-on-failure --test-dir build -j %NUMBER_OF_PROCESSORS% + shell: cmd format-check: runs-on: ubuntu-latest From a4d20d58b35bf883eb9b1ebe71855e8c2ceb9808 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 10:40:37 -0500 Subject: [PATCH 047/131] Removing the apt locale setup for windows build. Removing the env for compilers as well in the windows build since we only have one compiler --- .github/workflows/pipeline.yml | 10 ---------- 1 file changed, 10 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 92e1b3a..51c9504 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -78,18 +78,8 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Prepare environment - run: | - sudo apt-get update - sudo apt-get install -y locales - - sudo locale-gen de_DE.UTF-8 - - name: Configure build working-directory: ${{runner.workspace}} - env: - CC: ${{matrix.cc}} - CXX: ${{matrix.cxx}} run: | cmake -Bbuild -H$GITHUB_WORKSPACE ` -A ${{matrix.platform}} ` From 8eecbf7a598e4bd4351316b93e972b1cb8a054c5 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 10:42:56 -0500 Subject: [PATCH 048/131] Attempting env setup for the build folder on windows in github. Slightly different than the ubuntu env --- .github/workflows/pipeline.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 51c9504..1982b5c 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -81,12 +81,14 @@ jobs: - name: Configure build working-directory: ${{runner.workspace}} run: | - cmake -Bbuild -H$GITHUB_WORKSPACE ` - -A ${{matrix.platform}} ` + cmake -B ${{runner.workspace}}/build ` + -S $Env:GITHUB_WORKSPACE ` + -H $GITHUB_WORKSPACE ` + -A ${{matrix.platform}} ` -DCMAKE_BUILD_TYPE=${{matrix.build_type}} ` - -DCMAKE_CXX_STANDARD=${{matrix.std}} ` - -DCMAKE_CXX_STANDARD_REQUIRED=ON ` - -DCMAKE_CXX_EXTENSIONS=ON ` + -DCMAKE_CXX_STANDARD=${{matrix.std}} ` + -DCMAKE_CXX_STANDARD_REQUIRED=ON ` + -DCMAKE_CXX_EXTENSIONS=ON ` -DDBC_TEST_LOCALE_INDEPENDENCE=ON - name: Build tests + lib From ffd801508dc9182ef1077dbaadb39781675dbc6d Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 10:45:05 -0500 Subject: [PATCH 049/131] Changing the shell to cmd and removing one env setup for cmake for the windows build --- .github/workflows/pipeline.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 1982b5c..45fc8cc 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -69,6 +69,7 @@ jobs: name: ${{matrix.os}}, ${{matrix.std}}, ${{matrix.build_type}}, ${{matrix.platform}} runs-on: ${{matrix.os}} strategy: + fail-fast: false matrix: os: [windows-2019, windows-2022] platform: [Win32, x64] @@ -81,15 +82,15 @@ jobs: - name: Configure build working-directory: ${{runner.workspace}} run: | - cmake -B ${{runner.workspace}}/build ` - -S $Env:GITHUB_WORKSPACE ` - -H $GITHUB_WORKSPACE ` + cmake -S $Env:GITHUB_WORKSPACE ` + -B ${{runner.workspace}}/build ` -A ${{matrix.platform}} ` -DCMAKE_BUILD_TYPE=${{matrix.build_type}} ` -DCMAKE_CXX_STANDARD=${{matrix.std}} ` -DCMAKE_CXX_STANDARD_REQUIRED=ON ` -DCMAKE_CXX_EXTENSIONS=ON ` -DDBC_TEST_LOCALE_INDEPENDENCE=ON + shell: cmd - name: Build tests + lib working-directory: ${{runner.workspace}} From 674ad74a5364309e8e417303b3da81350a5b501d Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 10:46:01 -0500 Subject: [PATCH 050/131] The cmd shell is another different env setup. Using the original powershell --- .github/workflows/pipeline.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 45fc8cc..73695fe 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -90,7 +90,6 @@ jobs: -DCMAKE_CXX_STANDARD_REQUIRED=ON ` -DCMAKE_CXX_EXTENSIONS=ON ` -DDBC_TEST_LOCALE_INDEPENDENCE=ON - shell: cmd - name: Build tests + lib working-directory: ${{runner.workspace}} From 95801690fa38d3eb274d2281786aeeb1f2e3dd53 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 11:20:39 -0500 Subject: [PATCH 051/131] Fixing conversion warnings caught by MSVC and adding flags if available on gcc --- CMakeLists.txt | 11 ++++++++++- src/dbc.cpp | 12 +++++++----- src/message.cpp | 25 +++++++++++++------------ 3 files changed, 30 insertions(+), 18 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ca5f356..57475f3 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,10 +63,19 @@ if(DBC_GENERATE_DOCS) add_subdirectory(doc) endif() +list(APPEND GCC_CLANG_COMPILE_FLAGS + -Wall -Wextra -Wpedantic + -Warith-conversion -Wconversion + -Wint-in-bool-context + -Wmissing-declarations + -Werror +) + + if (MSVC) add_compile_options(/W4 /WX) else() - add_compile_options(-Wall -Wextra -Wpedantic -Werror) + add_compile_options(${GCC_CLANG_COMPILE_FLAGS}) endif() add_library(${PROJECT_NAME} STATIC ${SOURCE_FILES}) diff --git a/src/dbc.cpp b/src/dbc.cpp index fea6aea..25bb37d 100644 --- a/src/dbc.cpp +++ b/src/dbc.cpp @@ -1,3 +1,4 @@ +#include #include #include #include @@ -32,6 +33,7 @@ struct VALObject { std::vector vd; }; +static bool parseVal(const std::string& str, VALObject& obj); bool parseVal(const std::string& str, VALObject& obj) { obj.signal_name = ""; obj.vd.clear(); @@ -67,7 +69,7 @@ bool parseVal(const std::string& str, VALObject& obj) { } if (can_id_str.empty()) return false; - obj.can_id = std::stoul(can_id_str); + obj.can_id = static_cast(std::stoul(can_id_str)); if (*a != ' ') return false; a++; // skip whitespace @@ -237,9 +239,9 @@ void DbcParser::parse_dbc_messages(const std::vector& lines) { VALObject obj; for (const auto& line : lines) { if (std::regex_search(line, match, message_re)) { - uint32_t id = std::stoul(match.str(2)); + uint32_t id = static_cast(std::stoul(match.str(2))); std::string name = match.str(3); - uint8_t size = std::stoul(match.str(4)); + uint8_t size = static_cast(std::stoul(match.str(4))); std::string node = match.str(5); Message msg(id, name, size, node); @@ -251,8 +253,8 @@ void DbcParser::parse_dbc_messages(const std::vector& lines) { if (std::regex_search(line, match, signal_re)) { std::string name = match.str(2); bool is_multiplexed = false; // No support yet - uint32_t start_bit = std::stoul(match.str(3)); - uint32_t size = std::stoul(match.str(4)); + uint32_t start_bit = static_cast(std::stoul(match.str(3))); + uint32_t size = static_cast(std::stoul(match.str(4))); bool is_bigendian = (std::stoul(match.str(5)) == 0); bool is_signed = (match.str(6) == "-"); diff --git a/src/message.cpp b/src/message.cpp index cc9a341..00e136b 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -1,4 +1,5 @@ #include +#include #include namespace libdbc { @@ -14,20 +15,20 @@ bool Message::operator==(const Message& rhs) const { } Message::ParseSignalsStatus Message::parseSignals(const std::vector& data, std::vector& values) const { - int size = data.size(); + auto size = data.size(); if (size > 8) return ParseSignalsStatus::ErrorMessageToLong; // not supported yet uint64_t data_little_endian = 0; uint64_t data_big_endian = 0; - for (int i = 0; i < size; i++) { + for (size_t i = 0; i < size; i++) { data_little_endian |= ((uint64_t)data[i]) << i * 8; data_big_endian = (data_big_endian << 8) | (uint64_t)data[i]; } // TODO: does this also work on a big endian machine? - const uint32_t len = size * 8; + const auto len = size * 8; uint64_t v = 0; for (const auto& signal : m_signals) { if (signal.is_bigendian) { @@ -40,33 +41,33 @@ Message::ParseSignalsStatus Message::parseSignals(const std::vector& da if (signal.is_signed && signal.size > 1) { switch (signal.size) { case 8: - values.push_back((int8_t)v * signal.factor + signal.offset); + values.push_back(static_cast(v) * signal.factor + signal.offset); break; case 16: - values.push_back((int16_t)v * signal.factor + signal.offset); + values.push_back(static_cast(v) * signal.factor + signal.offset); break; case 32: - values.push_back((int32_t)v * signal.factor + signal.offset); + values.push_back(static_cast(v) * signal.factor + signal.offset); break; case 64: - values.push_back((int64_t)v * signal.factor + signal.offset); + values.push_back(static_cast(v) * signal.factor + signal.offset); break; default: { // 2 complement -> decimal - const int negative = (v & (1 << (signal.size - 1))) != 0; + const int negative = (v & (1ull << (signal.size - 1))) != 0; int64_t nativeInt; if (negative) - nativeInt = v | ~((1 << signal.size) - 1); // invert all bits above signal.size + nativeInt = v | ~((1ull << signal.size) - 1); // invert all bits above signal.size else - nativeInt = v & ((1 << signal.size) - 1); // masking - values.push_back(nativeInt * signal.factor + signal.offset); + nativeInt = v & ((1ull << signal.size) - 1); // masking + values.push_back(static_cast(nativeInt) * signal.factor + signal.offset); break; } } } else { // use only the relevant bits v = v & ((1 << signal.size) - 1); // masking - values.push_back(v * signal.factor + signal.offset); + values.push_back(static_cast(v) * signal.factor + signal.offset); } } return ParseSignalsStatus::Success; From 8cf693dd69bfd7b0bc4572fcc9243361eda23290 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 11:27:22 -0500 Subject: [PATCH 052/131] Removing clang flag that is unknown, fixing missing forward declare for struct on MSVC, and lastly casting the value of int found by clang --- CMakeLists.txt | 5 ++--- src/dbc.cpp | 1 + src/message.cpp | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 57475f3..8172352 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,9 +65,8 @@ endif() list(APPEND GCC_CLANG_COMPILE_FLAGS -Wall -Wextra -Wpedantic - -Warith-conversion -Wconversion - -Wint-in-bool-context - -Wmissing-declarations + -Wconversion -Wint-in-bool-context + -Wmissing-declarations -Wmissing-field-initializers -Werror ) diff --git a/src/dbc.cpp b/src/dbc.cpp index 25bb37d..28d3a0b 100644 --- a/src/dbc.cpp +++ b/src/dbc.cpp @@ -27,6 +27,7 @@ const auto whiteSpace = "\\s"; enum VALToken { Identifier = 0, CANId, SignalName, Value, Description }; +struct VALObject; struct VALObject { uint32_t can_id; std::string signal_name; diff --git a/src/message.cpp b/src/message.cpp index 00e136b..64b03d0 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -57,9 +57,9 @@ Message::ParseSignalsStatus Message::parseSignals(const std::vector& da const int negative = (v & (1ull << (signal.size - 1))) != 0; int64_t nativeInt; if (negative) - nativeInt = v | ~((1ull << signal.size) - 1); // invert all bits above signal.size + nativeInt = static_cast(v | ~((1ull << signal.size) - 1)); // invert all bits above signal.size else - nativeInt = v & ((1ull << signal.size) - 1); // masking + nativeInt = static_cast(v & ((1ull << signal.size) - 1)); // masking values.push_back(static_cast(nativeInt) * signal.factor + signal.offset); break; } From 3b6aadcd47358894d1bae57bd8b55137bb774abb Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 11:36:19 -0500 Subject: [PATCH 053/131] Adding back the anonymous for parseVal to see if that satisfies the msvc --- src/dbc.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/dbc.cpp b/src/dbc.cpp index 28d3a0b..3081739 100644 --- a/src/dbc.cpp +++ b/src/dbc.cpp @@ -5,7 +5,7 @@ #include -namespace libdbc { +namespace { const auto floatPattern = "(-?\\d+\\.?(\\d+)?)"; // Can be negative @@ -27,7 +27,6 @@ const auto whiteSpace = "\\s"; enum VALToken { Identifier = 0, CANId, SignalName, Value, Description }; -struct VALObject; struct VALObject { uint32_t can_id; std::string signal_name; @@ -141,6 +140,10 @@ bool parseVal(const std::string& str, VALObject& obj) { return false; } +} // Anonyomous namespace + +namespace libdbc { + DbcParser::DbcParser() : version("") , nodes() From baca2277e810bb7c11dd0fd9753ca1f392bedc16 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 11:41:15 -0500 Subject: [PATCH 054/131] namespace change didn't work. Revert that. Attempt to use brace initializer --- src/dbc.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/dbc.cpp b/src/dbc.cpp index 3081739..4955c6f 100644 --- a/src/dbc.cpp +++ b/src/dbc.cpp @@ -5,7 +5,7 @@ #include -namespace { +namespace libdbc { const auto floatPattern = "(-?\\d+\\.?(\\d+)?)"; // Can be negative @@ -30,7 +30,7 @@ enum VALToken { Identifier = 0, CANId, SignalName, Value, Description }; struct VALObject { uint32_t can_id; std::string signal_name; - std::vector vd; + std::vector vd; }; static bool parseVal(const std::string& str, VALObject& obj); @@ -39,7 +39,7 @@ bool parseVal(const std::string& str, VALObject& obj) { obj.vd.clear(); auto state = Identifier; const char* a = str.data(); - libdbc::Signal::SignalValueDescriptions vd; + Signal::SignalValueDescriptions vd; for (;;) { switch (state) { case Identifier: { @@ -140,10 +140,6 @@ bool parseVal(const std::string& str, VALObject& obj) { return false; } -} // Anonyomous namespace - -namespace libdbc { - DbcParser::DbcParser() : version("") , nodes() @@ -240,7 +236,7 @@ void DbcParser::parse_dbc_messages(const std::vector& lines) { std::vector sv; - VALObject obj; + VALObject obj{}; for (const auto& line : lines) { if (std::regex_search(line, match, message_re)) { uint32_t id = static_cast(std::stoul(match.str(2))); From 9aec8b06c7a02dc9be139c10bf656919a514adaf Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 11:45:15 -0500 Subject: [PATCH 055/131] There was another for loop that shadowed obj --- src/dbc.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/dbc.cpp b/src/dbc.cpp index 4955c6f..8b3dac6 100644 --- a/src/dbc.cpp +++ b/src/dbc.cpp @@ -279,10 +279,10 @@ void DbcParser::parse_dbc_messages(const std::vector& lines) { } } - for (const auto& obj : sv) { + for (const auto& signal : sv) { for (auto& msg : messages) { - if (msg.id() == obj.can_id) { - msg.addValueDescription(obj.signal_name, obj.vd); + if (msg.id() == signal.can_id) { + msg.addValueDescription(signal.signal_name, signal.vd); break; } } From 0b45437e7de6a793fe0eb545ad28fcd8cce7960c Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 12:43:29 -0500 Subject: [PATCH 056/131] Adding warning on shadow variables for gcc / clang and starting to replace the tmpnam with c++ 17 features for our tests to remove the warnings --- .github/workflows/pipeline.yml | 2 +- CMakeLists.txt | 2 +- test/CMakeLists.txt | 3 +++ test/common.cpp | 18 ++++++++++++++++++ test/common.hpp | 3 +++ test/test_dbc.cpp | 17 ++++------------- 6 files changed, 30 insertions(+), 15 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 73695fe..4d4e371 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -57,7 +57,7 @@ jobs: - name: Build tests + lib working-directory: ${{runner.workspace}} - run: cmake --build build + run: cmake --build build --parallel `nproc` - name: Run tests env: diff --git a/CMakeLists.txt b/CMakeLists.txt index 8172352..95fa0ae 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,7 +65,7 @@ endif() list(APPEND GCC_CLANG_COMPILE_FLAGS -Wall -Wextra -Wpedantic - -Wconversion -Wint-in-bool-context + -Wconversion -Wint-in-bool-context -Wshadow -Wmissing-declarations -Wmissing-field-initializers -Werror ) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 0573542..7dc7db5 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -10,6 +10,9 @@ FetchContent_Declare( FetchContent_MakeAvailable(Catch2) include(Catch) +# Need filesystem for testing +set(CMAKE_CXX_STANDARD 17) + if (MSVC) add_compile_options(/W4 /WX) else() diff --git a/test/common.cpp b/test/common.cpp index 383ebac..4377496 100644 --- a/test/common.cpp +++ b/test/common.cpp @@ -1,5 +1,8 @@ #include "common.hpp" #include "defines.hpp" +#include +#include +#include bool create_tmp_dbc_with(const char* filename, const char* content) { auto* file = std::fopen(filename, "w"); @@ -12,3 +15,18 @@ bool create_tmp_dbc_with(const char* filename, const char* content) { std::fclose(file); return true; } + +std::string create_temporary_dbc_with(const char* contents) { + std::filesystem::path temp_dir = std::filesystem::temp_directory_path(); + + // Generate a unique temporary file name + std::filesystem::path temp_file = temp_dir / "temp_file_XXXXXX"; // "XXXXXX" is a placeholder for a unique name + + std::ofstream file(temp_file); + if (file.is_open()) { + file << contents << std::endl; + file.close(); + } + + return temp_file; +} diff --git a/test/common.hpp b/test/common.hpp index 074fc25..c14c8c7 100644 --- a/test/common.hpp +++ b/test/common.hpp @@ -1,6 +1,9 @@ #ifndef COMMON_H #define COMMON_H +#include + bool create_tmp_dbc_with(const char* filename, const char* content); +std::string create_temporary_dbc_with(const char* contents); #endif // COMMON_H diff --git a/test/test_dbc.cpp b/test/test_dbc.cpp index 8edc565..dd9bb47 100644 --- a/test/test_dbc.cpp +++ b/test/test_dbc.cpp @@ -63,22 +63,13 @@ TEST_CASE("Testing dbc file loading", "[fileio]") { } TEST_CASE("Testing big endian, little endian") { - const auto* filename = std::tmpnam(NULL); - - auto* file = std::fopen(filename, "w"); - CHECK(file); - - std::fputs(PRIMITIVE_DBC.c_str(), file); - // first big endian - // second little endian - std::fputs(R"(BO_ 234 MSG1: 8 Vector__XXX + std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 234 MSG1: 8 Vector__XXX SG_ Sig1 : 55|16@0- (0.1,0) [-3276.8|-3276.7] "C" Vector__XXX - SG_ Sig2 : 39|16@1- (0.1,0) [-3276.8|-3276.7] "C" Vector__XXX)", - file); - std::fclose(file); + SG_ Sig2 : 39|16@1- (0.1,0) [-3276.8|-3276.7] "C" Vector__XXX)"; + const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); auto parser = libdbc::DbcParser(); - parser.parse_file(filename); + parser.parse_file(filename.c_str()); REQUIRE(parser.get_messages().size() == 1); REQUIRE(parser.get_messages().at(0).name() == "MSG1"); From 386d29beddd23cdf42fea9e7afb63f82a4feaa7d Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 12:48:16 -0500 Subject: [PATCH 057/131] generating unique file names for temp dbc now --- test/common.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/test/common.cpp b/test/common.cpp index 4377496..6b0656d 100644 --- a/test/common.cpp +++ b/test/common.cpp @@ -1,8 +1,10 @@ #include "common.hpp" #include "defines.hpp" +#include #include #include #include +#include bool create_tmp_dbc_with(const char* filename, const char* content) { auto* file = std::fopen(filename, "w"); @@ -20,13 +22,19 @@ std::string create_temporary_dbc_with(const char* contents) { std::filesystem::path temp_dir = std::filesystem::temp_directory_path(); // Generate a unique temporary file name - std::filesystem::path temp_file = temp_dir / "temp_file_XXXXXX"; // "XXXXXX" is a placeholder for a unique name + char filename[] = "temp_file_XXXXXX"; + if (std::tmpnam(filename) == nullptr) { + throw std::runtime_error("Failed to generate a unique temporary filename."); + } + std::filesystem::path temp_file = temp_dir / filename; std::ofstream file(temp_file); - if (file.is_open()) { - file << contents << std::endl; - file.close(); + if (!file.is_open()) { + throw std::runtime_error("Failed to create temporary file."); } + file << contents << std::endl; + file.close(); + return temp_file; } From 35bc831af800710410583386c3d8e81fff2f9892 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 12:54:43 -0500 Subject: [PATCH 058/131] test_dbc.cpp tests are now using new temporary file creation method --- test/test_dbc.cpp | 57 +++++++++++++++++++++-------------------------- 1 file changed, 26 insertions(+), 31 deletions(-) diff --git a/test/test_dbc.cpp b/test/test_dbc.cpp index dd9bb47..5d22a3e 100644 --- a/test/test_dbc.cpp +++ b/test/test_dbc.cpp @@ -67,6 +67,7 @@ TEST_CASE("Testing big endian, little endian") { SG_ Sig1 : 55|16@0- (0.1,0) [-3276.8|-3276.7] "C" Vector__XXX SG_ Sig2 : 39|16@1- (0.1,0) [-3276.8|-3276.7] "C" Vector__XXX)"; const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); + std::cerr << filename << std::endl; auto parser = libdbc::DbcParser(); parser.parse_file(filename.c_str()); @@ -85,16 +86,16 @@ TEST_CASE("Testing big endian, little endian") { } TEST_CASE("Testing negative values") { - const auto* filename = std::tmpnam(NULL); - - create_tmp_dbc_with(filename, R"(BO_ 234 MSG1: 8 Vector__XXX + std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 234 MSG1: 8 Vector__XXX SG_ Sig1 : 55|16@0- (0.1,0) [-3276.8|-3276.7] "C" Vector__XXX SG_ Sig2 : 39|16@0- (0.1,0) [-3276.8|-3276.7] "C" Vector__XXX SG_ Sig3 : 23|16@0- (10,0) [-3276.8|-3276.7] "C" Vector__XXX - SG_ Sig4 : 7|16@0- (1,-10) [0|32767] "" Vector__XXX)"); + SG_ Sig4 : 7|16@0- (1,-10) [0|32767] "" Vector__XXX)"; + const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); + std::cerr << filename << std::endl; auto parser = libdbc::DbcParser(); - parser.parse_file(filename); + parser.parse_file(filename.c_str()); REQUIRE(parser.get_messages().size() == 1); REQUIRE(parser.get_messages().at(0).name() == "MSG1"); @@ -131,13 +132,13 @@ TEST_CASE("Testing negative values") { } TEST_CASE("Special characters in unit") { - const auto* filename = std::tmpnam(NULL); - - create_tmp_dbc_with(filename, R"(BO_ 234 MSG1: 8 Vector__XXX - SG_ Speed : 0|8@1+ (1,0) [0|204] "Km/h" DEVICE1,DEVICE2,DEVICE3)"); + std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 234 MSG1: 8 Vector__XXX + SG_ Speed : 0|8@1+ (1,0) [0|204] "Km/h" DEVICE1,DEVICE2,DEVICE3)"; + const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); + std::cerr << filename << std::endl; auto parser = libdbc::DbcParser(); - parser.parse_file(filename); + parser.parse_file(filename.c_str()); REQUIRE(parser.get_messages().size() == 1); REQUIRE(parser.get_messages().at(0).name() == "MSG1"); @@ -149,15 +150,15 @@ TEST_CASE("Special characters in unit") { } TEST_CASE("Signal Value Description") { - const auto* filename = std::tmpnam(NULL); - - create_tmp_dbc_with(filename, R"(BO_ 234 MSG1: 8 Vector__XXX + std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 234 MSG1: 8 Vector__XXX SG_ State1 : 0|8@1+ (1,0) [0|200] "Km/h" DEVICE1,DEVICE2,DEVICE3 SG_ State2 : 0|8@1+ (1,0) [0|204] "" DEVICE1,DEVICE2,DEVICE3 -VAL_ 234 State1 123 "Description 1" 0 "Description 2" 90903489 "Big value and special characters &$§())!" ;)"); +VAL_ 234 State1 123 "Description 1" 0 "Description 2" 90903489 "Big value and special characters &$§())!" ;)"; + const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); + std::cerr << filename << std::endl; auto parser = libdbc::DbcParser(); - parser.parse_file(filename); + parser.parse_file(filename.c_str()); REQUIRE(parser.get_messages().size() == 1); REQUIRE(parser.get_messages().at(0).name() == "MSG1"); @@ -176,18 +177,15 @@ VAL_ 234 State1 123 "Description 1" 0 "Description 2" 90903489 "Big value and sp } TEST_CASE("Signal Value Description Extended CAN id") { - /* - * It should not crash, even extended CAN id is used - */ - const auto* filename = std::tmpnam(NULL); - - create_tmp_dbc_with(filename, R"(BO_ 3221225472 MSG1: 8 Vector__XXX + std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 3221225472 MSG1: 8 Vector__XXX SG_ State1 : 0|8@1+ (1,0) [0|200] "Km/h" DEVICE1,DEVICE2,DEVICE3 SG_ State2 : 0|8@1+ (1,0) [0|204] "" DEVICE1,DEVICE2,DEVICE3 -VAL_ 3221225472 State1 123 "Description 1" 0 "Description 2" 4000000000 "Big value and special characters &$§())!" ;)"); +VAL_ 3221225472 State1 123 "Description 1" 0 "Description 2" 4000000000 "Big value and special characters &$§())!" ;)"; + const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); + std::cerr << filename << std::endl; auto parser = libdbc::DbcParser(); - parser.parse_file(filename); + parser.parse_file(filename.c_str()); REQUIRE(parser.get_messages().size() == 1); REQUIRE(parser.get_messages().at(0).name() == "MSG1"); @@ -206,22 +204,19 @@ VAL_ 3221225472 State1 123 "Description 1" 0 "Description 2" 4000000000 "Big val } TEST_CASE("Signal Value Multiple VAL_") { - /* - * It should not crash, even extended CAN id is used - */ - const auto* filename = std::tmpnam(NULL); - - create_tmp_dbc_with(filename, R"(BO_ 3221225472 MSG1: 8 Vector__XXX + std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 3221225472 MSG1: 8 Vector__XXX SG_ State1 : 0|8@1+ (1,0) [0|200] "Km/h" DEVICE1,DEVICE2,DEVICE3 SG_ State2 : 0|8@1+ (1,0) [0|204] "" DEVICE1,DEVICE2,DEVICE3" BO_ 123 MSG2: 8 Vector__XXX SG_ State1 : 0|8@1+ (1,0) [0|200] "Km/h" DEVICE1,DEVICE2,DEVICE3 SG_ State2 : 0|8@1+ (1,0) [0|204] "" DEVICE1,DEVICE2,DEVICE3 VAL_ 3221225472 State1 123 "Description 1" 0 "Description 2" ; -VAL_ 123 State1 123 "Description 3" 0 "Description 4" ;)"); +VAL_ 123 State1 123 "Description 3" 0 "Description 4" ;)"; + const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); + std::cerr << filename << std::endl; auto parser = libdbc::DbcParser(); - parser.parse_file(filename); + parser.parse_file(filename.c_str()); REQUIRE(parser.get_messages().size() == 2); REQUIRE(parser.get_messages().at(0).name() == "MSG1"); From f2dc6981cf555b54bccfc1a9d9b3096ea6f41cbe Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 13:01:41 -0500 Subject: [PATCH 059/131] Removing std::cerr debugs and finished removing old function for creating temporary file --- test/locale_testing/test_locale_main.cpp | 7 ++- test/test_dbc.cpp | 6 --- test/test_parseMessage.cpp | 54 +++++++++++------------- 3 files changed, 27 insertions(+), 40 deletions(-) diff --git a/test/locale_testing/test_locale_main.cpp b/test/locale_testing/test_locale_main.cpp index 7ffddfa..159e12c 100644 --- a/test/locale_testing/test_locale_main.cpp +++ b/test/locale_testing/test_locale_main.cpp @@ -34,13 +34,12 @@ TEST_CASE("Should parse doubld string locale independently") { } TEST_CASE("Should process message with floats locale indpendently") { - const auto* filename = std::tmpnam(NULL); - - create_tmp_dbc_with(filename, R"(BO_ 234 MSG1: 8 Vector__XXX + std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 234 MSG1: 8 Vector__XXX SG_ Sig1 : 55|16@0- (0.1,0) [-3276.8|-3276.7] "C" Vector__XXX SG_ Sig2 : 39|16@0- (0.1,0) [-3276.8|-3276.7] "C" Vector__XXX SG_ Sig3 : 23|16@0- (10,0) [-3276.8|-3276.7] "C" Vector__XXX - SG_ Sig4 : 7|16@0- (1,-10) [0|32767] "" Vector__XXX)"); + SG_ Sig4 : 7|16@0- (1,-10) [0|32767] "" Vector__XXX)"; + const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); auto parser = libdbc::DbcParser(); parser.parse_file(filename); diff --git a/test/test_dbc.cpp b/test/test_dbc.cpp index 5d22a3e..43862bc 100644 --- a/test/test_dbc.cpp +++ b/test/test_dbc.cpp @@ -67,7 +67,6 @@ TEST_CASE("Testing big endian, little endian") { SG_ Sig1 : 55|16@0- (0.1,0) [-3276.8|-3276.7] "C" Vector__XXX SG_ Sig2 : 39|16@1- (0.1,0) [-3276.8|-3276.7] "C" Vector__XXX)"; const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); - std::cerr << filename << std::endl; auto parser = libdbc::DbcParser(); parser.parse_file(filename.c_str()); @@ -92,7 +91,6 @@ TEST_CASE("Testing negative values") { SG_ Sig3 : 23|16@0- (10,0) [-3276.8|-3276.7] "C" Vector__XXX SG_ Sig4 : 7|16@0- (1,-10) [0|32767] "" Vector__XXX)"; const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); - std::cerr << filename << std::endl; auto parser = libdbc::DbcParser(); parser.parse_file(filename.c_str()); @@ -135,7 +133,6 @@ TEST_CASE("Special characters in unit") { std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 234 MSG1: 8 Vector__XXX SG_ Speed : 0|8@1+ (1,0) [0|204] "Km/h" DEVICE1,DEVICE2,DEVICE3)"; const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); - std::cerr << filename << std::endl; auto parser = libdbc::DbcParser(); parser.parse_file(filename.c_str()); @@ -155,7 +152,6 @@ TEST_CASE("Signal Value Description") { SG_ State2 : 0|8@1+ (1,0) [0|204] "" DEVICE1,DEVICE2,DEVICE3 VAL_ 234 State1 123 "Description 1" 0 "Description 2" 90903489 "Big value and special characters &$§())!" ;)"; const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); - std::cerr << filename << std::endl; auto parser = libdbc::DbcParser(); parser.parse_file(filename.c_str()); @@ -182,7 +178,6 @@ TEST_CASE("Signal Value Description Extended CAN id") { SG_ State2 : 0|8@1+ (1,0) [0|204] "" DEVICE1,DEVICE2,DEVICE3 VAL_ 3221225472 State1 123 "Description 1" 0 "Description 2" 4000000000 "Big value and special characters &$§())!" ;)"; const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); - std::cerr << filename << std::endl; auto parser = libdbc::DbcParser(); parser.parse_file(filename.c_str()); @@ -213,7 +208,6 @@ BO_ 123 MSG2: 8 Vector__XXX VAL_ 3221225472 State1 123 "Description 1" 0 "Description 2" ; VAL_ 123 State1 123 "Description 3" 0 "Description 4" ;)"; const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); - std::cerr << filename << std::endl; auto parser = libdbc::DbcParser(); parser.parse_file(filename.c_str()); diff --git a/test/test_parseMessage.cpp b/test/test_parseMessage.cpp index d0e865f..3eaacb0 100644 --- a/test/test_parseMessage.cpp +++ b/test/test_parseMessage.cpp @@ -5,24 +5,22 @@ #include #include "common.hpp" +#include "defines.hpp" // Testing of parsing messages TEST_CASE("Parse Message Unknown ID") { - libdbc::DbcParser parser; - - const auto dbcContent = R"(BO_ 234 MSG1: 8 Vector__XXX + std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 234 MSG1: 8 Vector__XXX SG_ Msg1Sig1 : 0|8@0+ (1,0) [-3276.8|-3276.7] "C" Vector__XXX SG_ MsgSig2 : 8|8@0+ (1,0) [-3276.8|-3276.7] "C" Vector__XXX BO_ 123 MSG2: 8 Vector__XXX SG_ Msg2Sig1 : 0|8@0+ (1,0) [-3276.8|-3276.7] "C" Vector__XXX SG_ Msg2Sig1 : 8|8@0+ (1,0) [-3276.8|-3276.7] "C" Vector__XXX )"; + const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); - const auto* filename = std::tmpnam(NULL); - CHECK(create_tmp_dbc_with(filename, dbcContent)); - - parser.parse_file(filename); + libdbc::DbcParser parser; + parser.parse_file(filename.c_str()); SECTION("Evaluating unknown` message id") { std::vector out_values; @@ -31,9 +29,7 @@ BO_ 123 MSG2: 8 Vector__XXX } TEST_CASE("Parse Message Big Number not aligned little endian") { - libdbc::DbcParser parser; - - const auto dbcContent = R"(BO_ 337 STATUS: 8 Vector__XXX + std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 337 STATUS: 8 Vector__XXX SG_ Value6 : 27|3@1+ (1,0) [0|7] "" Vector__XXX SG_ Value5 : 16|11@1+ (0.1,-102) [-102|102] "%" Vector__XXX SG_ Value2 : 8|2@1+ (1,0) [0|2] "" Vector__XXX @@ -42,10 +38,9 @@ TEST_CASE("Parse Message Big Number not aligned little endian") { SG_ Value4 : 11|4@1+ (1,0) [0|3] "" Vector__XXX SG_ Value1 : 0|8@1+ (1,0) [0|204] "Km/h" Vector__XXX )"; + const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); - const auto* filename = std::tmpnam(NULL); - CHECK(create_tmp_dbc_with(filename, dbcContent)); - + libdbc::DbcParser parser; parser.parse_file(filename); SECTION("Evaluating first message") { @@ -83,20 +78,19 @@ TEST_CASE("Parse Message Big Number not aligned little endian") { } TEST_CASE("Parse Message little endian") { - const auto* filename = std::tmpnam(NULL); - - create_tmp_dbc_with(filename, R"(BO_ 541 STATUS: 8 DEVICE1 + std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 541 STATUS: 8 DEVICE1 SG_ Temperature : 48|16@1+ (0.01,-40) [-40|125] "C" DEVICE1 SG_ SOH : 0|16@1+ (0.01,0) [0|100] "%" DEVICE1 SG_ SOE : 32|16@1+ (0.01,0) [0|100] "%" DEVICE1 - SG_ SOC : 16|16@1+ (0.01,0) [0|100] "%" DEVICE1)"); + SG_ SOC : 16|16@1+ (0.01,0) [0|100] "%" DEVICE1)"; + const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); - libdbc::DbcParser p; - p.parse_file(filename); + libdbc::DbcParser parser; + parser.parse_file(filename); std::vector data{0x08, 0x27, 0xa3, 0x22, 0xe5, 0x1f, 0x45, 0x14}; // little endian std::vector result_values; - REQUIRE(p.parseMessage(0x21d, data, result_values) == libdbc::Message::ParseSignalsStatus::Success); + REQUIRE(parser.parseMessage(0x21d, data, result_values) == libdbc::Message::ParseSignalsStatus::Success); REQUIRE(result_values.size() == 4); REQUIRE(Catch::Approx(result_values.at(0)) == 11.89); @@ -106,8 +100,7 @@ TEST_CASE("Parse Message little endian") { } TEST_CASE("Parse Message big endian signed values") { - const auto* filename = std::tmpnam(NULL); - create_tmp_dbc_with(filename, R"(BO_ 545 MSG: 8 BMS2 + std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 545 MSG: 8 BMS2 SG_ Sig1 : 62|1@0+ (1,0) [0|0] "" Vector__XXX SG_ Sig2 : 49|2@0+ (1,0) [0|0] "" Vector__XXX SG_ Sig3 : 39|16@0- (0.1,0) [0|0] "A" Vector__XXX @@ -119,10 +112,11 @@ TEST_CASE("Parse Message big endian signed values") { SG_ Sig9 : 56|1@0+ (1,0) [0|0] "" Vector__XXX SG_ Sig10 : 61|1@0+ (1,0) [0|0] "" Vector__XXX SG_ Sig11 : 7|16@0+ (0.001,0) [0|65.535] "V" Vector__XXX - SG_ Sig12 : 23|16@0+ (0.1,0) [0|6553.5] "A" Vector__XXX)"); + SG_ Sig12 : 23|16@0+ (0.1,0) [0|6553.5] "A" Vector__XXX)"; + const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); libdbc::DbcParser p; - p.parse_file(filename); + p.parse_file(filename.c_str()); std::vector data{13, 177, 0, 216, 251, 180, 0, 31}; // big endian std::vector result_values; @@ -143,12 +137,12 @@ TEST_CASE("Parse Message big endian signed values") { } TEST_CASE("Parse Message with non byte aligned values") { - const auto* filename = std::tmpnam(NULL); - create_tmp_dbc_with(filename, R"(BO_ 403 INFORMATION: 8 Vector__XXX + std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 403 INFORMATION: 8 Vector__XXX SG_ Voltage : 30|9@1+ (0.2,0) [0|102.2] "V" Vector__XXX SG_ Phase_Current : 20|10@1- (1,0) [-512|512] "A" Vector__XXX SG_ Iq_Current : 10|10@1- (1,0) [-512|512] "A" Vector__XXX - SG_ Id_Current : 0|10@1- (1,0) [-512|512] "A" Vector__XXX)"); + SG_ Id_Current : 0|10@1- (1,0) [-512|512] "A" Vector__XXX)"; + const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); libdbc::DbcParser p; p.parse_file(filename); @@ -164,10 +158,10 @@ TEST_CASE("Parse Message with non byte aligned values") { } TEST_CASE("Parse Message data length < 8 unsigned") { - const auto* filename = std::tmpnam(NULL); - create_tmp_dbc_with(filename, R"(BO_ 234 MSG1: 8 Vector__XXX + std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 234 MSG1: 8 Vector__XXX SG_ Msg1Sig1 : 7|8@0+ (1,0) [-3276.8|-3276.7] "C" Vector__XXX - SG_ Msg1Sig2 : 15|8@0+ (1,0) [-3276.8|-3276.7] "km/h" Vector__XXX)"); + SG_ Msg1Sig2 : 15|8@0+ (1,0) [-3276.8|-3276.7] "km/h" Vector__XXX)"; + const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); libdbc::DbcParser p; p.parse_file(filename); From a70fc65b1084fe5e963f277d3244e7d3dde25818 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 13:06:22 -0500 Subject: [PATCH 060/131] Remove the old temporary file function and removing the last instance of tmpnam with a time / random generator solution --- test/common.cpp | 33 +++++++++++++++++++-------------- test/common.hpp | 1 - 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/test/common.cpp b/test/common.cpp index 6b0656d..ce3c7ba 100644 --- a/test/common.cpp +++ b/test/common.cpp @@ -1,31 +1,36 @@ #include "common.hpp" #include "defines.hpp" -#include +#include #include #include #include +#include #include -bool create_tmp_dbc_with(const char* filename, const char* content) { - auto* file = std::fopen(filename, "w"); - if (!file) { - return false; - } +// Don't want to use tmpnam due to warnings. So here is an alternative using time and random numbers. +// This should be platform agnostic as well. +static std::string generate_unique_filename(); +std::string generate_unique_filename() { + // Get current time since epoch + auto now = std::chrono::system_clock::now(); + auto duration = now.time_since_epoch(); + auto milliseconds = std::chrono::duration_cast(duration).count(); + + // Generate a random number + std::random_device rd; + std::mt19937 gen(rd()); + std::uniform_int_distribution<> dis(0, 9999); + int random_num = dis(gen); - std::fputs(PRIMITIVE_DBC.c_str(), file); - std::fputs(content, file); - std::fclose(file); - return true; + // Concatenate time and random number to create a unique filename + return "temp_file_" + std::to_string(milliseconds) + "_" + std::to_string(random_num) + ".txt"; } std::string create_temporary_dbc_with(const char* contents) { std::filesystem::path temp_dir = std::filesystem::temp_directory_path(); // Generate a unique temporary file name - char filename[] = "temp_file_XXXXXX"; - if (std::tmpnam(filename) == nullptr) { - throw std::runtime_error("Failed to generate a unique temporary filename."); - } + std::string filename = generate_unique_filename(); std::filesystem::path temp_file = temp_dir / filename; std::ofstream file(temp_file); diff --git a/test/common.hpp b/test/common.hpp index c14c8c7..49ee838 100644 --- a/test/common.hpp +++ b/test/common.hpp @@ -3,7 +3,6 @@ #include -bool create_tmp_dbc_with(const char* filename, const char* content); std::string create_temporary_dbc_with(const char* contents); #endif // COMMON_H From e505e750300707ae068734baa7ad4bf25227b060 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 13:15:48 -0500 Subject: [PATCH 061/131] Removing shadow warning because it is too sensitive for gcc but keeping for clang. Explicitly calling string conversion on the file path --- CMakeLists.txt | 7 +++++-- test/common.cpp | 2 +- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 95fa0ae..f7ffd79 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -65,14 +65,17 @@ endif() list(APPEND GCC_CLANG_COMPILE_FLAGS -Wall -Wextra -Wpedantic - -Wconversion -Wint-in-bool-context -Wshadow + -Wconversion -Wint-in-bool-context -Wmissing-declarations -Wmissing-field-initializers -Werror ) -if (MSVC) +if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC") add_compile_options(/W4 /WX) +elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + # Clang shadow warnings aren't as sensitive as gcc + add_compile_options(${GCC_CLANG_COMPILE_FLAGS} -Wshadow) else() add_compile_options(${GCC_CLANG_COMPILE_FLAGS}) endif() diff --git a/test/common.cpp b/test/common.cpp index ce3c7ba..053a3ed 100644 --- a/test/common.cpp +++ b/test/common.cpp @@ -41,5 +41,5 @@ std::string create_temporary_dbc_with(const char* contents) { file << contents << std::endl; file.close(); - return temp_file; + return temp_file.string(); } From 05df300c68c6f59ab621ad9ba75470b9d3e7c903 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 13:29:12 -0500 Subject: [PATCH 062/131] Adding size getter for message. This wasn't done before and was an oversight. This fixes #19 issue. I am not sure if uint8_t is the right size but if it is greater rollover happens and no detection method right now --- include/libdbc/message.hpp | 5 ++--- src/message.cpp | 8 ++++++++ test/test_dbc.cpp | 7 +++++-- 3 files changed, 15 insertions(+), 5 deletions(-) diff --git a/include/libdbc/message.hpp b/include/libdbc/message.hpp index a0e267a..e903fed 100644 --- a/include/libdbc/message.hpp +++ b/include/libdbc/message.hpp @@ -32,9 +32,8 @@ struct Message { void appendSignal(const Signal& signal); const std::vector getSignals() const; uint32_t id() const; - const std::string& name() const { - return m_name; - } + uint8_t size() const; + const std::string& name() const; void addValueDescription(const std::string& signal_name, const std::vector&); virtual bool operator==(const Message& rhs) const; diff --git a/src/message.cpp b/src/message.cpp index 64b03d0..443526a 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -85,6 +85,14 @@ uint32_t Message::id() const { return m_id; } +uint8_t Message::size() const { + return m_size; +} + +const std::string& Message::name() const { + return m_name; +} + void Message::addValueDescription(const std::string& signal_name, const std::vector& vd) { for (auto& s : m_signals) { if (s.name.compare(signal_name) == 0) { diff --git a/test/test_dbc.cpp b/test/test_dbc.cpp index 43862bc..93f8991 100644 --- a/test/test_dbc.cpp +++ b/test/test_dbc.cpp @@ -73,6 +73,7 @@ TEST_CASE("Testing big endian, little endian") { REQUIRE(parser.get_messages().size() == 1); REQUIRE(parser.get_messages().at(0).name() == "MSG1"); + REQUIRE(parser.get_messages().at(0).size() == 8); REQUIRE(parser.get_messages().at(0).getSignals().size() == 2); { const auto signal = parser.get_messages().at(0).getSignals().at(0); @@ -85,7 +86,7 @@ TEST_CASE("Testing big endian, little endian") { } TEST_CASE("Testing negative values") { - std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 234 MSG1: 8 Vector__XXX + std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 234 MSG1: 58 Vector__XXX SG_ Sig1 : 55|16@0- (0.1,0) [-3276.8|-3276.7] "C" Vector__XXX SG_ Sig2 : 39|16@0- (0.1,0) [-3276.8|-3276.7] "C" Vector__XXX SG_ Sig3 : 23|16@0- (10,0) [-3276.8|-3276.7] "C" Vector__XXX @@ -97,6 +98,7 @@ TEST_CASE("Testing negative values") { REQUIRE(parser.get_messages().size() == 1); REQUIRE(parser.get_messages().at(0).name() == "MSG1"); + REQUIRE(parser.get_messages().at(0).size() == 58); REQUIRE(parser.get_messages().at(0).getSignals().size() == 4); SECTION("Evaluating first message") { @@ -130,7 +132,7 @@ TEST_CASE("Testing negative values") { } TEST_CASE("Special characters in unit") { - std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 234 MSG1: 8 Vector__XXX + std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 234 MSG1: 255 Vector__XXX SG_ Speed : 0|8@1+ (1,0) [0|204] "Km/h" DEVICE1,DEVICE2,DEVICE3)"; const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); @@ -139,6 +141,7 @@ TEST_CASE("Special characters in unit") { REQUIRE(parser.get_messages().size() == 1); REQUIRE(parser.get_messages().at(0).name() == "MSG1"); + REQUIRE(parser.get_messages().at(0).size() == 255); REQUIRE(parser.get_messages().at(0).getSignals().size() == 1); SECTION("Checking that signal with special characters as unit is parsed correctly") { const auto signal = parser.get_messages().at(0).getSignals().at(0); From 70d17119216d5aa11c3ac3f9c1a73cf7c6f45ed6 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 13:34:10 -0500 Subject: [PATCH 063/131] First stab at a macos build --- .github/workflows/pipeline.yml | 42 ++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 4d4e371..590d7f8 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -103,6 +103,48 @@ jobs: run: ctest --output-on-failure --test-dir build -j %NUMBER_OF_PROCESSORS% shell: cmd + macos-builds: + name: ${{matrix.cxx}}, C++${{matrix.std}}, ${{matrix.build_type}} + runs-on: macos-latest + strategy: + matrix: + cxx: + - g++ + - clang++ + build_type: [Debug, Release] + std: [11] + include: + - cxx: g++ + cc: gcc + - cxx: clang++ + cc: clang + + steps: + - uses: actions/checkout@v4 + + - name: Configure build + working-directory: ${{runner.workspace}} + env: + CC: ${{matrix.cc}} + CXX: ${{matrix.cxx}} + run: | + cmake -Bbuild -H$GITHUB_WORKSPACE \ + -DCMAKE_BUILD_TYPE=${{matrix.build_type}} \ + -DCMAKE_CXX_STANDARD=${{matrix.std}} \ + -DCMAKE_CXX_STANDARD_REQUIRED=ON \ + -DCMAKE_CXX_EXTENSIONS=ON \ + -DDBC_TEST_LOCALE_INDEPENDENCE=ON + + - name: Build tests + lib + working-directory: ${{runner.workspace}} + run: cmake --build build --parallel `sysctl -n hw.ncpu` + + - name: Run tests + env: + CTEST_OUTPUT_ON_FAILURE: 1 + working-directory: ${{runner.workspace}} + run: ctest --output-on-failure --test-dir build -j `sysctl -n hw.ncpu` + format-check: runs-on: ubuntu-latest From 38f6284fcb202f946d98a5ef4c56c7891959d090 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 13:38:57 -0500 Subject: [PATCH 064/131] setlocale is in global namespace on mac os --- .github/workflows/pipeline.yml | 5 +++-- test/locale_testing/test_locale_main.cpp | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 590d7f8..2bda82a 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -8,7 +8,7 @@ env: jobs: linux-builds: - name: ${{matrix.cxx}}, C++${{matrix.std}}, ${{matrix.build_type}} + name: linux ${{matrix.cxx}}, C++${{matrix.std}}, ${{matrix.build_type}} runs-on: ubuntu-latest strategy: fail-fast: false @@ -104,9 +104,10 @@ jobs: shell: cmd macos-builds: - name: ${{matrix.cxx}}, C++${{matrix.std}}, ${{matrix.build_type}} + name: macos ${{matrix.cxx}}, C++${{matrix.std}}, ${{matrix.build_type}} runs-on: macos-latest strategy: + fail-fast: false matrix: cxx: - g++ diff --git a/test/locale_testing/test_locale_main.cpp b/test/locale_testing/test_locale_main.cpp index 159e12c..4f99b20 100644 --- a/test/locale_testing/test_locale_main.cpp +++ b/test/locale_testing/test_locale_main.cpp @@ -13,7 +13,8 @@ class testRunListener : public Catch::EventListenerBase { using Catch::EventListenerBase::EventListenerBase; void testRunStarting(Catch::TestRunInfo const&) override { - prev_loc = std::setlocale(LC_ALL, nullptr); + // Mac OS uses global and c++ standard uses the std. Using this to remove ambiguity between the two. + prev_loc = ::setlocale(LC_ALL, nullptr); // Set the locale to something that has , instead of . for floats std::locale::global(std::locale("de_DE.UTF-8")); } From 8630cf394d3321f54a4d08147da57a68ab0ead77 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 13:41:31 -0500 Subject: [PATCH 065/131] Remove checked in third-party library we aren't using --- third_party/bitstream/CMakeLists.txt | 15 - third_party/bitstream/Readme.md | 2 - third_party/bitstream/bitstream.c | 608 --------------------------- third_party/bitstream/bitstream.h | 178 -------- 4 files changed, 803 deletions(-) delete mode 100644 third_party/bitstream/CMakeLists.txt delete mode 100644 third_party/bitstream/Readme.md delete mode 100644 third_party/bitstream/bitstream.c delete mode 100644 third_party/bitstream/bitstream.h diff --git a/third_party/bitstream/CMakeLists.txt b/third_party/bitstream/CMakeLists.txt deleted file mode 100644 index 043d10f..0000000 --- a/third_party/bitstream/CMakeLists.txt +++ /dev/null @@ -1,15 +0,0 @@ -cmake_minimum_required(VERSION 3.16) -# FILE_SET needs cmake 3.23 - -project(bitstream) - -add_library(${PROJECT_NAME} STATIC bitstream.c) - -if (${CMAKE_MINOR_VERSION} GREATER_EQUAL 23) - target_sources(${PROJECT_NAME} INTERFACE FILE_SET HEADERS - TYPE HEADERS - BASE_DIRS ${PROJECT_SOURCE_DIR} - FILES bitstream.h) -else() - target_include_directories(${PROJECT_NAME} INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}) -endif() diff --git a/third_party/bitstream/Readme.md b/third_party/bitstream/Readme.md deleted file mode 100644 index 3704131..0000000 --- a/third_party/bitstream/Readme.md +++ /dev/null @@ -1,2 +0,0 @@ -Bitstream reader. -Files copied from https://github.com/eerimoq/bitstruct/tree/master/bitstruct diff --git a/third_party/bitstream/bitstream.c b/third_party/bitstream/bitstream.c deleted file mode 100644 index cc68ed8..0000000 --- a/third_party/bitstream/bitstream.c +++ /dev/null @@ -1,608 +0,0 @@ -/** - * The MIT License (MIT) - * - * Copyright (c) 2019 Erik Moqvist - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifdef __cplusplus -extern "C" { -#endif - -#include -#include "bitstream.h" - -void bitstream_writer_init(struct bitstream_writer_t *self_p, - uint8_t *buf_p) -{ - self_p->buf_p = buf_p; - self_p->byte_offset = 0; - self_p->bit_offset = 0; -} - -int bitstream_writer_size_in_bits(struct bitstream_writer_t *self_p) -{ - return (8 * self_p->byte_offset + self_p->bit_offset); -} - -int bitstream_writer_size_in_bytes(struct bitstream_writer_t *self_p) -{ - return (self_p->byte_offset + (self_p->bit_offset + 7) / 8); -} - -void bitstream_writer_write_bit(struct bitstream_writer_t *self_p, - int value) -{ - if (self_p->bit_offset == 0) { - self_p->buf_p[self_p->byte_offset] = (value << 7); - self_p->bit_offset = 1; - } else { - self_p->buf_p[self_p->byte_offset] |= (value << (8 - self_p->bit_offset - 1)); - - if (self_p->bit_offset == 7) { - self_p->bit_offset = 0; - self_p->byte_offset++; - } else { - self_p->bit_offset++; - } - } -} - -void bitstream_writer_write_bytes(struct bitstream_writer_t *self_p, - const uint8_t *buf_p, - int length) -{ - int i; - uint8_t *dst_p; - - dst_p = &self_p->buf_p[self_p->byte_offset]; - - if (self_p->bit_offset == 0) { - memcpy(dst_p, buf_p, sizeof(uint8_t) * length); - } else { - for (i = 0; i < length; i++) { - dst_p[i] |= (buf_p[i] >> self_p->bit_offset); - dst_p[i + 1] = (uint8_t)(buf_p[i] << (8 - self_p->bit_offset)); - } - } - - self_p->byte_offset += length; -} - -void bitstream_writer_write_u8(struct bitstream_writer_t *self_p, - uint8_t value) -{ - if (self_p->bit_offset == 0) { - self_p->buf_p[self_p->byte_offset] = value; - } else { - self_p->buf_p[self_p->byte_offset] |= (value >> self_p->bit_offset); - self_p->buf_p[self_p->byte_offset + 1] = - (uint8_t)(value << (8 - self_p->bit_offset)); - } - - self_p->byte_offset++; -} - -void bitstream_writer_write_u16(struct bitstream_writer_t *self_p, - uint16_t value) -{ - if (self_p->bit_offset == 0) { - self_p->buf_p[self_p->byte_offset] = (value >> 8); - } else { - self_p->buf_p[self_p->byte_offset] |= (value >> (8 + self_p->bit_offset)); - self_p->buf_p[self_p->byte_offset + 2] = - (uint8_t)(value << (8 - self_p->bit_offset)); - value >>= self_p->bit_offset; - } - - self_p->buf_p[self_p->byte_offset + 1] = (uint8_t)value; - self_p->byte_offset += 2; -} - -void bitstream_writer_write_u32(struct bitstream_writer_t *self_p, - uint32_t value) -{ - int i; - - if (self_p->bit_offset == 0) { - self_p->buf_p[self_p->byte_offset] = (value >> 24); - } else { - self_p->buf_p[self_p->byte_offset] |= (value >> (24 + self_p->bit_offset)); - self_p->buf_p[self_p->byte_offset + 4] = - (uint8_t)(value << (8 - self_p->bit_offset)); - value >>= self_p->bit_offset; - } - - for (i = 3; i > 0; i--) { - self_p->buf_p[self_p->byte_offset + i] = value; - value >>= 8; - } - - self_p->byte_offset += 4; -} - -void bitstream_writer_write_u64(struct bitstream_writer_t *self_p, - uint64_t value) -{ - int i; - - - if (self_p->bit_offset == 0) { - self_p->buf_p[self_p->byte_offset] = (value >> 56); - } else { - self_p->buf_p[self_p->byte_offset] |= (value >> (56 + self_p->bit_offset)); - self_p->buf_p[self_p->byte_offset + 8] = - (uint8_t)(value << (8 - self_p->bit_offset)); - value >>= self_p->bit_offset; - } - - for (i = 7; i > 0; i--) { - self_p->buf_p[self_p->byte_offset + i] = (uint8_t)value; - value >>= 8; - } - - self_p->byte_offset += 8; -} - -void bitstream_writer_write_u64_bits(struct bitstream_writer_t *self_p, - uint64_t value, - int number_of_bits) -{ - int i; - int first_byte_bits; - int last_byte_bits; - int full_bytes; - - if (number_of_bits == 0) { - return; - } - - /* Align beginning. */ - first_byte_bits = (8 - self_p->bit_offset); - - if (first_byte_bits != 8) { - if (number_of_bits < first_byte_bits) { - self_p->buf_p[self_p->byte_offset] |= - (uint8_t)(value << (first_byte_bits - number_of_bits)); - self_p->bit_offset += number_of_bits; - } else { - self_p->buf_p[self_p->byte_offset] |= (value >> (number_of_bits - - first_byte_bits)); - self_p->byte_offset++; - self_p->bit_offset = 0; - } - - number_of_bits -= first_byte_bits; - - if (number_of_bits <= 0) { - return; - } - } - - /* Align end. */ - last_byte_bits = (number_of_bits % 8); - full_bytes = (number_of_bits / 8); - - if (last_byte_bits != 0) { - self_p->buf_p[self_p->byte_offset + full_bytes] = - (uint8_t)(value << (8 - last_byte_bits)); - value >>= last_byte_bits; - self_p->bit_offset = last_byte_bits; - } - - /* Copy middle bytes. */ - for (i = full_bytes; i > 0; i--) { - self_p->buf_p[self_p->byte_offset + i - 1] = (uint8_t)value; - value >>= 8; - } - - self_p->byte_offset += full_bytes; -} - -void bitstream_writer_write_repeated_bit(struct bitstream_writer_t *self_p, - int value, - int length) -{ - int rest; - - if (value != 0) { - value = 0xff; - } - - rest = (length % 8); - bitstream_writer_write_u64_bits(self_p, value & ((1 << rest) - 1), rest); - bitstream_writer_write_repeated_u8(self_p, value, length / 8); -} - -void bitstream_writer_write_repeated_u8(struct bitstream_writer_t *self_p, - uint8_t value, - int length) -{ - int i; - - for (i = 0; i < length; i++) { - bitstream_writer_write_u8(self_p, value); - } -} - -void bitstream_writer_insert_bit(struct bitstream_writer_t *self_p, - int value) -{ - struct bitstream_writer_bounds_t bounds; - - bitstream_writer_bounds_save(&bounds, - self_p, - (8 * self_p->byte_offset) + self_p->bit_offset, - 1); - bitstream_writer_write_bit(self_p, value); - bitstream_writer_bounds_restore(&bounds); -} - -void bitstream_writer_insert_bytes(struct bitstream_writer_t *self_p, - const uint8_t *buf_p, - int length) -{ - struct bitstream_writer_bounds_t bounds; - - bitstream_writer_bounds_save(&bounds, - self_p, - (8 * self_p->byte_offset) + self_p->bit_offset, - 8 * length); - bitstream_writer_write_bytes(self_p, buf_p, length); - bitstream_writer_bounds_restore(&bounds); -} - -void bitstream_writer_insert_u8(struct bitstream_writer_t *self_p, - uint8_t value) -{ - struct bitstream_writer_bounds_t bounds; - - bitstream_writer_bounds_save(&bounds, - self_p, - (8 * self_p->byte_offset) + self_p->bit_offset, - 8); - bitstream_writer_write_u8(self_p, value); - bitstream_writer_bounds_restore(&bounds); -} - -void bitstream_writer_insert_u16(struct bitstream_writer_t *self_p, - uint16_t value) -{ - struct bitstream_writer_bounds_t bounds; - - bitstream_writer_bounds_save(&bounds, - self_p, - (8 * self_p->byte_offset) + self_p->bit_offset, - 16); - bitstream_writer_write_u16(self_p, value); - bitstream_writer_bounds_restore(&bounds); -} - -void bitstream_writer_insert_u32(struct bitstream_writer_t *self_p, - uint32_t value) -{ - struct bitstream_writer_bounds_t bounds; - - bitstream_writer_bounds_save(&bounds, - self_p, - (8 * self_p->byte_offset) + self_p->bit_offset, - 32); - bitstream_writer_write_u32(self_p, value); - bitstream_writer_bounds_restore(&bounds); -} - -void bitstream_writer_insert_u64(struct bitstream_writer_t *self_p, - uint64_t value) -{ - struct bitstream_writer_bounds_t bounds; - - bitstream_writer_bounds_save(&bounds, - self_p, - (8 * self_p->byte_offset) + self_p->bit_offset, - 64); - bitstream_writer_write_u64(self_p, value); - bitstream_writer_bounds_restore(&bounds); -} - -void bitstream_writer_insert_u64_bits(struct bitstream_writer_t *self_p, - uint64_t value, - int number_of_bits) -{ - struct bitstream_writer_bounds_t bounds; - - bitstream_writer_bounds_save(&bounds, - self_p, - (8 * self_p->byte_offset) + self_p->bit_offset, - number_of_bits); - bitstream_writer_write_u64_bits(self_p, value, number_of_bits); - bitstream_writer_bounds_restore(&bounds); -} - -void bitstream_writer_seek(struct bitstream_writer_t *self_p, - int offset) -{ - offset += ((8 * self_p->byte_offset) + self_p->bit_offset); - self_p->byte_offset = (offset / 8); - self_p->bit_offset = (offset % 8); -} - -void bitstream_writer_bounds_save(struct bitstream_writer_bounds_t *self_p, - struct bitstream_writer_t *writer_p, - int bit_offset, - int length) -{ - int number_of_bits; - - self_p->writer_p = writer_p; - number_of_bits = (bit_offset % 8); - - if (number_of_bits == 0) { - self_p->first_byte_offset = -1; - } else { - self_p->first_byte_offset = (bit_offset / 8); - self_p->first_byte = writer_p->buf_p[self_p->first_byte_offset]; - self_p->first_byte &= (0xff00 >> number_of_bits); - } - - number_of_bits = ((bit_offset + length) % 8); - - if (number_of_bits == 0) { - self_p->last_byte_offset = -1; - } else { - self_p->last_byte_offset = ((bit_offset + length) / 8); - self_p->last_byte = writer_p->buf_p[self_p->last_byte_offset]; - self_p->last_byte &= ~(0xff00 >> number_of_bits); - writer_p->buf_p[self_p->last_byte_offset] = 0; - } - - if (self_p->first_byte_offset != -1) { - writer_p->buf_p[self_p->first_byte_offset] = 0; - } -} - -void bitstream_writer_bounds_restore(struct bitstream_writer_bounds_t *self_p) -{ - if (self_p->first_byte_offset != -1) { - self_p->writer_p->buf_p[self_p->first_byte_offset] |= self_p->first_byte; - } - - if (self_p->last_byte_offset != -1) { - self_p->writer_p->buf_p[self_p->last_byte_offset] |= self_p->last_byte; - } -} - -void bitstream_reader_init(struct bitstream_reader_t *self_p, - const uint8_t *buf_p) -{ - self_p->buf_p = buf_p; - self_p->byte_offset = 0; - self_p->bit_offset = 0; -} - -int bitstream_reader_read_bit(struct bitstream_reader_t *self_p) -{ - int value; - - if (self_p->bit_offset == 0) { - value = (self_p->buf_p[self_p->byte_offset] >> 7); - self_p->bit_offset = 1; - } else { - value = ((self_p->buf_p[self_p->byte_offset] >> (7 - self_p->bit_offset)) & 0x1); - - if (self_p->bit_offset == 7) { - self_p->bit_offset = 0; - self_p->byte_offset++; - } else { - self_p->bit_offset++; - } - } - - return (value); -} - -void bitstream_reader_read_bytes(struct bitstream_reader_t *self_p, - uint8_t *buf_p, - int length) -{ - int i; - const uint8_t *src_p; - - src_p = &self_p->buf_p[self_p->byte_offset]; - - if (self_p->bit_offset == 0) { - memcpy(buf_p, src_p, sizeof(uint8_t) * length); - } else { - for (i = 0; i < length; i++) { - buf_p[i] = (src_p[i] << self_p->bit_offset); - buf_p[i] |= (src_p[i + 1] >> (8 - self_p->bit_offset)); - } - } - - self_p->byte_offset += length; -} - -uint8_t bitstream_reader_read_u8(struct bitstream_reader_t *self_p) -{ - uint8_t value; - - value = (self_p->buf_p[self_p->byte_offset] << self_p->bit_offset); - self_p->byte_offset++; - - if (self_p->bit_offset != 0) { - value |= (self_p->buf_p[self_p->byte_offset] >> (8 - self_p->bit_offset)); - } - - return (value); -} - -uint16_t bitstream_reader_read_u16(struct bitstream_reader_t *self_p) -{ - uint16_t value; - int i; - int offset; - const uint8_t *src_p; - - src_p = &self_p->buf_p[self_p->byte_offset]; - offset = (16 + self_p->bit_offset); - value = 0; - - for (i = 0; i < 2; i++) { - offset -= 8; - value |= ((uint16_t)src_p[i] << offset); - } - - if (offset != 0) { - value |= (src_p[2] >> (8 - offset)); - } - - self_p->byte_offset += 2; - - return (value); -} - -uint32_t bitstream_reader_read_u32(struct bitstream_reader_t *self_p) -{ - uint32_t value; - int i; - int offset; - const uint8_t *src_p; - - src_p = &self_p->buf_p[self_p->byte_offset]; - offset = (32 + self_p->bit_offset); - value = 0; - - for (i = 0; i < 4; i++) { - offset -= 8; - value |= ((uint32_t)src_p[i] << offset); - } - - if (offset != 0) { - value |= (src_p[4] >> (8 - offset)); - } - - self_p->byte_offset += 4; - - return (value); -} - -uint64_t bitstream_reader_read_u64(struct bitstream_reader_t *self_p) -{ - uint64_t value; - int i; - int offset; - const uint8_t *src_p; - - src_p = &self_p->buf_p[self_p->byte_offset]; - offset = (64 + self_p->bit_offset); - value = 0; - - for (i = 0; i < 8; i++) { - offset -= 8; - value |= ((uint64_t)src_p[i] << offset); - } - - if (offset != 0) { - value |= ((uint64_t)src_p[8] >> (8 - offset)); - } - - self_p->byte_offset += 8; - - return (value); -} - -uint64_t bitstream_reader_read_u64_bits(struct bitstream_reader_t *self_p, - int number_of_bits) -{ - uint64_t value; - int i; - int first_byte_bits; - int last_byte_bits; - int full_bytes; - - if (number_of_bits == 0) { - return (0); - } - - /* Align beginning. */ - first_byte_bits = (8 - self_p->bit_offset); - - if (first_byte_bits != 8) { - if (number_of_bits < first_byte_bits) { - value = (self_p->buf_p[self_p->byte_offset] >> (first_byte_bits - - number_of_bits)); - value &= ((1 << number_of_bits) - 1); - self_p->bit_offset += number_of_bits; - } else { - value = self_p->buf_p[self_p->byte_offset]; - value &= ((1 << first_byte_bits) - 1); - self_p->byte_offset++; - self_p->bit_offset = 0; - } - - number_of_bits -= first_byte_bits; - - if (number_of_bits <= 0) { - return (value); - } - } else { - value = 0; - } - - /* Copy middle bytes. */ - full_bytes = (number_of_bits / 8); - - for (i = 0; i < full_bytes; i++) { - value <<= 8; - value |= self_p->buf_p[self_p->byte_offset + i]; - } - - /* Last byte. */ - last_byte_bits = (number_of_bits % 8); - - if (last_byte_bits != 0) { - value <<= last_byte_bits; - value |= (self_p->buf_p[self_p->byte_offset + full_bytes] - >> (8 - last_byte_bits)); - self_p->bit_offset = last_byte_bits; - } - - self_p->byte_offset += full_bytes; - - return (value); -} - -void bitstream_reader_seek(struct bitstream_reader_t *self_p, - int offset) -{ - offset += ((8 * self_p->byte_offset) + self_p->bit_offset); - self_p->byte_offset = (offset / 8); - self_p->bit_offset = (offset % 8); -} - -int bitstream_reader_tell(struct bitstream_reader_t *self_p) -{ - return ((8 * self_p->byte_offset) + self_p->bit_offset); -} - -#ifdef __cplusplus -} -#endif diff --git a/third_party/bitstream/bitstream.h b/third_party/bitstream/bitstream.h deleted file mode 100644 index 9ced7b9..0000000 --- a/third_party/bitstream/bitstream.h +++ /dev/null @@ -1,178 +0,0 @@ -/** - * The MIT License (MIT) - * - * Copyright (c) 2019 Erik Moqvist - * - * Permission is hereby granted, free of charge, to any person - * obtaining a copy of this software and associated documentation - * files (the "Software"), to deal in the Software without - * restriction, including without limitation the rights to use, copy, - * modify, merge, publish, distribute, sublicense, and/or sell copies - * of the Software, and to permit persons to whom the Software is - * furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be - * included in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE - * SOFTWARE. - */ - -#ifndef BITSTREAM_H -#define BITSTREAM_H - -#ifdef __cplusplus -extern "C" { -#endif // __cplusplus - -#include - -#define BITSTREAM_VERSION "0.8.0" - -struct bitstream_writer_t { - uint8_t *buf_p; - int byte_offset; - int bit_offset; -}; - -struct bitstream_writer_bounds_t { - struct bitstream_writer_t *writer_p; - int first_byte_offset; - uint8_t first_byte; - int last_byte_offset; - uint8_t last_byte; -}; - -struct bitstream_reader_t { - const uint8_t *buf_p; - int byte_offset; - int bit_offset; -}; - -/* - * The writer. - */ - -void bitstream_writer_init(struct bitstream_writer_t *self_p, - uint8_t *buf_p); - -int bitstream_writer_size_in_bits(struct bitstream_writer_t *self_p); - -int bitstream_writer_size_in_bytes(struct bitstream_writer_t *self_p); - -/* Write bits to the stream. Clears each byte before bits are - written. */ -void bitstream_writer_write_bit(struct bitstream_writer_t *self_p, - int value); - -void bitstream_writer_write_bytes(struct bitstream_writer_t *self_p, - const uint8_t *buf_p, - int length); - -void bitstream_writer_write_u8(struct bitstream_writer_t *self_p, - uint8_t value); - -void bitstream_writer_write_u16(struct bitstream_writer_t *self_p, - uint16_t value); - -void bitstream_writer_write_u32(struct bitstream_writer_t *self_p, - uint32_t value); - -void bitstream_writer_write_u64(struct bitstream_writer_t *self_p, - uint64_t value); - -/* Upper unused bits must be zero. */ -void bitstream_writer_write_u64_bits(struct bitstream_writer_t *self_p, - uint64_t value, - int number_of_bits); - -void bitstream_writer_write_repeated_bit(struct bitstream_writer_t *self_p, - int value, - int length); - -void bitstream_writer_write_repeated_u8(struct bitstream_writer_t *self_p, - uint8_t value, - int length); - -/* Insert bits into the stream. Leaves all other bits unmodified. */ -void bitstream_writer_insert_bit(struct bitstream_writer_t *self_p, - int value); - -void bitstream_writer_insert_bytes(struct bitstream_writer_t *self_p, - const uint8_t *buf_p, - int length); - -void bitstream_writer_insert_u8(struct bitstream_writer_t *self_p, - uint8_t value); - -void bitstream_writer_insert_u16(struct bitstream_writer_t *self_p, - uint16_t value); - -void bitstream_writer_insert_u32(struct bitstream_writer_t *self_p, - uint32_t value); - -void bitstream_writer_insert_u64(struct bitstream_writer_t *self_p, - uint64_t value); - -void bitstream_writer_insert_u64_bits(struct bitstream_writer_t *self_p, - uint64_t value, - int number_of_bits); - -/* Move write position. Seeking backwards makes the written size - smaller. Use write with care after seek, as seek does not clear - bytes. */ -void bitstream_writer_seek(struct bitstream_writer_t *self_p, - int offset); - -/* Save-restore first and last bytes in given range, so write can be - used in given range. */ -void bitstream_writer_bounds_save(struct bitstream_writer_bounds_t *self_p, - struct bitstream_writer_t *writer_p, - int bit_offset, - int length); - -void bitstream_writer_bounds_restore(struct bitstream_writer_bounds_t *self_p); - -/* - * The reader. - */ - -void bitstream_reader_init(struct bitstream_reader_t *self_p, - const uint8_t *buf_p); - -/* Read bits from the stream. */ -int bitstream_reader_read_bit(struct bitstream_reader_t *self_p); - -void bitstream_reader_read_bytes(struct bitstream_reader_t *self_p, - uint8_t *buf_p, - int length); - -uint8_t bitstream_reader_read_u8(struct bitstream_reader_t *self_p); - -uint16_t bitstream_reader_read_u16(struct bitstream_reader_t *self_p); - -uint32_t bitstream_reader_read_u32(struct bitstream_reader_t *self_p); - -uint64_t bitstream_reader_read_u64(struct bitstream_reader_t *self_p); - -uint64_t bitstream_reader_read_u64_bits(struct bitstream_reader_t *self_p, - int number_of_bits); - -/* Move read position. */ -void bitstream_reader_seek(struct bitstream_reader_t *self_p, - int offset); - -/* Get read position. */ -int bitstream_reader_tell(struct bitstream_reader_t *self_p); - -#ifdef __cplusplus -} -#endif // __cplusplus - -#endif // BITSTREAM_H From f1ec46aa277546841b255a50bef7211949c1a0c3 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 16:54:53 -0500 Subject: [PATCH 066/131] Working script to create a single header file --- script-requirements.txt | 1 - scripts/create_single_header.sh | 14 +++++++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) delete mode 100644 script-requirements.txt mode change 100644 => 100755 scripts/create_single_header.sh diff --git a/script-requirements.txt b/script-requirements.txt deleted file mode 100644 index 86aed3c..0000000 --- a/script-requirements.txt +++ /dev/null @@ -1 +0,0 @@ -Quom==1.2.0 \ No newline at end of file diff --git a/scripts/create_single_header.sh b/scripts/create_single_header.sh old mode 100644 new mode 100755 index 71ee4fa..cf32065 --- a/scripts/create_single_header.sh +++ b/scripts/create_single_header.sh @@ -1 +1,13 @@ -quom -I include -I src src/dbc.cpp build/libdbc.hpp \ No newline at end of file +#!/bin/sh + +set -e + +cargo install cpp-amalgamate + +rm -rf build/single_header/ +mkdir -p build/single_header/libdbc + +files=$(find src -name "*.cpp") +files="${files} $(find include -name "*.hpp")" + +cpp-amalgamate -d include -d build/_deps/fastfloat-src/include ${files} -o build/single_header/libdbc/libdbc.hpp \ No newline at end of file From b3d5c832f209a71d1c6800bfe001e8ad24c647e6 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 17:43:27 -0500 Subject: [PATCH 067/131] Working single header creation Clang format added line endings because the creation of single header needs extra line before EOF Reformatted the spacing of the cmake for the tests Added line before EOF in files. --- .clang-format | 2 + CMakeLists.txt | 12 ++-- README.md | 9 +++ include/libdbc/dbc.hpp | 1 - include/libdbc/exceptions/error.hpp | 2 +- scripts/create_single_header.sh | 6 +- src/signal.cpp | 2 +- test/CMakeLists.txt | 52 +++++++++++------ .../test_single_header.cpp | 56 +++++++++++++++++++ ...arseMessage.cpp => test_parse_message.cpp} | 0 10 files changed, 113 insertions(+), 29 deletions(-) create mode 100644 test/single_header_testing/test_single_header.cpp rename test/{test_parseMessage.cpp => test_parse_message.cpp} (100%) diff --git a/.clang-format b/.clang-format index e553c79..e5d309b 100644 --- a/.clang-format +++ b/.clang-format @@ -102,3 +102,5 @@ AllowShortLambdasOnASingleLine: Empty # We do not want clang-format to put all arguments on a new line AllowAllArgumentsOnNextLine: false + +InsertNewlineAtEOF: true diff --git a/CMakeLists.txt b/CMakeLists.txt index f7ffd79..4bf2650 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,6 +9,7 @@ project(dbc option(DBC_ENABLE_TESTS "Enable Unittests" ON) option(DBC_TEST_LOCALE_INDEPENDENCE "Used to deterime if the libary is locale agnostic when it comes to converting floats. You need `de_DE.UTF-8` locale installed for this testing." OFF) option(DBC_GENERATE_DOCS "Use doxygen if installed to generated documentation files" OFF) +option(DBC_GENERATE_SINGLE_HEADER "This will run the generator for the single header file version. Default is OFF since we make a static build. Requires cargo installed." OFF) # ---------------------- # set(CMAKE_EXPORT_COMPILE_COMMANDS ON) @@ -94,11 +95,12 @@ target_sources(${PROJECT_NAME} INTERFACE FILE_SET HEADERS FILES ${HEADER_FILES} ) -add_custom_target(release - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - COMMAND ${CMAKE_SOURCE_DIR}/scripts/create_single_header.sh - DEPENDS ${PROJECT_NAME} -) +if(DBC_GENERATE_SINGLE_HEADER) + add_custom_target(single_header ALL + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + COMMAND ${CMAKE_SOURCE_DIR}/scripts/create_single_header.sh + ) +endif() ## Installation # install lib diff --git a/README.md b/README.md index d9f37e8..77d46ec 100644 --- a/README.md +++ b/README.md @@ -36,6 +36,15 @@ cmake -LH .. | grep -B1 "DBC_" cmake -LAH .. ``` +### Creating a Single Header File + +If you want to generate one header file you will need to run the `./scripts/create_single_header.sh`. + +It requires you have `cargo` installed from rust. See these instructions if you don't have that https://www.rust-lang.org/tools/install. +It uses the https://github.com/Felerius/cpp-amalgamate crate to do the single header file creation. + +The output will be generated in the `build/single_header/libdbc/` folder. You can run a cmake command to build this as well as other targets. + ## Testing I am trying to always make sure that this is very well tested code. I am using Catch2 to do this diff --git a/include/libdbc/dbc.hpp b/include/libdbc/dbc.hpp index b43d9e4..bff9c4e 100644 --- a/include/libdbc/dbc.hpp +++ b/include/libdbc/dbc.hpp @@ -1,4 +1,3 @@ - #ifndef __DBC_HPP__ #define __DBC_HPP__ diff --git a/include/libdbc/exceptions/error.hpp b/include/libdbc/exceptions/error.hpp index 8fa3954..175cac7 100644 --- a/include/libdbc/exceptions/error.hpp +++ b/include/libdbc/exceptions/error.hpp @@ -21,4 +21,4 @@ class validity_error : public exception { } // libdbc -#endif // __ERROR_HPP__ \ No newline at end of file +#endif // __ERROR_HPP__ diff --git a/scripts/create_single_header.sh b/scripts/create_single_header.sh index cf32065..a740133 100755 --- a/scripts/create_single_header.sh +++ b/scripts/create_single_header.sh @@ -7,7 +7,7 @@ cargo install cpp-amalgamate rm -rf build/single_header/ mkdir -p build/single_header/libdbc -files=$(find src -name "*.cpp") -files="${files} $(find include -name "*.hpp")" +source_files=$(find src -name "*.cpp") +include_files=$(find include -name "*.hpp") -cpp-amalgamate -d include -d build/_deps/fastfloat-src/include ${files} -o build/single_header/libdbc/libdbc.hpp \ No newline at end of file +cpp-amalgamate -d include -d build/_deps/fastfloat-src/include -o build/single_header/libdbc/libdbc.hpp ${source_files} ${include_files} diff --git a/src/signal.cpp b/src/signal.cpp index c4b703b..a2ad53d 100644 --- a/src/signal.cpp +++ b/src/signal.cpp @@ -51,4 +51,4 @@ std::ostream& operator<<(std::ostream& out, const Signal& sig) { out << r; return out << "}"; } -} \ No newline at end of file +} diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 7dc7db5..bc57725 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -3,9 +3,9 @@ enable_testing() # Download and build Catch2 test framework Include(FetchContent) FetchContent_Declare( - Catch2 - GIT_REPOSITORY https://github.com/catchorg/Catch2.git - GIT_TAG v3.5.2 + Catch2 + GIT_REPOSITORY https://github.com/catchorg/Catch2.git + GIT_TAG v3.5.2 ) FetchContent_MakeAvailable(Catch2) include(Catch) @@ -14,9 +14,9 @@ include(Catch) set(CMAKE_CXX_STANDARD 17) if (MSVC) - add_compile_options(/W4 /WX) + add_compile_options(/W4 /WX) else() - add_compile_options(-Wall -Wextra -Wpedantic -Werror) + add_compile_options(-Wall -Wextra -Wpedantic -Werror) endif() # Code coverage compiler specific @@ -24,11 +24,12 @@ if (GCC) add_compile_options(--coverage) endif() + add_executable(dbcParserTests - test_dbc.cpp - test_utils.cpp - test_parseMessage.cpp - common.cpp + test_dbc.cpp + test_utils.cpp + test_parse_message.cpp + common.cpp ) target_compile_definitions(dbcParserTests PRIVATE TESTDBCFILES_PATH="${CMAKE_CURRENT_SOURCE_DIR}/dbcs") @@ -40,16 +41,31 @@ catch_discover_tests(dbcParserTests) # We want a seperate binary for this test. We setup global locals which mess with all of the testing. # Opting for a sperate test running so we don't conflict if(DBC_TEST_LOCALE_INDEPENDENCE) - add_executable(dbcLocaleTests - locale_testing/test_locale_main.cpp - common.cpp - ) + add_executable(dbcLocaleTests + locale_testing/test_locale_main.cpp + common.cpp + ) - target_compile_definitions(dbcLocaleTests PRIVATE TESTDBCFILES_PATH="${CMAKE_CURRENT_SOURCE_DIR}/dbcs") - target_link_libraries(dbcLocaleTests PRIVATE dbc Catch2::Catch2WithMain) - target_include_directories(dbcLocaleTests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) + target_compile_definitions(dbcLocaleTests PRIVATE TESTDBCFILES_PATH="${CMAKE_CURRENT_SOURCE_DIR}/dbcs") + target_link_libraries(dbcLocaleTests PRIVATE dbc Catch2::Catch2WithMain) + target_include_directories(dbcLocaleTests PRIVATE ${CMAKE_CURRENT_SOURCE_DIR}) - catch_discover_tests(dbcLocaleTests) +catch_discover_tests(dbcLocaleTests) else() - message(WARNING "Locale independent testing is turned off!") + message(WARNING "Locale independent testing is turned off!") +endif() + +# Again another test binary to ensure we aren't including our other headers. +# It should compile and run on one include +if(DBC_GENERATE_SINGLE_HEADER) + add_executable(dbcSingleHeaderTest + single_header_testing/test_single_header.cpp + common.cpp + ) + + target_compile_definitions(dbcSingleHeaderTest PRIVATE TESTDBCFILES_PATH="${CMAKE_CURRENT_SOURCE_DIR}/dbcs") + target_link_libraries(dbcSingleHeaderTest PRIVATE Catch2::Catch2WithMain) + target_include_directories(dbcSingleHeaderTest PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_BINARY_DIR}/single_header/) + + catch_discover_tests(dbcSingleHeaderTest) endif() diff --git a/test/single_header_testing/test_single_header.cpp b/test/single_header_testing/test_single_header.cpp new file mode 100644 index 0000000..fce0e41 --- /dev/null +++ b/test/single_header_testing/test_single_header.cpp @@ -0,0 +1,56 @@ +#include "common.hpp" +#include "defines.hpp" +#include + +#include +#include +#include + +TEST_CASE("Testing dbc file loading", "[fileio]") { + auto parser = std::unique_ptr(new libdbc::DbcParser()); + + SECTION("Loading a single simple dbc file", "[dbc]") { + std::vector nodes = {"DBG", "DRIVER", "IO", "MOTOR", "SENSOR"}; + + libdbc::Message msg(500, "IO_DEBUG", 4, "IO"); + + std::vector receivers{"DBG"}; + libdbc::Signal sig("IO_DEBUG_test_unsigned", false, 0, 8, false, false, 1, 0, 0, 0, "", receivers); + msg.appendSignal(sig); + + std::vector msgs = {msg}; + + parser->parse_file(SIMPLE_DBC_FILE); + + REQUIRE(parser->get_version() == "1.0.0"); + + REQUIRE(parser->get_nodes() == nodes); + + REQUIRE(parser->get_messages() == msgs); + + REQUIRE(parser->get_messages().front().getSignals() == msg.getSignals()); + } +} + +TEST_CASE("Testing big endian, little endian") { + std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 234 MSG1: 8 Vector__XXX + SG_ Sig1 : 55|16@0- (0.1,0) [-3276.8|-3276.7] "C" Vector__XXX + SG_ Sig2 : 39|16@1- (0.1,0) [-3276.8|-3276.7] "C" Vector__XXX)"; + const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); + + auto parser = libdbc::DbcParser(); + parser.parse_file(filename.c_str()); + + REQUIRE(parser.get_messages().size() == 1); + REQUIRE(parser.get_messages().at(0).name() == "MSG1"); + REQUIRE(parser.get_messages().at(0).size() == 8); + REQUIRE(parser.get_messages().at(0).getSignals().size() == 2); + { + const auto signal = parser.get_messages().at(0).getSignals().at(0); + REQUIRE(signal.is_bigendian == true); + } + { + const auto signal = parser.get_messages().at(0).getSignals().at(1); + REQUIRE(signal.is_bigendian == false); + } +} diff --git a/test/test_parseMessage.cpp b/test/test_parse_message.cpp similarity index 100% rename from test/test_parseMessage.cpp rename to test/test_parse_message.cpp From 490069fef8fd8262c62746d48300447f27b74b49 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 17:48:07 -0500 Subject: [PATCH 068/131] Refactored the common and defines to a testing_utils folder --- test/CMakeLists.txt | 6 +-- test/locale_testing/test_locale_main.cpp | 4 +- .../test_single_header.cpp | 4 +- test/test_dbc.cpp | 4 +- test/test_parse_message.cpp | 4 +- test/test_utils.cpp | 2 +- test/{ => testing_utils}/common.cpp | 4 +- test/{ => testing_utils}/common.hpp | 0 test/{ => testing_utils}/defines.hpp | 44 +++++++++---------- 9 files changed, 36 insertions(+), 36 deletions(-) rename test/{ => testing_utils}/common.cpp (94%) rename test/{ => testing_utils}/common.hpp (100%) rename test/{ => testing_utils}/defines.hpp (97%) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index bc57725..d265d2b 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -29,7 +29,7 @@ add_executable(dbcParserTests test_dbc.cpp test_utils.cpp test_parse_message.cpp - common.cpp + testing_utils/common.cpp ) target_compile_definitions(dbcParserTests PRIVATE TESTDBCFILES_PATH="${CMAKE_CURRENT_SOURCE_DIR}/dbcs") @@ -43,7 +43,7 @@ catch_discover_tests(dbcParserTests) if(DBC_TEST_LOCALE_INDEPENDENCE) add_executable(dbcLocaleTests locale_testing/test_locale_main.cpp - common.cpp + testing_utils/common.cpp ) target_compile_definitions(dbcLocaleTests PRIVATE TESTDBCFILES_PATH="${CMAKE_CURRENT_SOURCE_DIR}/dbcs") @@ -60,7 +60,7 @@ endif() if(DBC_GENERATE_SINGLE_HEADER) add_executable(dbcSingleHeaderTest single_header_testing/test_single_header.cpp - common.cpp + testing_utils/common.cpp ) target_compile_definitions(dbcSingleHeaderTest PRIVATE TESTDBCFILES_PATH="${CMAKE_CURRENT_SOURCE_DIR}/dbcs") diff --git a/test/locale_testing/test_locale_main.cpp b/test/locale_testing/test_locale_main.cpp index 4f99b20..7336545 100644 --- a/test/locale_testing/test_locale_main.cpp +++ b/test/locale_testing/test_locale_main.cpp @@ -1,5 +1,5 @@ -#include "common.hpp" -#include "defines.hpp" +#include "testing_utils/common.hpp" +#include "testing_utils/defines.hpp" #include #include diff --git a/test/single_header_testing/test_single_header.cpp b/test/single_header_testing/test_single_header.cpp index fce0e41..d61dac6 100644 --- a/test/single_header_testing/test_single_header.cpp +++ b/test/single_header_testing/test_single_header.cpp @@ -1,5 +1,5 @@ -#include "common.hpp" -#include "defines.hpp" +#include "testing_utils/common.hpp" +#include "testing_utils/defines.hpp" #include #include diff --git a/test/test_dbc.cpp b/test/test_dbc.cpp index 93f8991..508df5c 100644 --- a/test/test_dbc.cpp +++ b/test/test_dbc.cpp @@ -1,5 +1,5 @@ -#include "common.hpp" -#include "defines.hpp" +#include "testing_utils/common.hpp" +#include "testing_utils/defines.hpp" #include #include #include diff --git a/test/test_parse_message.cpp b/test/test_parse_message.cpp index 3eaacb0..3c3c301 100644 --- a/test/test_parse_message.cpp +++ b/test/test_parse_message.cpp @@ -4,8 +4,8 @@ #include -#include "common.hpp" -#include "defines.hpp" +#include "testing_utils/common.hpp" +#include "testing_utils/defines.hpp" // Testing of parsing messages diff --git a/test/test_utils.cpp b/test/test_utils.cpp index 6417498..ea3d594 100644 --- a/test/test_utils.cpp +++ b/test/test_utils.cpp @@ -1,4 +1,4 @@ -#include "defines.hpp" +#include "testing_utils/defines.hpp" #include #include diff --git a/test/common.cpp b/test/testing_utils/common.cpp similarity index 94% rename from test/common.cpp rename to test/testing_utils/common.cpp index 053a3ed..e058054 100644 --- a/test/common.cpp +++ b/test/testing_utils/common.cpp @@ -1,5 +1,5 @@ -#include "common.hpp" -#include "defines.hpp" +#include "testing_utils/common.hpp" +#include "testing_utils/defines.hpp" #include #include #include diff --git a/test/common.hpp b/test/testing_utils/common.hpp similarity index 100% rename from test/common.hpp rename to test/testing_utils/common.hpp diff --git a/test/defines.hpp b/test/testing_utils/defines.hpp similarity index 97% rename from test/defines.hpp rename to test/testing_utils/defines.hpp index fcd0206..42d7ee8 100644 --- a/test/defines.hpp +++ b/test/testing_utils/defines.hpp @@ -1,22 +1,22 @@ -#include - -// Correctly formated files -static const std::string COMPLEX_DBC_FILE = std::string(TESTDBCFILES_PATH) + "/Complex.dbc"; -static const std::string SIMPLE_DBC_FILE = std::string(TESTDBCFILES_PATH) + "/Simple.dbc"; - -// Files with Errors -static const std::string MISSING_NEW_SYMBOLS_DBC_FILE = std::string(TESTDBCFILES_PATH) + "/MissingNewSymbols.dbc"; -static const std::string MISSING_VERSION_DBC_FILE = std::string(TESTDBCFILES_PATH) + "/MissingVersion.dbc"; -static const std::string MISSING_BIT_TIMING_DBC_FILE = std::string(TESTDBCFILES_PATH) + "/MissingBitTiming.dbc"; -static const std::string TEXT_FILE = std::string(TESTDBCFILES_PATH) + "/TextFile.txt"; - -static const std::string PRIMITIVE_DBC = - R"(VERSION "1.0.0" - -NS_ : - -BS_: - -BU_: DBG DRIVER IO MOTOR SENSOR - -)"; +#include + +// Correctly formated files +static const std::string COMPLEX_DBC_FILE = std::string(TESTDBCFILES_PATH) + "/Complex.dbc"; +static const std::string SIMPLE_DBC_FILE = std::string(TESTDBCFILES_PATH) + "/Simple.dbc"; + +// Files with Errors +static const std::string MISSING_NEW_SYMBOLS_DBC_FILE = std::string(TESTDBCFILES_PATH) + "/MissingNewSymbols.dbc"; +static const std::string MISSING_VERSION_DBC_FILE = std::string(TESTDBCFILES_PATH) + "/MissingVersion.dbc"; +static const std::string MISSING_BIT_TIMING_DBC_FILE = std::string(TESTDBCFILES_PATH) + "/MissingBitTiming.dbc"; +static const std::string TEXT_FILE = std::string(TESTDBCFILES_PATH) + "/TextFile.txt"; + +static const std::string PRIMITIVE_DBC = + R"(VERSION "1.0.0" + +NS_ : + +BS_: + +BU_: DBG DRIVER IO MOTOR SENSOR + +)"; From f7470b51752343b3f69981f9c42c9220d8ed77ac Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 18:08:45 -0500 Subject: [PATCH 069/131] Install cargo for single header creation in github. Bumping clang-format to 16 --- .github/workflows/pipeline.yml | 22 +++++++++++++--------- scripts/fmt.sh | 6 +++--- 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 2bda82a..5c6d0fd 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -42,18 +42,22 @@ jobs: sudo locale-gen de_DE.UTF-8 + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y + source "$HOME/.cargo/env" + - name: Configure build working-directory: ${{runner.workspace}} env: CC: ${{matrix.cc}} CXX: ${{matrix.cxx}} run: | - cmake -Bbuild -H$GITHUB_WORKSPACE \ + cmake -Bbuild -H$GITHUB_WORKSPACE \ -DCMAKE_BUILD_TYPE=${{matrix.build_type}} \ - -DCMAKE_CXX_STANDARD=${{matrix.std}} \ - -DCMAKE_CXX_STANDARD_REQUIRED=ON \ - -DCMAKE_CXX_EXTENSIONS=ON \ - -DDBC_TEST_LOCALE_INDEPENDENCE=ON + -DCMAKE_CXX_STANDARD=${{matrix.std}} \ + -DCMAKE_CXX_STANDARD_REQUIRED=ON \ + -DCMAKE_CXX_EXTENSIONS=ON \ + -DDBC_TEST_LOCALE_INDEPENDENCE=ON \ + -DDBC_GENERATE_SINGLE_HEADER=ON - name: Build tests + lib working-directory: ${{runner.workspace}} @@ -129,11 +133,11 @@ jobs: CC: ${{matrix.cc}} CXX: ${{matrix.cxx}} run: | - cmake -Bbuild -H$GITHUB_WORKSPACE \ + cmake -Bbuild -H$GITHUB_WORKSPACE \ -DCMAKE_BUILD_TYPE=${{matrix.build_type}} \ - -DCMAKE_CXX_STANDARD=${{matrix.std}} \ - -DCMAKE_CXX_STANDARD_REQUIRED=ON \ - -DCMAKE_CXX_EXTENSIONS=ON \ + -DCMAKE_CXX_STANDARD=${{matrix.std}} \ + -DCMAKE_CXX_STANDARD_REQUIRED=ON \ + -DCMAKE_CXX_EXTENSIONS=ON \ -DDBC_TEST_LOCALE_INDEPENDENCE=ON - name: Build tests + lib diff --git a/scripts/fmt.sh b/scripts/fmt.sh index 8f360f8..9e15b4e 100755 --- a/scripts/fmt.sh +++ b/scripts/fmt.sh @@ -11,8 +11,8 @@ FMT="" # Some distros just call it clang-format. Others (e.g. Ubuntu) are insistent # that the version number be part of the command. We prefer clang-format if -# that's present, otherwise we check clang-format-13 -for clangfmt in clang-format{,-13}; do +# that's present, otherwise we check clang-format-16 +for clangfmt in clang-format{,-16}; do if which "$clangfmt" &>/dev/null; then FMT="$clangfmt" break @@ -21,7 +21,7 @@ done # Check if we found a working clang-format if [ -z "$FMT" ]; then - echo "failed to find clang-format. Please install clang-format version 13 or above" + echo "failed to find clang-format. Please install clang-format version 16 or above" exit 1 fi From 68a8f83fb097a4bfd6eede02ad37da30fd71a8c6 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 18:13:04 -0500 Subject: [PATCH 070/131] Installing clang-format 16 --- .github/workflows/pipeline.yml | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 5c6d0fd..9d0b253 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -154,7 +154,15 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + + - name: Install clang-format version + run: | + wget https://apt.llvm.org/llvm.sh + chmod +x llvm.sh + sudo ./llvm.sh 16 + + clang-format --version - name: Test format with clang format run: ./scripts/fmt.sh From 29edf4c1f40ff64567553b7ccc6eb84cad53c92d Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 18:43:01 -0500 Subject: [PATCH 071/131] Adding the dependencies correctly. Need to install the header before the test target --- CMakeLists.txt | 68 ++++++++++++++++++++++----------------------- test/CMakeLists.txt | 2 ++ 2 files changed, 36 insertions(+), 34 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 4bf2650..e9cbed5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,8 @@ cmake_minimum_required(VERSION 3.16) project(dbc - VERSION 0.2.0 - DESCRIPTION "C++ DBC Parser" + VERSION 0.2.0 + DESCRIPTION "C++ DBC Parser" ) # -- PROJECT OPTIONS -- # @@ -28,20 +28,20 @@ set(CMAKE_CXX_STANDARD_REQUIRED True) find_package(FastFloat QUIET) if (NOT ${FastFloat_FOUND}) - include(FetchContent) - FetchContent_Declare( - FastFloat - GIT_REPOSITORY https://github.com/fastfloat/fast_float.git - GIT_TAG 1ea4f27b2aeee2859a1354a3c24cff52a116cad1 - ) - # FetchContent_MakeAvailable(FastFloat) - FetchContent_Populate(FastFloat) - add_subdirectory(${fastfloat_SOURCE_DIR} ${fastfloat_BINARY_DIR} EXCLUDE_FROM_ALL) + include(FetchContent) + FetchContent_Declare( + FastFloat + GIT_REPOSITORY https://github.com/fastfloat/fast_float.git + GIT_TAG 1ea4f27b2aeee2859a1354a3c24cff52a116cad1 + ) + # FetchContent_MakeAvailable(FastFloat) + FetchContent_Populate(FastFloat) + add_subdirectory(${fastfloat_SOURCE_DIR} ${fastfloat_BINARY_DIR} EXCLUDE_FROM_ALL) endif() # add where to find the source files list(APPEND SOURCE_FILES - ${PROJECT_SOURCE_DIR}/src/utils.cpp + ${PROJECT_SOURCE_DIR}/src/utils.cpp ${PROJECT_SOURCE_DIR}/src/message.cpp ${PROJECT_SOURCE_DIR}/src/signal.cpp ${PROJECT_SOURCE_DIR}/src/dbc.cpp @@ -56,50 +56,50 @@ list(APPEND HEADER_FILES ) if(DBC_ENABLE_TESTS) - include(CTest) - add_subdirectory(test) + include(CTest) + add_subdirectory(test) endif() if(DBC_GENERATE_DOCS) - add_subdirectory(doc) + add_subdirectory(doc) endif() list(APPEND GCC_CLANG_COMPILE_FLAGS - -Wall -Wextra -Wpedantic - -Wconversion -Wint-in-bool-context - -Wmissing-declarations -Wmissing-field-initializers - -Werror + -Wall -Wextra -Wpedantic + -Wconversion -Wint-in-bool-context + -Wmissing-declarations -Wmissing-field-initializers + -Werror ) if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC") - add_compile_options(/W4 /WX) + add_compile_options(/W4 /WX) elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") - # Clang shadow warnings aren't as sensitive as gcc - add_compile_options(${GCC_CLANG_COMPILE_FLAGS} -Wshadow) + # Clang shadow warnings aren't as sensitive as gcc + add_compile_options(${GCC_CLANG_COMPILE_FLAGS} -Wshadow) else() - add_compile_options(${GCC_CLANG_COMPILE_FLAGS}) + add_compile_options(${GCC_CLANG_COMPILE_FLAGS}) endif() add_library(${PROJECT_NAME} STATIC ${SOURCE_FILES}) target_link_libraries(${PROJECT_NAME} FastFloat::fast_float) target_include_directories(${PROJECT_NAME} PUBLIC - $ - $ + $ + $ ) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) target_sources(${PROJECT_NAME} INTERFACE FILE_SET HEADERS - TYPE HEADERS - BASE_DIRS ${PROJECT_SOURCE_DIR}/include/libdbc - FILES ${HEADER_FILES} + TYPE HEADERS + BASE_DIRS ${PROJECT_SOURCE_DIR}/include/libdbc + FILES ${HEADER_FILES} ) if(DBC_GENERATE_SINGLE_HEADER) - add_custom_target(single_header ALL - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - COMMAND ${CMAKE_SOURCE_DIR}/scripts/create_single_header.sh - ) + add_custom_target(single_header ALL + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + COMMAND ${CMAKE_SOURCE_DIR}/scripts/create_single_header.sh + ) endif() ## Installation @@ -113,5 +113,5 @@ install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/libdbc DESTINATION ${CMAKE_INSTA # Generate pkg-config file configure_file(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY) install( - FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc - DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) + FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index d265d2b..fc8cf97 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -68,4 +68,6 @@ if(DBC_GENERATE_SINGLE_HEADER) target_include_directories(dbcSingleHeaderTest PRIVATE ${CMAKE_CURRENT_SOURCE_DIR} ${CMAKE_BINARY_DIR}/single_header/) catch_discover_tests(dbcSingleHeaderTest) + + add_dependencies(dbcSingleHeaderTest single_header) endif() From e57d62cb4d74faa7b85678aa71853229ec1fa963 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 19:01:12 -0500 Subject: [PATCH 072/131] Attempt to override clang-format link in github and set makeavailable for the fastfloat --- .github/workflows/pipeline.yml | 2 ++ CMakeLists.txt | 4 +--- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 9d0b253..290a7cd 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -162,6 +162,8 @@ jobs: chmod +x llvm.sh sudo ./llvm.sh 16 + ln -sf $(which clang-format-16) $(which clang-format) + clang-format --version - name: Test format with clang format diff --git a/CMakeLists.txt b/CMakeLists.txt index e9cbed5..7ffeb04 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -34,9 +34,7 @@ if (NOT ${FastFloat_FOUND}) GIT_REPOSITORY https://github.com/fastfloat/fast_float.git GIT_TAG 1ea4f27b2aeee2859a1354a3c24cff52a116cad1 ) - # FetchContent_MakeAvailable(FastFloat) - FetchContent_Populate(FastFloat) - add_subdirectory(${fastfloat_SOURCE_DIR} ${fastfloat_BINARY_DIR} EXCLUDE_FROM_ALL) + FetchContent_MakeAvailable(FastFloat) endif() # add where to find the source files From f8123edfbf21d1e48017a4e12d810508d505b6cf Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 19:02:50 -0500 Subject: [PATCH 073/131] Force override of clang format link --- .github/workflows/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 290a7cd..6e5079e 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -162,7 +162,7 @@ jobs: chmod +x llvm.sh sudo ./llvm.sh 16 - ln -sf $(which clang-format-16) $(which clang-format) + sudo ln -sf $(which clang-format-16) $(which clang-format) clang-format --version From fafac20cef2ec1f9c66afd79eb5ce1ceb876fb95 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 19:20:44 -0500 Subject: [PATCH 074/131] Actually installing clang-format 16 and trying to remove the working directories from the linux builds --- .github/workflows/pipeline.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 6e5079e..f5322af 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -46,7 +46,6 @@ jobs: source "$HOME/.cargo/env" - name: Configure build - working-directory: ${{runner.workspace}} env: CC: ${{matrix.cc}} CXX: ${{matrix.cxx}} @@ -60,13 +59,11 @@ jobs: -DDBC_GENERATE_SINGLE_HEADER=ON - name: Build tests + lib - working-directory: ${{runner.workspace}} run: cmake --build build --parallel `nproc` - name: Run tests env: CTEST_OUTPUT_ON_FAILURE: 1 - working-directory: ${{runner.workspace}} run: ctest --output-on-failure --test-dir build -j `nproc` windows-build: @@ -162,9 +159,10 @@ jobs: chmod +x llvm.sh sudo ./llvm.sh 16 + sudo apt update && sudo apt install -y clang-format-16 sudo ln -sf $(which clang-format-16) $(which clang-format) - clang-format --version + test "$(clang-format --version)" == "$(clang-forsmat-16 --version)" - name: Test format with clang format run: ./scripts/fmt.sh From a15b6a5de3423c54fe47747c506fa458989da07f Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 19:22:54 -0500 Subject: [PATCH 075/131] Typo in the test command for the clang-format version --- .github/workflows/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index f5322af..024bb66 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -162,7 +162,7 @@ jobs: sudo apt update && sudo apt install -y clang-format-16 sudo ln -sf $(which clang-format-16) $(which clang-format) - test "$(clang-format --version)" == "$(clang-forsmat-16 --version)" + test "$(clang-format --version)" == "$(clang-format-16 --version)" - name: Test format with clang format run: ./scripts/fmt.sh From 099bf14b87acb3610660654662ec0fdde3fd3398 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 20:06:09 -0500 Subject: [PATCH 076/131] Updated the release yaml and now have a script to validate the input against the current project version --- .github/data/release_body.md | 19 +++++++++ .github/workflows/pipeline.yml | 2 +- .github/workflows/release.yml | 71 ++++++++++++++++++++++++++++++---- CMakeLists.txt | 6 +-- scripts/check_version.py | 55 ++++++++++++++++++++++++++ 5 files changed, 141 insertions(+), 12 deletions(-) create mode 100644 .github/data/release_body.md create mode 100755 scripts/check_version.py diff --git a/.github/data/release_body.md b/.github/data/release_body.md new file mode 100644 index 0000000..df96e6d --- /dev/null +++ b/.github/data/release_body.md @@ -0,0 +1,19 @@ +# Libdbc release + +### Developer Notes + +**TODO: Update this!** + +## Breaking Changes + +* + +## Features + +* + +## Bugs + +* + + diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 024bb66..b630847 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -1,6 +1,6 @@ name: Libdbc Pipeline -on: [push] +on: [push, workflow_call] env: # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 9d76a79..0753591 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -5,23 +5,80 @@ on: inputs: major: required: true - type: string + description: "The major version" + type: number minor: required: true - type: string + description: "The minor version" + type: number patch: required: true - type: string + description: "The patch version" + type: number + + release_type: + type: choice + description: "The type of release you are making. Controls branch naming / creation" + options: + - patch + - minor + - major jobs: + check_version: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: "Validate version in cmake before continuing" + run: ./scripts/check_version.py --version "v${{ inputs.major }}.${{ inputs.minor }}.${{ inputs.patch }}" + + pipeline: + runs-on: ubuntu-latest + needs: [check_version] + uses: ./.github/workflows/pipeline.yml + create_release: runs-on: ubuntu-latest + needs: [pipeline] + + env: + header_file_path: build/single_header/libdbc/libdbc.hpp + steps: - - name: "Checkout the code" - uses: actions/checkout@v3 + - uses: actions/checkout@v4 + + - name: "Setup Cargo" + run: | + curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y + source "$HOME/.cargo/env" + + - name: "Generate the header only library" + run: ./scripts/create_single_header.sh + + - uses: actions/upload-artifact@v4 + with: + if-no-files-found: error + name: header-only + path: ${{ env.header_file_path }} + + - name: "Create a branch if we are making a major / minor release" + uses: peterjgrainger/action-create-branch@v2.2.0 + if: ${{ inputs.major }} || ${{ inputs.minor }} + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} + with: + branch: 'release/v${{ inputs.major }}.${{ inputs.minor }}' + sha: '${{ github.sha }}' - - name: "Run tests as a pre check" - uses: .github/workflows/tests.yml + - uses: ncipollo/release-action@v1 + with: + artifacts: "${{ env.header_file_path }}" + draft: true + bodyFile: ".github/workflows/release_body.md" + tag: v${{ inputs.major }}.${{ inputs.minor }}.${{ inputs.patch }} + commit: release/v${{ inputs.major }}.${{ inputs.minor }} diff --git a/CMakeLists.txt b/CMakeLists.txt index 7ffeb04..e3afc99 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,9 +1,7 @@ cmake_minimum_required(VERSION 3.16) -project(dbc - VERSION 0.2.0 - DESCRIPTION "C++ DBC Parser" -) +# Keep this on one line for release checking +project(dbc VERSION 0.2.0 DESCRIPTION "C++ DBC Parser") # -- PROJECT OPTIONS -- # option(DBC_ENABLE_TESTS "Enable Unittests" ON) diff --git a/scripts/check_version.py b/scripts/check_version.py new file mode 100755 index 0000000..3881db4 --- /dev/null +++ b/scripts/check_version.py @@ -0,0 +1,55 @@ +#!/usr/bin/env python3 +# Used to check the input verion against the input +import re +import argparse + + +def get_cmake_version(cmake_file): + with open(cmake_file, 'r') as f: + contents = f.read() + match = re.search(r'project\(.*VERSION (\d+)\.(\d+)\.(\d+)', contents) + if match: + major, minor, patch = map(int, match.groups()) + return major, minor, patch + return None + + +def validate_semver(version): + pattern = r'^v(\d+)\.(\d+)\.(\d+)$' + match = re.match(pattern, version) + if match: + return tuple(map(int, match.groups())) + else: + return None + + +def compare_versions(input_version, cmake_version): + if input_version > cmake_version: + print("Input version is greater than CMake version.") + exit(1) + elif input_version < cmake_version: + print("Input version is smaller than CMake version.") + exit(1) + else: + print("Input version is equal to CMake version.") + + +if __name__ == "__main__": + parser = argparse.ArgumentParser(description="Check input version against CMake project version") + parser.add_argument("--version", type=str, help="Input version with a 'v' prefix", required=True) + args = parser.parse_args() + + cmake_version = get_cmake_version("CMakeLists.txt") + if cmake_version is None: + print("Failed to retrieve version from CMakeLists.txt.") + exit(1) + else: + input_version = validate_semver(args.version) + if input_version is None: + print("Invalid input version format. Please provide a version in the format 'vX.Y.Z'") + exit(1) + else: + compare_versions(input_version, cmake_version) + + + From bfe7953c96d0dcad3d877df88820ecea9d79c916 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 20:07:38 -0500 Subject: [PATCH 077/131] Fixing branch creation skip logic --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 0753591..810f382 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -65,7 +65,7 @@ jobs: - name: "Create a branch if we are making a major / minor release" uses: peterjgrainger/action-create-branch@v2.2.0 - if: ${{ inputs.major }} || ${{ inputs.minor }} + if: ${{ inputs.release_type }} == "minor" || ${{ inputs.release_type }} == "major" env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: From ed989c09036d649194fbb777459cee248503d71f Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 20:09:19 -0500 Subject: [PATCH 078/131] Remove the runs-on for resuable call step --- .github/workflows/release.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 810f382..6b01964 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -35,7 +35,6 @@ jobs: run: ./scripts/check_version.py --version "v${{ inputs.major }}.${{ inputs.minor }}.${{ inputs.patch }}" pipeline: - runs-on: ubuntu-latest needs: [check_version] uses: ./.github/workflows/pipeline.yml From 20652ad32fc0258b11a053cfe659a4eec808632d Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 20:20:19 -0500 Subject: [PATCH 079/131] Fixing release to use cmake to do the building of the header --- .github/workflows/release.yml | 7 +++++-- README.md | 10 ++++++++-- 2 files changed, 13 insertions(+), 4 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 6b01964..a6ac1c3 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -53,8 +53,11 @@ jobs: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y source "$HOME/.cargo/env" - - name: "Generate the header only library" - run: ./scripts/create_single_header.sh + - name: Configure build + run: cmake -Bbuild -H$GITHUB_WORKSPACE -DDBC_GENERATE_SINGLE_HEADER=ON + + - name: Generate the header file + run: cmake --build build --parallel `nproc` --target single_header - uses: actions/upload-artifact@v4 with: diff --git a/README.md b/README.md index 77d46ec..c35eb7d 100644 --- a/README.md +++ b/README.md @@ -38,13 +38,19 @@ cmake -LAH .. ### Creating a Single Header File -If you want to generate one header file you will need to run the `./scripts/create_single_header.sh`. - It requires you have `cargo` installed from rust. See these instructions if you don't have that https://www.rust-lang.org/tools/install. It uses the https://github.com/Felerius/cpp-amalgamate crate to do the single header file creation. The output will be generated in the `build/single_header/libdbc/` folder. You can run a cmake command to build this as well as other targets. +To just build the single header you can simply run the target: +```shell +cmake -Bbuild -H. -DDBC_GENERATE_SINGLE_HEADER=ON + +cmake --build build --parallel `nproc` --target single-header +``` + + ## Testing I am trying to always make sure that this is very well tested code. I am using Catch2 to do this From 404880d5ce0436c5687746a7a2a2ac151d1587c9 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 20:24:23 -0500 Subject: [PATCH 080/131] Fixing typo in single_header command in the README --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index c35eb7d..8702453 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ To just build the single header you can simply run the target: ```shell cmake -Bbuild -H. -DDBC_GENERATE_SINGLE_HEADER=ON -cmake --build build --parallel `nproc` --target single-header +cmake --build build --parallel `nproc` --target single_header ``` From f7067ffa7b6ea9dda465e8c18f59438188caf661 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 20:26:24 -0500 Subject: [PATCH 081/131] Release body path typo in the action --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index a6ac1c3..b7cc050 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -78,7 +78,7 @@ jobs: with: artifacts: "${{ env.header_file_path }}" draft: true - bodyFile: ".github/workflows/release_body.md" + bodyFile: ".github/data/release_body.md" tag: v${{ inputs.major }}.${{ inputs.minor }}.${{ inputs.patch }} commit: release/v${{ inputs.major }}.${{ inputs.minor }} From 162da79223eeef6f8e348929b4a3812068861e04 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 20:29:48 -0500 Subject: [PATCH 082/131] Updating release action name with the given inputs --- .github/workflows/release.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index b7cc050..ba9dac2 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,4 @@ -name: Libdbc Release +name: Libdbc release v${{ inputs.major }}.${{ inputs.minor }}.${{ inputs.patch }} as release type ${{ inputs.release_type }} on: workflow_dispatch: From 465eeb00bccbff15ec2f0cda46e4e67077c66179 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 20:31:27 -0500 Subject: [PATCH 083/131] Fixing run-name not name in release yaml --- .github/workflows/release.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index ba9dac2..63ff8e1 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -1,4 +1,5 @@ -name: Libdbc release v${{ inputs.major }}.${{ inputs.minor }}.${{ inputs.patch }} as release type ${{ inputs.release_type }} +name: Libdbc Release +run-name: Libdbc release v${{ inputs.major }}.${{ inputs.minor }}.${{ inputs.patch }} as release type ${{ inputs.release_type }} on: workflow_dispatch: From af79962323996185b99aac221ba6578e35bfaa19 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 28 Jan 2024 20:36:10 -0500 Subject: [PATCH 084/131] Correcting the branch name for releases to show it contains all patches --- .github/workflows/release.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 63ff8e1..0e45a26 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -72,7 +72,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} with: - branch: 'release/v${{ inputs.major }}.${{ inputs.minor }}' + branch: 'release/v${{ inputs.major }}.${{ inputs.minor }}.X' sha: '${{ github.sha }}' - uses: ncipollo/release-action@v1 @@ -81,7 +81,7 @@ jobs: draft: true bodyFile: ".github/data/release_body.md" tag: v${{ inputs.major }}.${{ inputs.minor }}.${{ inputs.patch }} - commit: release/v${{ inputs.major }}.${{ inputs.minor }} + commit: release/v${{ inputs.major }}.${{ inputs.minor }}.X From 58f485ee6bd94525291b0ae636503b7f6985bbfa Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Thu, 1 Feb 2024 18:56:02 -0500 Subject: [PATCH 085/131] Require bracing on single line if statements using clang format --- .clang-format | 2 ++ src/dbc.cpp | 56 ++++++++++++++++++++++++++++++++----------------- src/message.cpp | 11 ++++++---- src/signal.cpp | 3 ++- 4 files changed, 48 insertions(+), 24 deletions(-) diff --git a/.clang-format b/.clang-format index e5d309b..c409644 100644 --- a/.clang-format +++ b/.clang-format @@ -44,6 +44,8 @@ BraceWrapping: AfterClass: false AfterCaseLabel: false +InsertBraces: true + # CrlInstruction *a; DerivePointerAlignment: false PointerAlignment: Left diff --git a/src/dbc.cpp b/src/dbc.cpp index 8b3dac6..be9d34f 100644 --- a/src/dbc.cpp +++ b/src/dbc.cpp @@ -43,20 +43,25 @@ bool parseVal(const std::string& str, VALObject& obj) { for (;;) { switch (state) { case Identifier: { - if (*a != 'V') + if (*a != 'V') { return false; + } a++; - if (*a != 'A') + if (*a != 'A') { return false; + } a++; - if (*a != 'L') + if (*a != 'L') { return false; + } a++; - if (*a != '_') + if (*a != '_') { return false; + } a++; - if (*a != ' ') + if (*a != ' ') { return false; + } a++; // skip whitespace state = CANId; break; @@ -67,27 +72,31 @@ bool parseVal(const std::string& str, VALObject& obj) { can_id_str += *a; a++; } - if (can_id_str.empty()) + if (can_id_str.empty()) { return false; + } obj.can_id = static_cast(std::stoul(can_id_str)); - if (*a != ' ') + if (*a != ' ') { return false; + } a++; // skip whitespace state = SignalName; break; } case SignalName: { - if ((*a >= 'a' && *a <= 'z') || (*a >= 'A' && *a <= 'Z') || *a == '_') + if ((*a >= 'a' && *a <= 'z') || (*a >= 'A' && *a <= 'Z') || *a == '_') { obj.signal_name += *a; - else + } else { return false; + } a++; while ((*a >= 'a' && *a <= 'z') || (*a >= 'A' && *a <= 'Z') || *a == '_' || (*a >= '0' && *a <= '9')) { obj.signal_name += *a; a++; } - if (*a != ' ') + if (*a != ' ') { return false; + } a++; // skip whitespace state = Value; break; @@ -99,15 +108,18 @@ bool parseVal(const std::string& str, VALObject& obj) { a++; } if (*a == ';') { - if (value_str.empty()) + if (value_str.empty()) { return true; + } return false; } - if (value_str.empty()) + if (value_str.empty()) { return false; + } - if (*a != ' ') + if (*a != ' ') { return false; + } a++; // skip whitespace vd.value = (uint32_t)std::stoul(value_str); state = Description; @@ -115,18 +127,21 @@ bool parseVal(const std::string& str, VALObject& obj) { } case Description: { std::string desc; - if (*a != '"') + if (*a != '"') { return false; + } a++; while (*a != '"' && *a != 0) { desc += *a; a++; } - if (*a == 0) + if (*a == 0) { return false; + } a++; - if (*a != ' ') + if (*a != ' ') { return false; + } a++; // skip whitespace vd.description = desc; @@ -188,8 +203,9 @@ std::vector DbcParser::get_messages() const { Message::ParseSignalsStatus DbcParser::parseMessage(const uint32_t id, const std::vector& data, std::vector& out_values) { for (const auto& message : messages) { - if (message.id() == id) + if (message.id() == id) { return message.parseSignals(data, out_values); + } } return Message::ParseSignalsStatus::ErrorUnknownID; } @@ -212,8 +228,9 @@ void DbcParser::parse_dbc_header(std::istream& file_stream) { utils::StreamHandler::get_next_non_blank_line(file_stream, line); - if (!std::regex_search(line, match, bit_timing_re)) + if (!std::regex_search(line, match, bit_timing_re)) { throw validity_error(); + } } void DbcParser::parse_dbc_nodes(std::istream& file_stream) { @@ -222,8 +239,9 @@ void DbcParser::parse_dbc_nodes(std::istream& file_stream) { utils::StreamHandler::get_next_non_blank_line(file_stream, line); - if (!std::regex_search(line, match, node_re)) + if (!std::regex_search(line, match, node_re)) { throw validity_error(); + } if (match.length() > 2) { std::string n = match.str(2); diff --git a/src/message.cpp b/src/message.cpp index 443526a..f16677a 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -16,8 +16,9 @@ bool Message::operator==(const Message& rhs) const { Message::ParseSignalsStatus Message::parseSignals(const std::vector& data, std::vector& values) const { auto size = data.size(); - if (size > 8) + if (size > 8) { return ParseSignalsStatus::ErrorMessageToLong; // not supported yet + } uint64_t data_little_endian = 0; uint64_t data_big_endian = 0; @@ -35,8 +36,9 @@ Message::ParseSignalsStatus Message::parseSignals(const std::vector& da uint32_t start_bit = 8 * (signal.start_bit / 8) + (7 - (signal.start_bit % 8)); // Calculation taken from python CAN v = data_big_endian << start_bit; v = v >> (len - signal.size); - } else + } else { v = data_little_endian >> signal.start_bit; + } if (signal.is_signed && signal.size > 1) { switch (signal.size) { @@ -56,10 +58,11 @@ Message::ParseSignalsStatus Message::parseSignals(const std::vector& da // 2 complement -> decimal const int negative = (v & (1ull << (signal.size - 1))) != 0; int64_t nativeInt; - if (negative) + if (negative) { nativeInt = static_cast(v | ~((1ull << signal.size) - 1)); // invert all bits above signal.size - else + } else { nativeInt = static_cast(v & ((1ull << signal.size) - 1)); // masking + } values.push_back(static_cast(nativeInt) * signal.factor + signal.offset); break; } diff --git a/src/signal.cpp b/src/signal.cpp index a2ad53d..d1ab7d8 100644 --- a/src/signal.cpp +++ b/src/signal.cpp @@ -47,8 +47,9 @@ std::ostream& operator<<(std::ostream& out, const Signal& sig) { out << "Min: " << sig.min << ", Max: " << sig.max << ", "; out << "Unit: (" << sig.unit << "), "; out << "receivers: "; - for (const auto& r : sig.receivers) + for (const auto& r : sig.receivers) { out << r; + } return out << "}"; } } From 753119d6615674876d5f21216438d8dd663bca92 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Thu, 1 Feb 2024 19:05:39 -0500 Subject: [PATCH 086/131] Removing whitespace and dead comments --- include/libdbc/message.hpp | 6 ------ src/dbc.cpp | 2 -- src/utils.cpp | 1 - 3 files changed, 9 deletions(-) diff --git a/include/libdbc/message.hpp b/include/libdbc/message.hpp index e903fed..f3b0b66 100644 --- a/include/libdbc/message.hpp +++ b/include/libdbc/message.hpp @@ -21,12 +21,6 @@ struct Message { ErrorInvalidConversion, }; - /*! - * \brief parseSignals - * \param data - * \param values - * \return - */ ParseSignalsStatus parseSignals(const std::vector& data, std::vector& values) const; void appendSignal(const Signal& signal); diff --git a/src/dbc.cpp b/src/dbc.cpp index be9d34f..7ea7ce3 100644 --- a/src/dbc.cpp +++ b/src/dbc.cpp @@ -223,9 +223,7 @@ void DbcParser::parse_dbc_header(std::istream& file_stream) { version = match.str(2); utils::StreamHandler::get_next_non_blank_line(file_stream, line); - utils::StreamHandler::skip_to_next_blank_line(file_stream, line); - utils::StreamHandler::get_next_non_blank_line(file_stream, line); if (!std::regex_search(line, match, bit_timing_re)) { diff --git a/src/utils.cpp b/src/utils.cpp index 35cff0c..f39cc81 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -75,7 +75,6 @@ std::string String::trim(const std::string& line) { double String::convert_to_double(const std::string& value, double default_value) { double converted_value = default_value; fast_float::from_chars(value.data(), value.data() + value.size(), converted_value); - // converted_value = std::stod(value); return converted_value; } From 6a2aeff602f14e506789086271f37ab4b8f4d399 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Thu, 1 Feb 2024 21:48:54 -0500 Subject: [PATCH 087/131] Adding initial clang tidy file and target to run it --- .clang-tidy | 368 +++++++++++++++++++++++++++++++++++++++++++++++++ CMakeLists.txt | 7 + 2 files changed, 375 insertions(+) create mode 100644 .clang-tidy diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000..45b0537 --- /dev/null +++ b/.clang-tidy @@ -0,0 +1,368 @@ +--- +Checks: 'clang-diagnostic-*,clang-analyzer-*,*,-clang-analyzer-alpha.*,-llvm-include-order' +WarningsAsErrors: '' +HeaderFilterRegex: '' +AnalyzeTemporaryDtors: false +FormatStyle: none +User: dwag +CheckOptions: + hicpp-move-const-arg.CheckMoveToConstRef: 'true' + readability-suspicious-call-argument.PrefixSimilarAbove: '30' + cppcoreguidelines-no-malloc.Reallocations: '::realloc' + portability-simd-intrinsics.Std: '' + cppcoreguidelines-owning-memory.LegacyResourceConsumers: '::free;::realloc;::freopen;::fclose' + bugprone-reserved-identifier.Invert: 'false' + cert-dcl16-c.IgnoreMacros: 'true' + bugprone-narrowing-conversions.PedanticMode: 'false' + altera-struct-pack-align.MaxConfiguredAlignment: '128' + bugprone-unused-return-value.CheckedFunctions: '::std::async;::std::launder;::std::remove;::std::remove_if;::std::unique;::std::unique_ptr::release;::std::basic_string::empty;::std::vector::empty;::std::back_inserter;::std::distance;::std::find;::std::find_if;::std::inserter;::std::lower_bound;::std::make_pair;::std::map::count;::std::map::find;::std::map::lower_bound;::std::multimap::equal_range;::std::multimap::upper_bound;::std::set::count;::std::set::find;::std::setfill;::std::setprecision;::std::setw;::std::upper_bound;::std::vector::at;::bsearch;::ferror;::feof;::isalnum;::isalpha;::isblank;::iscntrl;::isdigit;::isgraph;::islower;::isprint;::ispunct;::isspace;::isupper;::iswalnum;::iswprint;::iswspace;::isxdigit;::memchr;::memcmp;::strcmp;::strcoll;::strncmp;::strpbrk;::strrchr;::strspn;::strstr;::wcscmp;::access;::bind;::connect;::difftime;::dlsym;::fnmatch;::getaddrinfo;::getopt;::htonl;::htons;::iconv_open;::inet_addr;::isascii;::isatty;::mmap;::newlocale;::openat;::pathconf;::pthread_equal;::pthread_getspecific;::pthread_mutex_trylock;::readdir;::readlink;::recvmsg;::regexec;::scandir;::semget;::setjmp;::shm_open;::shmget;::sigismember;::strcasecmp;::strsignal;::ttyname' + modernize-use-auto.MinTypeNameLength: '5' + cert-dcl51-cpp.AggressiveDependentMemberLookup: 'false' + hicpp-use-auto.MinTypeNameLength: '5' + readability-inconsistent-declaration-parameter-name.Strict: 'false' + hicpp-use-override.IgnoreDestructors: 'false' + cppcoreguidelines-macro-usage.CheckCapsOnly: 'false' + readability-suspicious-call-argument.DiceDissimilarBelow: '60' + cert-dcl37-c.AllowedIdentifiers: '' + performance-inefficient-vector-operation.VectorLikeClasses: '::std::vector' + hicpp-use-emplace.SmartPointers: '::std::shared_ptr;::std::unique_ptr;::std::auto_ptr;::std::weak_ptr' + bugprone-assert-side-effect.IgnoredFunctions: __builtin_expect + hicpp-member-init.IgnoreArrays: 'false' + openmp-exception-escape.IgnoredExceptions: '' + readability-suspicious-call-argument.Equality: 'true' + hicpp-use-override.AllowOverrideAndFinal: 'false' + misc-uniqueptr-reset-release.IncludeStyle: llvm + abseil-string-find-str-contains.StringLikeClasses: '::std::basic_string;::std::basic_string_view;::absl::string_view' + readability-const-return-type.IgnoreMacros: 'true' + hicpp-signed-bitwise.IgnorePositiveIntegerLiterals: 'false' + bugprone-easily-swappable-parameters.QualifiersMix: 'false' + cert-err09-cpp.WarnOnLargeObjects: 'false' + bugprone-suspicious-string-compare.WarnOnImplicitComparison: 'true' + bugprone-argument-comment.CommentNullPtrs: '0' + android-comparison-in-temp-failure-retry.RetryMacros: TEMP_FAILURE_RETRY + cppcoreguidelines-narrowing-conversions.WarnOnFloatingPointNarrowingConversion: 'true' + hicpp-use-equals-delete.IgnoreMacros: 'true' + cppcoreguidelines-init-variables.IncludeStyle: llvm + modernize-use-nodiscard.ReplacementString: '[[nodiscard]]' + modernize-loop-convert.MakeReverseRangeHeader: '' + readability-avoid-const-params-in-decls.IgnoreMacros: 'true' + readability-suspicious-call-argument.SuffixSimilarAbove: '30' + misc-definitions-in-headers.HeaderFileExtensions: ';h;hh;hpp;hxx' + hicpp-uppercase-literal-suffix.NewSuffixes: '' + modernize-use-emplace.ContainersWithPush: '::std::stack;::std::queue;::std::priority_queue' + cppcoreguidelines-narrowing-conversions.WarnOnIntegerNarrowingConversion: 'true' + bugprone-easily-swappable-parameters.IgnoredParameterNames: '"";iterator;Iterator;begin;Begin;end;End;first;First;last;Last;lhs;LHS;rhs;RHS' + modernize-loop-convert.UseCxx20ReverseRanges: 'true' + cppcoreguidelines-prefer-member-initializer.UseAssignment: 'false' + hicpp-function-size.VariableThreshold: '4294967295' + cert-oop57-cpp.MemSetNames: '' + hicpp-no-malloc.Deallocations: '::free' + performance-type-promotion-in-math-fn.IncludeStyle: llvm + google-readability-function-size.LineThreshold: '4294967295' + readability-function-cognitive-complexity.DescribeBasicIncrements: 'true' + bugprone-suspicious-include.ImplementationFileExtensions: 'c;cc;cpp;cxx' + hicpp-use-emplace.ContainersWithPushFront: '::std::forward_list;::std::list;::std::deque' + modernize-loop-convert.MakeReverseRangeFunction: '' + readability-inconsistent-declaration-parameter-name.IgnoreMacros: 'true' + bugprone-suspicious-missing-comma.SizeThreshold: '5' + readability-identifier-naming.IgnoreFailedSplit: 'false' + hicpp-multiway-paths-covered.WarnOnMissingElse: 'false' + readability-qualified-auto.AddConstToQualified: 'true' + bugprone-sizeof-expression.WarnOnSizeOfThis: 'true' + bugprone-string-constructor.WarnOnLargeLength: 'true' + cppcoreguidelines-explicit-virtual-functions.OverrideSpelling: override + hicpp-no-malloc.Allocations: '::malloc;::calloc' + hicpp-use-noexcept.UseNoexceptFalse: 'true' + abseil-string-find-startswith.IncludeStyle: llvm + google-global-names-in-headers.HeaderFileExtensions: ';h;hh;hpp;hxx' + readability-uppercase-literal-suffix.IgnoreMacros: 'true' + modernize-make-shared.IgnoreMacros: 'true' + modernize-use-emplace.ContainersWithPushFront: '::std::forward_list;::std::list;::std::deque' + misc-const-correctness.TransformValues: 'true' + cert-dcl59-cpp.HeaderFileExtensions: ';h;hh;hpp;hxx' + bugprone-suspicious-enum-usage.StrictMode: 'false' + performance-unnecessary-copy-initialization.AllowedTypes: '' + bugprone-suspicious-missing-comma.MaxConcatenatedTokens: '5' + modernize-use-transparent-functors.SafeMode: 'false' + readability-suspicious-call-argument.Levenshtein: 'true' + bugprone-not-null-terminated-result.WantToUseSafeFunctions: 'true' + misc-throw-by-value-catch-by-reference.CheckThrowTemporaries: 'true' + bugprone-string-constructor.LargeLengthThreshold: '8388608' + bugprone-dynamic-static-initializers.HeaderFileExtensions: ';h;hh;hpp;hxx' + readability-simplify-boolean-expr.ChainedConditionalAssignment: 'false' + cppcoreguidelines-avoid-magic-numbers.IgnoreAllFloatingPointValues: 'false' + cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField: 'false' + cert-err09-cpp.CheckThrowTemporaries: 'true' + performance-inefficient-vector-operation.EnableProto: 'false' + bugprone-exception-escape.FunctionsThatShouldNotThrow: '' + modernize-loop-convert.MaxCopySize: '16' + readability-suspicious-call-argument.PrefixDissimilarBelow: '25' + readability-function-size.LineThreshold: '4294967295' + bugprone-easily-swappable-parameters.MinimumLength: '2' + portability-simd-intrinsics.Suggest: 'false' + hicpp-deprecated-headers.CheckHeaderFile: 'false' + modernize-use-override.IgnoreDestructors: 'false' + cppcoreguidelines-pro-bounds-constant-array-index.GslHeader: '' + modernize-make-shared.MakeSmartPtrFunctionHeader: '' + modernize-make-shared.MakeSmartPtrFunction: 'std::make_shared' + misc-non-private-member-variables-in-classes.IgnorePublicMemberVariables: 'false' + bugprone-sizeof-expression.WarnOnSizeOfConstant: 'true' + readability-redundant-string-init.StringNames: '::std::basic_string_view;::std::basic_string' + modernize-make-unique.IgnoreDefaultInitialization: 'true' + modernize-use-emplace.ContainersWithPushBack: '::std::vector;::std::list;::std::deque' + readability-magic-numbers.IgnoreBitFieldsWidths: 'true' + modernize-make-unique.IncludeStyle: llvm + modernize-use-override.OverrideSpelling: override + google-readability-function-size.NestingThreshold: '4294967295' + google-build-namespaces.HeaderFileExtensions: ';h;hh;hpp;hxx' + readability-suspicious-call-argument.LevenshteinDissimilarBelow: '50' + bugprone-argument-comment.CommentStringLiterals: '0' + concurrency-mt-unsafe.FunctionSet: any + readability-identifier-length.IgnoredExceptionVariableNames: '^[e]$' + google-readability-braces-around-statements.ShortStatementLines: '1' + bugprone-reserved-identifier.AllowedIdentifiers: '' + cppcoreguidelines-pro-type-member-init.IgnoreArrays: 'false' + readability-else-after-return.WarnOnUnfixable: 'true' + cppcoreguidelines-avoid-magic-numbers.IgnoredFloatingPointValues: '1.0;100.0;' + modernize-use-emplace.IgnoreImplicitConstructors: 'false' + cppcoreguidelines-macro-usage.IgnoreCommandLineMacros: 'true' + readability-suspicious-call-argument.Substring: 'true' + modernize-use-equals-delete.IgnoreMacros: 'true' + objc-forbidden-subclassing.ForbiddenSuperClassNames: 'ABNewPersonViewController;ABPeoplePickerNavigationController;ABPersonViewController;ABUnknownPersonViewController;NSHashTable;NSMapTable;NSPointerArray;NSPointerFunctions;NSTimer;UIActionSheet;UIAlertView;UIImagePickerController;UITextInputMode;UIWebView' + readability-identifier-length.IgnoredVariableNames: '' + readability-magic-numbers.IgnoreAllFloatingPointValues: 'false' + cppcoreguidelines-pro-bounds-constant-array-index.IncludeStyle: llvm + hicpp-use-auto.RemoveStars: 'false' + readability-suspicious-call-argument.Abbreviations: 'arr=array;cnt=count;idx=index;src=source;stmt=statement;cpy=copy;dest=destination;dist=distancedst=distance;ptr=pointer;wdth=width;str=string;ln=line;srv=server;attr=attribute;ref=reference;buf=buffer;col=column;nr=number;vec=vector;len=length;elem=element;val=value;i=index;var=variable;hght=height;cl=client;num=number;pos=position;lst=list;addr=address' + bugprone-misplaced-widening-cast.CheckImplicitCasts: 'false' + readability-uppercase-literal-suffix.NewSuffixes: '' + modernize-loop-convert.MinConfidence: reasonable + performance-unnecessary-value-param.AllowedTypes: '' + readability-uniqueptr-delete-release.PreferResetCall: 'false' + readability-identifier-length.MinimumExceptionNameLength: '2' + misc-definitions-in-headers.UseHeaderFileExtension: 'true' + google-readability-namespace-comments.SpacesBeforeComments: '2' + cppcoreguidelines-avoid-magic-numbers.IgnoreBitFieldsWidths: 'true' + cert-err61-cpp.CheckThrowTemporaries: 'true' + cppcoreguidelines-avoid-magic-numbers.IgnoredIntegerValues: '1;2;3;4;' + cppcoreguidelines-no-malloc.Allocations: '::malloc;::calloc' + misc-throw-by-value-catch-by-reference.MaxSize: '-1' + cppcoreguidelines-avoid-magic-numbers.IgnorePowersOf2IntegerValues: 'false' + bugprone-narrowing-conversions.IgnoreConversionFromTypes: '' + readability-function-size.BranchThreshold: '4294967295' + bugprone-suspicious-missing-comma.RatioThreshold: '0.200000' + hicpp-function-size.LineThreshold: '4294967295' + readability-implicit-bool-conversion.AllowIntegerConditions: 'false' + readability-identifier-length.IgnoredParameterNames: '^[n]$' + readability-function-size.StatementThreshold: '800' + hicpp-use-noexcept.ReplacementString: '' + readability-identifier-naming.IgnoreMainLikeFunctions: 'false' + cppcoreguidelines-init-variables.MathHeader: '' + google-runtime-int.SignedTypePrefix: int + google-readability-function-size.StatementThreshold: '800' + cert-msc51-cpp.DisallowedSeedTypes: 'time_t,std::time_t' + hicpp-use-emplace.TupleMakeFunctions: '::std::make_pair;::std::make_tuple' + bugprone-reserved-identifier.AggressiveDependentMemberLookup: 'false' + readability-suspicious-call-argument.DiceSimilarAbove: '70' + modernize-use-equals-default.IgnoreMacros: 'true' + readability-suspicious-call-argument.Abbreviation: 'true' + cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor: 'false' + cert-dcl37-c.AggressiveDependentMemberLookup: 'false' + readability-identifier-length.MinimumLoopCounterNameLength: '2' + abseil-string-find-str-contains.AbseilStringsMatchHeader: 'absl/strings/match.h' + bugprone-dangling-handle.HandleClasses: 'std::basic_string_view;std::experimental::basic_string_view' + cert-msc54-cpp.AsyncSafeFunctionSet: POSIX + modernize-use-emplace.SmartPointers: '::std::shared_ptr;::std::unique_ptr;::std::auto_ptr;::std::weak_ptr' + readability-magic-numbers.IgnorePowersOf2IntegerValues: 'false' + misc-const-correctness.TransformPointersAsValues: 'false' + readability-suspicious-call-argument.JaroWinklerSimilarAbove: '85' + misc-unused-parameters.StrictMode: 'false' + cppcoreguidelines-no-malloc.Deallocations: '::free' + readability-simplify-subscript-expr.Types: '::std::basic_string;::std::basic_string_view;::std::vector;::std::array' + performance-unnecessary-copy-initialization.ExcludedContainerTypes: '' + modernize-replace-auto-ptr.IncludeStyle: llvm + performance-move-const-arg.CheckTriviallyCopyableMove: 'true' + misc-const-correctness.TransformReferences: 'true' + hicpp-move-const-arg.CheckTriviallyCopyableMove: 'true' + readability-function-size.VariableThreshold: '4294967295' + readability-static-accessed-through-instance.NameSpecifierNestingThreshold: '3' + cert-dcl16-c.NewSuffixes: 'L;LL;LU;LLU' + misc-const-correctness.AnalyzeValues: 'true' + readability-identifier-naming.GetConfigPerFile: 'true' + bugprone-narrowing-conversions.WarnOnFloatingPointNarrowingConversion: 'true' + cert-sig30-c.AsyncSafeFunctionSet: POSIX + readability-simplify-boolean-expr.SimplifyDeMorgan: 'true' + cert-err61-cpp.MaxSize: '-1' + hicpp-member-init.UseAssignment: 'false' + modernize-use-default-member-init.UseAssignment: 'false' + readability-function-size.NestingThreshold: '4294967295' + google-readability-function-size.BranchThreshold: '4294967295' + bugprone-sizeof-expression.WarnOnSizeOfPointerToAggregate: 'true' + llvm-namespace-comment.ShortNamespaceLines: '1' + llvm-namespace-comment.SpacesBeforeComments: '1' + modernize-use-override.AllowOverrideAndFinal: 'false' + cppcoreguidelines-narrowing-conversions.IgnoreConversionFromTypes: '' + readability-function-size.ParameterThreshold: '4294967295' + hicpp-function-size.NestingThreshold: '4294967295' + modernize-pass-by-value.ValuesOnly: 'false' + readability-function-cognitive-complexity.IgnoreMacros: 'false' + modernize-loop-convert.IncludeStyle: llvm + cert-str34-c.DiagnoseSignedUnsignedCharComparisons: 'false' + bugprone-narrowing-conversions.WarnWithinTemplateInstantiation: 'false' + cert-err33-c.CheckedFunctions: '::aligned_alloc;::asctime_s;::at_quick_exit;::atexit;::bsearch;::bsearch_s;::btowc;::c16rtomb;::c32rtomb;::calloc;::clock;::cnd_broadcast;::cnd_init;::cnd_signal;::cnd_timedwait;::cnd_wait;::ctime_s;::fclose;::fflush;::fgetc;::fgetpos;::fgets;::fgetwc;::fopen;::fopen_s;::fprintf;::fprintf_s;::fputc;::fputs;::fputwc;::fputws;::fread;::freopen;::freopen_s;::fscanf;::fscanf_s;::fseek;::fsetpos;::ftell;::fwprintf;::fwprintf_s;::fwrite;::fwscanf;::fwscanf_s;::getc;::getchar;::getenv;::getenv_s;::gets_s;::getwc;::getwchar;::gmtime;::gmtime_s;::localtime;::localtime_s;::malloc;::mbrtoc16;::mbrtoc32;::mbsrtowcs;::mbsrtowcs_s;::mbstowcs;::mbstowcs_s;::memchr;::mktime;::mtx_init;::mtx_lock;::mtx_timedlock;::mtx_trylock;::mtx_unlock;::printf_s;::putc;::putwc;::raise;::realloc;::remove;::rename;::scanf;::scanf_s;::setlocale;::setvbuf;::signal;::snprintf;::snprintf_s;::sprintf;::sprintf_s;::sscanf;::sscanf_s;::strchr;::strerror_s;::strftime;::strpbrk;::strrchr;::strstr;::strtod;::strtof;::strtoimax;::strtok;::strtok_s;::strtol;::strtold;::strtoll;::strtoul;::strtoull;::strtoumax;::strxfrm;::swprintf;::swprintf_s;::swscanf;::swscanf_s;::thrd_create;::thrd_detach;::thrd_join;::thrd_sleep;::time;::timespec_get;::tmpfile;::tmpfile_s;::tmpnam;::tmpnam_s;::tss_create;::tss_get;::tss_set;::ungetc;::ungetwc;::vfprintf;::vfprintf_s;::vfscanf;::vfscanf_s;::vfwprintf;::vfwprintf_s;::vfwscanf;::vfwscanf_s;::vprintf_s;::vscanf;::vscanf_s;::vsnprintf;::vsnprintf_s;::vsprintf;::vsprintf_s;::vsscanf;::vsscanf_s;::vswprintf;::vswprintf_s;::vswscanf;::vswscanf_s;::vwprintf_s;::vwscanf;::vwscanf_s;::wcrtomb;::wcschr;::wcsftime;::wcspbrk;::wcsrchr;::wcsrtombs;::wcsrtombs_s;::wcsstr;::wcstod;::wcstof;::wcstoimax;::wcstok;::wcstok_s;::wcstol;::wcstold;::wcstoll;::wcstombs;::wcstombs_s;::wcstoul;::wcstoull;::wcstoumax;::wcsxfrm;::wctob;::wctrans;::wctype;::wmemchr;::wprintf_s;::wscanf;::wscanf_s;' + bugprone-suspicious-string-compare.WarnOnLogicalNotComparison: 'false' + hicpp-braces-around-statements.ShortStatementLines: '0' + cppcoreguidelines-explicit-virtual-functions.AllowOverrideAndFinal: 'false' + google-readability-function-size.ParameterThreshold: '4294967295' + readability-redundant-smartptr-get.IgnoreMacros: 'true' + readability-identifier-naming.AggressiveDependentMemberLookup: 'false' + cert-err61-cpp.WarnOnLargeObjects: 'false' + misc-const-correctness.WarnPointersAsValues: 'false' + readability-identifier-length.MinimumParameterNameLength: '3' + modernize-use-emplace.TupleTypes: '::std::pair;::std::tuple' + hicpp-use-emplace.IgnoreImplicitConstructors: 'false' + modernize-use-emplace.TupleMakeFunctions: '::std::make_pair;::std::make_tuple' + bugprone-narrowing-conversions.WarnOnIntegerToFloatingPointNarrowingConversion: 'true' + cppcoreguidelines-owning-memory.LegacyResourceProducers: '::malloc;::aligned_alloc;::realloc;::calloc;::fopen;::freopen;::tmpfile' + bugprone-easily-swappable-parameters.SuppressParametersUsedTogether: 'true' + bugprone-argument-comment.StrictMode: '0' + hicpp-uppercase-literal-suffix.IgnoreMacros: 'true' + misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic: 'false' + modernize-replace-random-shuffle.IncludeStyle: llvm + modernize-use-bool-literals.IgnoreMacros: 'true' + bugprone-easily-swappable-parameters.NamePrefixSuffixSilenceDissimilarityTreshold: '1' + bugprone-unhandled-self-assignment.WarnOnlyIfThisHasSuspiciousField: 'true' + google-readability-namespace-comments.ShortNamespaceLines: '10' + readability-suspicious-call-argument.JaroWinklerDissimilarBelow: '75' + bugprone-suspicious-string-compare.StringCompareLikeFunctions: '' + modernize-avoid-bind.PermissiveParameterList: 'false' + readability-suspicious-call-argument.Suffix: 'true' + cert-err09-cpp.MaxSize: '-1' + modernize-use-override.FinalSpelling: final + hicpp-use-equals-default.IgnoreMacros: 'true' + modernize-use-noexcept.ReplacementString: '' + hicpp-use-override.OverrideSpelling: override + modernize-use-using.IgnoreMacros: 'true' + hicpp-use-override.FinalSpelling: final + cppcoreguidelines-explicit-virtual-functions.FinalSpelling: final + readability-suspicious-call-argument.MinimumIdentifierNameLength: '3' + bugprone-narrowing-conversions.WarnOnIntegerNarrowingConversion: 'true' + modernize-loop-convert.NamingStyle: CamelCase + cppcoreguidelines-pro-type-member-init.UseAssignment: 'false' + bugprone-suspicious-include.HeaderFileExtensions: ';h;hh;hpp;hxx' + hicpp-function-size.StatementThreshold: '800' + readability-suspicious-call-argument.SubstringDissimilarBelow: '40' + hicpp-no-malloc.Reallocations: '::realloc' + bugprone-stringview-nullptr.IncludeStyle: llvm + performance-for-range-copy.WarnOnAllAutoCopies: 'false' + google-runtime-int.UnsignedTypePrefix: uint + performance-no-automatic-move.AllowedTypes: '' + modernize-pass-by-value.IncludeStyle: llvm + bugprone-argument-comment.CommentIntegerLiterals: '0' + bugprone-argument-comment.CommentFloatLiterals: '0' + bugprone-too-small-loop-variable.MagnitudeBitsUpperLimit: '16' + abseil-string-find-startswith.AbseilStringsMatchHeader: 'absl/strings/match.h' + readability-simplify-boolean-expr.ChainedConditionalReturn: 'false' + readability-else-after-return.WarnOnConditionVariables: 'true' + modernize-use-nullptr.NullMacros: 'NULL' + readability-suspicious-call-argument.SuffixDissimilarBelow: '25' + bugprone-argument-comment.CommentCharacterLiterals: '0' + cppcoreguidelines-macro-usage.AllowedRegexp: '^DEBUG_*' + llvm-header-guard.HeaderFileExtensions: ';h;hh;hpp;hxx' + readability-suspicious-call-argument.LevenshteinSimilarAbove: '66' + cppcoreguidelines-narrowing-conversions.PedanticMode: 'false' + modernize-make-shared.IgnoreDefaultInitialization: 'true' + readability-suspicious-call-argument.JaroWinkler: 'true' + bugprone-implicit-widening-of-multiplication-result.UseCXXHeadersInCppSources: 'true' + modernize-make-shared.IncludeStyle: llvm + readability-suspicious-call-argument.Prefix: 'true' + hicpp-special-member-functions.AllowMissingMoveFunctions: 'false' + cppcoreguidelines-special-member-functions.AllowMissingMoveFunctions: 'false' + bugprone-implicit-widening-of-multiplication-result.UseCXXStaticCastsInCppSources: 'true' + bugprone-signed-char-misuse.CharTypdefsToIgnore: '' + cert-dcl51-cpp.Invert: 'false' + hicpp-special-member-functions.AllowSoleDefaultDtor: 'false' + modernize-deprecated-headers.CheckHeaderFile: 'false' + hicpp-use-emplace.EmplacyFunctions: 'vector::emplace_back;vector::emplace;deque::emplace;deque::emplace_front;deque::emplace_back;forward_list::emplace_after;forward_list::emplace_front;list::emplace;list::emplace_back;list::emplace_front;set::emplace;set::emplace_hint;map::emplace;map::emplace_hint;multiset::emplace;multiset::emplace_hint;multimap::emplace;multimap::emplace_hint;unordered_set::emplace;unordered_set::emplace_hint;unordered_map::emplace;unordered_map::emplace_hint;unordered_multiset::emplace;unordered_multiset::emplace_hint;unordered_multimap::emplace;unordered_multimap::emplace_hint;stack::emplace;queue::emplace;priority_queue::emplace' + cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors: 'false' + modernize-make-unique.IgnoreMacros: 'true' + performance-for-range-copy.AllowedTypes: '' + hicpp-function-size.BranchThreshold: '4294967295' + misc-const-correctness.AnalyzeReferences: 'true' + bugprone-unchecked-optional-access.IgnoreSmartPointerDereference: 'false' + bugprone-argument-comment.CommentBoolLiterals: '0' + readability-braces-around-statements.ShortStatementLines: '0' + bugprone-argument-comment.CommentUserDefinedLiterals: '0' + hicpp-use-emplace.ContainersWithPushBack: '::std::vector;::std::list;::std::deque' + abseil-string-find-startswith.StringLikeClasses: '::std::basic_string' + hicpp-special-member-functions.AllowMissingMoveFunctionsWhenCopyIsDeleted: 'false' + performance-inefficient-string-concatenation.StrictMode: 'false' + readability-redundant-declaration.IgnoreMacros: 'true' + readability-magic-numbers.IgnoredFloatingPointValues: '1.0;100.0;' + bugprone-easily-swappable-parameters.IgnoredParameterTypeSuffixes: 'bool;Bool;_Bool;it;It;iterator;Iterator;inputit;InputIt;forwardit;ForwardIt;bidirit;BidirIt;constiterator;const_iterator;Const_Iterator;Constiterator;ConstIterator;RandomIt;randomit;random_iterator;ReverseIt;reverse_iterator;reverse_const_iterator;ConstReverseIterator;Const_Reverse_Iterator;const_reverse_iterator;Constreverseiterator;constreverseiterator' + modernize-make-unique.MakeSmartPtrFunction: 'std::make_unique' + google-runtime-int.TypeSuffix: '' + hicpp-function-size.ParameterThreshold: '4294967295' + cert-dcl51-cpp.AllowedIdentifiers: '' + abseil-cleanup-ctad.IncludeStyle: llvm + cert-oop57-cpp.MemCpyNames: '' + modernize-make-unique.MakeSmartPtrFunctionHeader: '' + bugprone-signal-handler.AsyncSafeFunctionSet: POSIX + bugprone-easily-swappable-parameters.ModelImplicitConversions: 'true' + readability-suspicious-call-argument.SubstringSimilarAbove: '50' + cppcoreguidelines-narrowing-conversions.WarnWithinTemplateInstantiation: 'false' + portability-restrict-system-includes.Includes: '*' + performance-move-const-arg.CheckMoveToConstRef: 'true' + readability-identifier-length.MinimumVariableNameLength: '3' + modernize-use-emplace.EmplacyFunctions: 'vector::emplace_back;vector::emplace;deque::emplace;deque::emplace_front;deque::emplace_back;forward_list::emplace_after;forward_list::emplace_front;list::emplace;list::emplace_back;list::emplace_front;set::emplace;set::emplace_hint;map::emplace;map::emplace_hint;multiset::emplace;multiset::emplace_hint;multimap::emplace;multimap::emplace_hint;unordered_set::emplace;unordered_set::emplace_hint;unordered_map::emplace;unordered_map::emplace_hint;unordered_multiset::emplace;unordered_multiset::emplace_hint;unordered_multimap::emplace;unordered_multimap::emplace_hint;stack::emplace;queue::emplace;priority_queue::emplace' + zircon-temporary-objects.Names: '' + cppcoreguidelines-narrowing-conversions.WarnOnEquivalentBitWidth: 'true' + hicpp-use-emplace.TupleTypes: '::std::pair;::std::tuple' + cppcoreguidelines-non-private-member-variables-in-classes.IgnorePublicMemberVariables: 'false' + readability-implicit-bool-conversion.AllowPointerConditions: 'false' + cppcoreguidelines-special-member-functions.AllowMissingMoveFunctionsWhenCopyIsDeleted: 'false' + cert-oop57-cpp.MemCmpNames: '' + modernize-use-noexcept.UseNoexceptFalse: 'true' + readability-function-cognitive-complexity.Threshold: '25' + cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic: 'true' + readability-simplify-boolean-expr.SimplifyDeMorganRelaxed: 'false' + bugprone-narrowing-conversions.WarnOnEquivalentBitWidth: 'true' + bugprone-sizeof-expression.WarnOnSizeOfIntegerExpression: 'false' + performance-faster-string-find.StringLikeClasses: '::std::basic_string;::std::basic_string_view' + cppcoreguidelines-narrowing-conversions.WarnOnIntegerToFloatingPointNarrowingConversion: 'true' + google-readability-function-size.VariableThreshold: '4294967295' + bugprone-assert-side-effect.CheckFunctionCalls: 'false' + bugprone-string-constructor.StringNames: '::std::basic_string;::std::basic_string_view' + bugprone-assert-side-effect.AssertMacros: assert,NSAssert,NSCAssert + bugprone-exception-escape.IgnoredExceptions: '' + bugprone-signed-char-misuse.DiagnoseSignedUnsignedCharComparisons: 'true' + altera-unroll-loops.MaxLoopIterations: '100' + llvm-qualified-auto.AddConstToQualified: 'false' + hicpp-use-emplace.ContainersWithPush: '::std::stack;::std::queue;::std::priority_queue' + modernize-use-default-member-init.IgnoreMacros: 'true' + cert-str34-c.CharTypdefsToIgnore: '' + misc-use-anonymous-namespace.HeaderFileExtensions: ';h;hh;hpp;hxx' + llvm-else-after-return.WarnOnConditionVariables: 'false' + bugprone-sizeof-expression.WarnOnSizeOfCompareToConstant: 'true' + bugprone-argument-comment.IgnoreSingleArgument: '0' + modernize-raw-string-literal.DelimiterStem: lit + readability-suspicious-call-argument.Dice: 'true' + misc-throw-by-value-catch-by-reference.WarnOnLargeObjects: 'false' + readability-identifier-length.IgnoredLoopCounterNames: '^[ijk_]$' + cert-dcl37-c.Invert: 'false' + altera-single-work-item-barrier.AOCVersion: '1600' + cppcoreguidelines-avoid-do-while.IgnoreMacros: 'false' + modernize-raw-string-literal.ReplaceShorterLiterals: 'false' + fuchsia-header-anon-namespaces.HeaderFileExtensions: ';h;hh;hpp;hxx' + readability-magic-numbers.IgnoredIntegerValues: '1;2;3;4;' + modernize-use-auto.RemoveStars: 'false' + abseil-string-find-str-contains.IncludeStyle: llvm + bugprone-implicit-widening-of-multiplication-result.IncludeStyle: llvm + llvmlibc-restrict-system-libc-headers.Includes: '-*' + hicpp-use-nullptr.NullMacros: '' + readability-redundant-member-init.IgnoreBaseInCopyConstructors: 'false' + modernize-replace-disallow-copy-and-assign-macro.MacroName: DISALLOW_COPY_AND_ASSIGN + performance-unnecessary-value-param.IncludeStyle: llvm + llvm-else-after-return.WarnOnUnfixable: 'false' + cert-msc32-c.DisallowedSeedTypes: 'time_t,std::time_t' +... \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index e3afc99..d938626 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -111,3 +111,10 @@ configure_file(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) + +# Clang tidy +add_custom_target(clang-tidy-check + clang-tidy -p ${CMAKE_BINARY_DIR}/compile_commands.json -checks=* -dump-config -checks=*,-clang-analyzer-alpha.*,-llvm-include-order ${SOURCE_FILES} ${HEADER_FILES} + # clang-tidy -p ${CMAKE_BINARY_DIR}/compile_commands.json -checks=* -dump-config${SOURCE_FILES} ${HEADER_FILES} + DEPENDS ${SOURCE_FILES} ${HEADER_FILES} + ) \ No newline at end of file From 772663d2b1ee2988696b97fe854986312ab75ebb Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Thu, 1 Feb 2024 22:18:53 -0500 Subject: [PATCH 088/131] fixing clang tidy to not contain warnings from checks we don't want. Should be basic ones Need to clean up the warnings still --- .clang-tidy | 368 ------------------------------------------------- CMakeLists.txt | 4 +- 2 files changed, 2 insertions(+), 370 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 45b0537..e69de29 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,368 +0,0 @@ ---- -Checks: 'clang-diagnostic-*,clang-analyzer-*,*,-clang-analyzer-alpha.*,-llvm-include-order' -WarningsAsErrors: '' -HeaderFilterRegex: '' -AnalyzeTemporaryDtors: false -FormatStyle: none -User: dwag -CheckOptions: - hicpp-move-const-arg.CheckMoveToConstRef: 'true' - readability-suspicious-call-argument.PrefixSimilarAbove: '30' - cppcoreguidelines-no-malloc.Reallocations: '::realloc' - portability-simd-intrinsics.Std: '' - cppcoreguidelines-owning-memory.LegacyResourceConsumers: '::free;::realloc;::freopen;::fclose' - bugprone-reserved-identifier.Invert: 'false' - cert-dcl16-c.IgnoreMacros: 'true' - bugprone-narrowing-conversions.PedanticMode: 'false' - altera-struct-pack-align.MaxConfiguredAlignment: '128' - bugprone-unused-return-value.CheckedFunctions: '::std::async;::std::launder;::std::remove;::std::remove_if;::std::unique;::std::unique_ptr::release;::std::basic_string::empty;::std::vector::empty;::std::back_inserter;::std::distance;::std::find;::std::find_if;::std::inserter;::std::lower_bound;::std::make_pair;::std::map::count;::std::map::find;::std::map::lower_bound;::std::multimap::equal_range;::std::multimap::upper_bound;::std::set::count;::std::set::find;::std::setfill;::std::setprecision;::std::setw;::std::upper_bound;::std::vector::at;::bsearch;::ferror;::feof;::isalnum;::isalpha;::isblank;::iscntrl;::isdigit;::isgraph;::islower;::isprint;::ispunct;::isspace;::isupper;::iswalnum;::iswprint;::iswspace;::isxdigit;::memchr;::memcmp;::strcmp;::strcoll;::strncmp;::strpbrk;::strrchr;::strspn;::strstr;::wcscmp;::access;::bind;::connect;::difftime;::dlsym;::fnmatch;::getaddrinfo;::getopt;::htonl;::htons;::iconv_open;::inet_addr;::isascii;::isatty;::mmap;::newlocale;::openat;::pathconf;::pthread_equal;::pthread_getspecific;::pthread_mutex_trylock;::readdir;::readlink;::recvmsg;::regexec;::scandir;::semget;::setjmp;::shm_open;::shmget;::sigismember;::strcasecmp;::strsignal;::ttyname' - modernize-use-auto.MinTypeNameLength: '5' - cert-dcl51-cpp.AggressiveDependentMemberLookup: 'false' - hicpp-use-auto.MinTypeNameLength: '5' - readability-inconsistent-declaration-parameter-name.Strict: 'false' - hicpp-use-override.IgnoreDestructors: 'false' - cppcoreguidelines-macro-usage.CheckCapsOnly: 'false' - readability-suspicious-call-argument.DiceDissimilarBelow: '60' - cert-dcl37-c.AllowedIdentifiers: '' - performance-inefficient-vector-operation.VectorLikeClasses: '::std::vector' - hicpp-use-emplace.SmartPointers: '::std::shared_ptr;::std::unique_ptr;::std::auto_ptr;::std::weak_ptr' - bugprone-assert-side-effect.IgnoredFunctions: __builtin_expect - hicpp-member-init.IgnoreArrays: 'false' - openmp-exception-escape.IgnoredExceptions: '' - readability-suspicious-call-argument.Equality: 'true' - hicpp-use-override.AllowOverrideAndFinal: 'false' - misc-uniqueptr-reset-release.IncludeStyle: llvm - abseil-string-find-str-contains.StringLikeClasses: '::std::basic_string;::std::basic_string_view;::absl::string_view' - readability-const-return-type.IgnoreMacros: 'true' - hicpp-signed-bitwise.IgnorePositiveIntegerLiterals: 'false' - bugprone-easily-swappable-parameters.QualifiersMix: 'false' - cert-err09-cpp.WarnOnLargeObjects: 'false' - bugprone-suspicious-string-compare.WarnOnImplicitComparison: 'true' - bugprone-argument-comment.CommentNullPtrs: '0' - android-comparison-in-temp-failure-retry.RetryMacros: TEMP_FAILURE_RETRY - cppcoreguidelines-narrowing-conversions.WarnOnFloatingPointNarrowingConversion: 'true' - hicpp-use-equals-delete.IgnoreMacros: 'true' - cppcoreguidelines-init-variables.IncludeStyle: llvm - modernize-use-nodiscard.ReplacementString: '[[nodiscard]]' - modernize-loop-convert.MakeReverseRangeHeader: '' - readability-avoid-const-params-in-decls.IgnoreMacros: 'true' - readability-suspicious-call-argument.SuffixSimilarAbove: '30' - misc-definitions-in-headers.HeaderFileExtensions: ';h;hh;hpp;hxx' - hicpp-uppercase-literal-suffix.NewSuffixes: '' - modernize-use-emplace.ContainersWithPush: '::std::stack;::std::queue;::std::priority_queue' - cppcoreguidelines-narrowing-conversions.WarnOnIntegerNarrowingConversion: 'true' - bugprone-easily-swappable-parameters.IgnoredParameterNames: '"";iterator;Iterator;begin;Begin;end;End;first;First;last;Last;lhs;LHS;rhs;RHS' - modernize-loop-convert.UseCxx20ReverseRanges: 'true' - cppcoreguidelines-prefer-member-initializer.UseAssignment: 'false' - hicpp-function-size.VariableThreshold: '4294967295' - cert-oop57-cpp.MemSetNames: '' - hicpp-no-malloc.Deallocations: '::free' - performance-type-promotion-in-math-fn.IncludeStyle: llvm - google-readability-function-size.LineThreshold: '4294967295' - readability-function-cognitive-complexity.DescribeBasicIncrements: 'true' - bugprone-suspicious-include.ImplementationFileExtensions: 'c;cc;cpp;cxx' - hicpp-use-emplace.ContainersWithPushFront: '::std::forward_list;::std::list;::std::deque' - modernize-loop-convert.MakeReverseRangeFunction: '' - readability-inconsistent-declaration-parameter-name.IgnoreMacros: 'true' - bugprone-suspicious-missing-comma.SizeThreshold: '5' - readability-identifier-naming.IgnoreFailedSplit: 'false' - hicpp-multiway-paths-covered.WarnOnMissingElse: 'false' - readability-qualified-auto.AddConstToQualified: 'true' - bugprone-sizeof-expression.WarnOnSizeOfThis: 'true' - bugprone-string-constructor.WarnOnLargeLength: 'true' - cppcoreguidelines-explicit-virtual-functions.OverrideSpelling: override - hicpp-no-malloc.Allocations: '::malloc;::calloc' - hicpp-use-noexcept.UseNoexceptFalse: 'true' - abseil-string-find-startswith.IncludeStyle: llvm - google-global-names-in-headers.HeaderFileExtensions: ';h;hh;hpp;hxx' - readability-uppercase-literal-suffix.IgnoreMacros: 'true' - modernize-make-shared.IgnoreMacros: 'true' - modernize-use-emplace.ContainersWithPushFront: '::std::forward_list;::std::list;::std::deque' - misc-const-correctness.TransformValues: 'true' - cert-dcl59-cpp.HeaderFileExtensions: ';h;hh;hpp;hxx' - bugprone-suspicious-enum-usage.StrictMode: 'false' - performance-unnecessary-copy-initialization.AllowedTypes: '' - bugprone-suspicious-missing-comma.MaxConcatenatedTokens: '5' - modernize-use-transparent-functors.SafeMode: 'false' - readability-suspicious-call-argument.Levenshtein: 'true' - bugprone-not-null-terminated-result.WantToUseSafeFunctions: 'true' - misc-throw-by-value-catch-by-reference.CheckThrowTemporaries: 'true' - bugprone-string-constructor.LargeLengthThreshold: '8388608' - bugprone-dynamic-static-initializers.HeaderFileExtensions: ';h;hh;hpp;hxx' - readability-simplify-boolean-expr.ChainedConditionalAssignment: 'false' - cppcoreguidelines-avoid-magic-numbers.IgnoreAllFloatingPointValues: 'false' - cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField: 'false' - cert-err09-cpp.CheckThrowTemporaries: 'true' - performance-inefficient-vector-operation.EnableProto: 'false' - bugprone-exception-escape.FunctionsThatShouldNotThrow: '' - modernize-loop-convert.MaxCopySize: '16' - readability-suspicious-call-argument.PrefixDissimilarBelow: '25' - readability-function-size.LineThreshold: '4294967295' - bugprone-easily-swappable-parameters.MinimumLength: '2' - portability-simd-intrinsics.Suggest: 'false' - hicpp-deprecated-headers.CheckHeaderFile: 'false' - modernize-use-override.IgnoreDestructors: 'false' - cppcoreguidelines-pro-bounds-constant-array-index.GslHeader: '' - modernize-make-shared.MakeSmartPtrFunctionHeader: '' - modernize-make-shared.MakeSmartPtrFunction: 'std::make_shared' - misc-non-private-member-variables-in-classes.IgnorePublicMemberVariables: 'false' - bugprone-sizeof-expression.WarnOnSizeOfConstant: 'true' - readability-redundant-string-init.StringNames: '::std::basic_string_view;::std::basic_string' - modernize-make-unique.IgnoreDefaultInitialization: 'true' - modernize-use-emplace.ContainersWithPushBack: '::std::vector;::std::list;::std::deque' - readability-magic-numbers.IgnoreBitFieldsWidths: 'true' - modernize-make-unique.IncludeStyle: llvm - modernize-use-override.OverrideSpelling: override - google-readability-function-size.NestingThreshold: '4294967295' - google-build-namespaces.HeaderFileExtensions: ';h;hh;hpp;hxx' - readability-suspicious-call-argument.LevenshteinDissimilarBelow: '50' - bugprone-argument-comment.CommentStringLiterals: '0' - concurrency-mt-unsafe.FunctionSet: any - readability-identifier-length.IgnoredExceptionVariableNames: '^[e]$' - google-readability-braces-around-statements.ShortStatementLines: '1' - bugprone-reserved-identifier.AllowedIdentifiers: '' - cppcoreguidelines-pro-type-member-init.IgnoreArrays: 'false' - readability-else-after-return.WarnOnUnfixable: 'true' - cppcoreguidelines-avoid-magic-numbers.IgnoredFloatingPointValues: '1.0;100.0;' - modernize-use-emplace.IgnoreImplicitConstructors: 'false' - cppcoreguidelines-macro-usage.IgnoreCommandLineMacros: 'true' - readability-suspicious-call-argument.Substring: 'true' - modernize-use-equals-delete.IgnoreMacros: 'true' - objc-forbidden-subclassing.ForbiddenSuperClassNames: 'ABNewPersonViewController;ABPeoplePickerNavigationController;ABPersonViewController;ABUnknownPersonViewController;NSHashTable;NSMapTable;NSPointerArray;NSPointerFunctions;NSTimer;UIActionSheet;UIAlertView;UIImagePickerController;UITextInputMode;UIWebView' - readability-identifier-length.IgnoredVariableNames: '' - readability-magic-numbers.IgnoreAllFloatingPointValues: 'false' - cppcoreguidelines-pro-bounds-constant-array-index.IncludeStyle: llvm - hicpp-use-auto.RemoveStars: 'false' - readability-suspicious-call-argument.Abbreviations: 'arr=array;cnt=count;idx=index;src=source;stmt=statement;cpy=copy;dest=destination;dist=distancedst=distance;ptr=pointer;wdth=width;str=string;ln=line;srv=server;attr=attribute;ref=reference;buf=buffer;col=column;nr=number;vec=vector;len=length;elem=element;val=value;i=index;var=variable;hght=height;cl=client;num=number;pos=position;lst=list;addr=address' - bugprone-misplaced-widening-cast.CheckImplicitCasts: 'false' - readability-uppercase-literal-suffix.NewSuffixes: '' - modernize-loop-convert.MinConfidence: reasonable - performance-unnecessary-value-param.AllowedTypes: '' - readability-uniqueptr-delete-release.PreferResetCall: 'false' - readability-identifier-length.MinimumExceptionNameLength: '2' - misc-definitions-in-headers.UseHeaderFileExtension: 'true' - google-readability-namespace-comments.SpacesBeforeComments: '2' - cppcoreguidelines-avoid-magic-numbers.IgnoreBitFieldsWidths: 'true' - cert-err61-cpp.CheckThrowTemporaries: 'true' - cppcoreguidelines-avoid-magic-numbers.IgnoredIntegerValues: '1;2;3;4;' - cppcoreguidelines-no-malloc.Allocations: '::malloc;::calloc' - misc-throw-by-value-catch-by-reference.MaxSize: '-1' - cppcoreguidelines-avoid-magic-numbers.IgnorePowersOf2IntegerValues: 'false' - bugprone-narrowing-conversions.IgnoreConversionFromTypes: '' - readability-function-size.BranchThreshold: '4294967295' - bugprone-suspicious-missing-comma.RatioThreshold: '0.200000' - hicpp-function-size.LineThreshold: '4294967295' - readability-implicit-bool-conversion.AllowIntegerConditions: 'false' - readability-identifier-length.IgnoredParameterNames: '^[n]$' - readability-function-size.StatementThreshold: '800' - hicpp-use-noexcept.ReplacementString: '' - readability-identifier-naming.IgnoreMainLikeFunctions: 'false' - cppcoreguidelines-init-variables.MathHeader: '' - google-runtime-int.SignedTypePrefix: int - google-readability-function-size.StatementThreshold: '800' - cert-msc51-cpp.DisallowedSeedTypes: 'time_t,std::time_t' - hicpp-use-emplace.TupleMakeFunctions: '::std::make_pair;::std::make_tuple' - bugprone-reserved-identifier.AggressiveDependentMemberLookup: 'false' - readability-suspicious-call-argument.DiceSimilarAbove: '70' - modernize-use-equals-default.IgnoreMacros: 'true' - readability-suspicious-call-argument.Abbreviation: 'true' - cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor: 'false' - cert-dcl37-c.AggressiveDependentMemberLookup: 'false' - readability-identifier-length.MinimumLoopCounterNameLength: '2' - abseil-string-find-str-contains.AbseilStringsMatchHeader: 'absl/strings/match.h' - bugprone-dangling-handle.HandleClasses: 'std::basic_string_view;std::experimental::basic_string_view' - cert-msc54-cpp.AsyncSafeFunctionSet: POSIX - modernize-use-emplace.SmartPointers: '::std::shared_ptr;::std::unique_ptr;::std::auto_ptr;::std::weak_ptr' - readability-magic-numbers.IgnorePowersOf2IntegerValues: 'false' - misc-const-correctness.TransformPointersAsValues: 'false' - readability-suspicious-call-argument.JaroWinklerSimilarAbove: '85' - misc-unused-parameters.StrictMode: 'false' - cppcoreguidelines-no-malloc.Deallocations: '::free' - readability-simplify-subscript-expr.Types: '::std::basic_string;::std::basic_string_view;::std::vector;::std::array' - performance-unnecessary-copy-initialization.ExcludedContainerTypes: '' - modernize-replace-auto-ptr.IncludeStyle: llvm - performance-move-const-arg.CheckTriviallyCopyableMove: 'true' - misc-const-correctness.TransformReferences: 'true' - hicpp-move-const-arg.CheckTriviallyCopyableMove: 'true' - readability-function-size.VariableThreshold: '4294967295' - readability-static-accessed-through-instance.NameSpecifierNestingThreshold: '3' - cert-dcl16-c.NewSuffixes: 'L;LL;LU;LLU' - misc-const-correctness.AnalyzeValues: 'true' - readability-identifier-naming.GetConfigPerFile: 'true' - bugprone-narrowing-conversions.WarnOnFloatingPointNarrowingConversion: 'true' - cert-sig30-c.AsyncSafeFunctionSet: POSIX - readability-simplify-boolean-expr.SimplifyDeMorgan: 'true' - cert-err61-cpp.MaxSize: '-1' - hicpp-member-init.UseAssignment: 'false' - modernize-use-default-member-init.UseAssignment: 'false' - readability-function-size.NestingThreshold: '4294967295' - google-readability-function-size.BranchThreshold: '4294967295' - bugprone-sizeof-expression.WarnOnSizeOfPointerToAggregate: 'true' - llvm-namespace-comment.ShortNamespaceLines: '1' - llvm-namespace-comment.SpacesBeforeComments: '1' - modernize-use-override.AllowOverrideAndFinal: 'false' - cppcoreguidelines-narrowing-conversions.IgnoreConversionFromTypes: '' - readability-function-size.ParameterThreshold: '4294967295' - hicpp-function-size.NestingThreshold: '4294967295' - modernize-pass-by-value.ValuesOnly: 'false' - readability-function-cognitive-complexity.IgnoreMacros: 'false' - modernize-loop-convert.IncludeStyle: llvm - cert-str34-c.DiagnoseSignedUnsignedCharComparisons: 'false' - bugprone-narrowing-conversions.WarnWithinTemplateInstantiation: 'false' - cert-err33-c.CheckedFunctions: '::aligned_alloc;::asctime_s;::at_quick_exit;::atexit;::bsearch;::bsearch_s;::btowc;::c16rtomb;::c32rtomb;::calloc;::clock;::cnd_broadcast;::cnd_init;::cnd_signal;::cnd_timedwait;::cnd_wait;::ctime_s;::fclose;::fflush;::fgetc;::fgetpos;::fgets;::fgetwc;::fopen;::fopen_s;::fprintf;::fprintf_s;::fputc;::fputs;::fputwc;::fputws;::fread;::freopen;::freopen_s;::fscanf;::fscanf_s;::fseek;::fsetpos;::ftell;::fwprintf;::fwprintf_s;::fwrite;::fwscanf;::fwscanf_s;::getc;::getchar;::getenv;::getenv_s;::gets_s;::getwc;::getwchar;::gmtime;::gmtime_s;::localtime;::localtime_s;::malloc;::mbrtoc16;::mbrtoc32;::mbsrtowcs;::mbsrtowcs_s;::mbstowcs;::mbstowcs_s;::memchr;::mktime;::mtx_init;::mtx_lock;::mtx_timedlock;::mtx_trylock;::mtx_unlock;::printf_s;::putc;::putwc;::raise;::realloc;::remove;::rename;::scanf;::scanf_s;::setlocale;::setvbuf;::signal;::snprintf;::snprintf_s;::sprintf;::sprintf_s;::sscanf;::sscanf_s;::strchr;::strerror_s;::strftime;::strpbrk;::strrchr;::strstr;::strtod;::strtof;::strtoimax;::strtok;::strtok_s;::strtol;::strtold;::strtoll;::strtoul;::strtoull;::strtoumax;::strxfrm;::swprintf;::swprintf_s;::swscanf;::swscanf_s;::thrd_create;::thrd_detach;::thrd_join;::thrd_sleep;::time;::timespec_get;::tmpfile;::tmpfile_s;::tmpnam;::tmpnam_s;::tss_create;::tss_get;::tss_set;::ungetc;::ungetwc;::vfprintf;::vfprintf_s;::vfscanf;::vfscanf_s;::vfwprintf;::vfwprintf_s;::vfwscanf;::vfwscanf_s;::vprintf_s;::vscanf;::vscanf_s;::vsnprintf;::vsnprintf_s;::vsprintf;::vsprintf_s;::vsscanf;::vsscanf_s;::vswprintf;::vswprintf_s;::vswscanf;::vswscanf_s;::vwprintf_s;::vwscanf;::vwscanf_s;::wcrtomb;::wcschr;::wcsftime;::wcspbrk;::wcsrchr;::wcsrtombs;::wcsrtombs_s;::wcsstr;::wcstod;::wcstof;::wcstoimax;::wcstok;::wcstok_s;::wcstol;::wcstold;::wcstoll;::wcstombs;::wcstombs_s;::wcstoul;::wcstoull;::wcstoumax;::wcsxfrm;::wctob;::wctrans;::wctype;::wmemchr;::wprintf_s;::wscanf;::wscanf_s;' - bugprone-suspicious-string-compare.WarnOnLogicalNotComparison: 'false' - hicpp-braces-around-statements.ShortStatementLines: '0' - cppcoreguidelines-explicit-virtual-functions.AllowOverrideAndFinal: 'false' - google-readability-function-size.ParameterThreshold: '4294967295' - readability-redundant-smartptr-get.IgnoreMacros: 'true' - readability-identifier-naming.AggressiveDependentMemberLookup: 'false' - cert-err61-cpp.WarnOnLargeObjects: 'false' - misc-const-correctness.WarnPointersAsValues: 'false' - readability-identifier-length.MinimumParameterNameLength: '3' - modernize-use-emplace.TupleTypes: '::std::pair;::std::tuple' - hicpp-use-emplace.IgnoreImplicitConstructors: 'false' - modernize-use-emplace.TupleMakeFunctions: '::std::make_pair;::std::make_tuple' - bugprone-narrowing-conversions.WarnOnIntegerToFloatingPointNarrowingConversion: 'true' - cppcoreguidelines-owning-memory.LegacyResourceProducers: '::malloc;::aligned_alloc;::realloc;::calloc;::fopen;::freopen;::tmpfile' - bugprone-easily-swappable-parameters.SuppressParametersUsedTogether: 'true' - bugprone-argument-comment.StrictMode: '0' - hicpp-uppercase-literal-suffix.IgnoreMacros: 'true' - misc-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic: 'false' - modernize-replace-random-shuffle.IncludeStyle: llvm - modernize-use-bool-literals.IgnoreMacros: 'true' - bugprone-easily-swappable-parameters.NamePrefixSuffixSilenceDissimilarityTreshold: '1' - bugprone-unhandled-self-assignment.WarnOnlyIfThisHasSuspiciousField: 'true' - google-readability-namespace-comments.ShortNamespaceLines: '10' - readability-suspicious-call-argument.JaroWinklerDissimilarBelow: '75' - bugprone-suspicious-string-compare.StringCompareLikeFunctions: '' - modernize-avoid-bind.PermissiveParameterList: 'false' - readability-suspicious-call-argument.Suffix: 'true' - cert-err09-cpp.MaxSize: '-1' - modernize-use-override.FinalSpelling: final - hicpp-use-equals-default.IgnoreMacros: 'true' - modernize-use-noexcept.ReplacementString: '' - hicpp-use-override.OverrideSpelling: override - modernize-use-using.IgnoreMacros: 'true' - hicpp-use-override.FinalSpelling: final - cppcoreguidelines-explicit-virtual-functions.FinalSpelling: final - readability-suspicious-call-argument.MinimumIdentifierNameLength: '3' - bugprone-narrowing-conversions.WarnOnIntegerNarrowingConversion: 'true' - modernize-loop-convert.NamingStyle: CamelCase - cppcoreguidelines-pro-type-member-init.UseAssignment: 'false' - bugprone-suspicious-include.HeaderFileExtensions: ';h;hh;hpp;hxx' - hicpp-function-size.StatementThreshold: '800' - readability-suspicious-call-argument.SubstringDissimilarBelow: '40' - hicpp-no-malloc.Reallocations: '::realloc' - bugprone-stringview-nullptr.IncludeStyle: llvm - performance-for-range-copy.WarnOnAllAutoCopies: 'false' - google-runtime-int.UnsignedTypePrefix: uint - performance-no-automatic-move.AllowedTypes: '' - modernize-pass-by-value.IncludeStyle: llvm - bugprone-argument-comment.CommentIntegerLiterals: '0' - bugprone-argument-comment.CommentFloatLiterals: '0' - bugprone-too-small-loop-variable.MagnitudeBitsUpperLimit: '16' - abseil-string-find-startswith.AbseilStringsMatchHeader: 'absl/strings/match.h' - readability-simplify-boolean-expr.ChainedConditionalReturn: 'false' - readability-else-after-return.WarnOnConditionVariables: 'true' - modernize-use-nullptr.NullMacros: 'NULL' - readability-suspicious-call-argument.SuffixDissimilarBelow: '25' - bugprone-argument-comment.CommentCharacterLiterals: '0' - cppcoreguidelines-macro-usage.AllowedRegexp: '^DEBUG_*' - llvm-header-guard.HeaderFileExtensions: ';h;hh;hpp;hxx' - readability-suspicious-call-argument.LevenshteinSimilarAbove: '66' - cppcoreguidelines-narrowing-conversions.PedanticMode: 'false' - modernize-make-shared.IgnoreDefaultInitialization: 'true' - readability-suspicious-call-argument.JaroWinkler: 'true' - bugprone-implicit-widening-of-multiplication-result.UseCXXHeadersInCppSources: 'true' - modernize-make-shared.IncludeStyle: llvm - readability-suspicious-call-argument.Prefix: 'true' - hicpp-special-member-functions.AllowMissingMoveFunctions: 'false' - cppcoreguidelines-special-member-functions.AllowMissingMoveFunctions: 'false' - bugprone-implicit-widening-of-multiplication-result.UseCXXStaticCastsInCppSources: 'true' - bugprone-signed-char-misuse.CharTypdefsToIgnore: '' - cert-dcl51-cpp.Invert: 'false' - hicpp-special-member-functions.AllowSoleDefaultDtor: 'false' - modernize-deprecated-headers.CheckHeaderFile: 'false' - hicpp-use-emplace.EmplacyFunctions: 'vector::emplace_back;vector::emplace;deque::emplace;deque::emplace_front;deque::emplace_back;forward_list::emplace_after;forward_list::emplace_front;list::emplace;list::emplace_back;list::emplace_front;set::emplace;set::emplace_hint;map::emplace;map::emplace_hint;multiset::emplace;multiset::emplace_hint;multimap::emplace;multimap::emplace_hint;unordered_set::emplace;unordered_set::emplace_hint;unordered_map::emplace;unordered_map::emplace_hint;unordered_multiset::emplace;unordered_multiset::emplace_hint;unordered_multimap::emplace;unordered_multimap::emplace_hint;stack::emplace;queue::emplace;priority_queue::emplace' - cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors: 'false' - modernize-make-unique.IgnoreMacros: 'true' - performance-for-range-copy.AllowedTypes: '' - hicpp-function-size.BranchThreshold: '4294967295' - misc-const-correctness.AnalyzeReferences: 'true' - bugprone-unchecked-optional-access.IgnoreSmartPointerDereference: 'false' - bugprone-argument-comment.CommentBoolLiterals: '0' - readability-braces-around-statements.ShortStatementLines: '0' - bugprone-argument-comment.CommentUserDefinedLiterals: '0' - hicpp-use-emplace.ContainersWithPushBack: '::std::vector;::std::list;::std::deque' - abseil-string-find-startswith.StringLikeClasses: '::std::basic_string' - hicpp-special-member-functions.AllowMissingMoveFunctionsWhenCopyIsDeleted: 'false' - performance-inefficient-string-concatenation.StrictMode: 'false' - readability-redundant-declaration.IgnoreMacros: 'true' - readability-magic-numbers.IgnoredFloatingPointValues: '1.0;100.0;' - bugprone-easily-swappable-parameters.IgnoredParameterTypeSuffixes: 'bool;Bool;_Bool;it;It;iterator;Iterator;inputit;InputIt;forwardit;ForwardIt;bidirit;BidirIt;constiterator;const_iterator;Const_Iterator;Constiterator;ConstIterator;RandomIt;randomit;random_iterator;ReverseIt;reverse_iterator;reverse_const_iterator;ConstReverseIterator;Const_Reverse_Iterator;const_reverse_iterator;Constreverseiterator;constreverseiterator' - modernize-make-unique.MakeSmartPtrFunction: 'std::make_unique' - google-runtime-int.TypeSuffix: '' - hicpp-function-size.ParameterThreshold: '4294967295' - cert-dcl51-cpp.AllowedIdentifiers: '' - abseil-cleanup-ctad.IncludeStyle: llvm - cert-oop57-cpp.MemCpyNames: '' - modernize-make-unique.MakeSmartPtrFunctionHeader: '' - bugprone-signal-handler.AsyncSafeFunctionSet: POSIX - bugprone-easily-swappable-parameters.ModelImplicitConversions: 'true' - readability-suspicious-call-argument.SubstringSimilarAbove: '50' - cppcoreguidelines-narrowing-conversions.WarnWithinTemplateInstantiation: 'false' - portability-restrict-system-includes.Includes: '*' - performance-move-const-arg.CheckMoveToConstRef: 'true' - readability-identifier-length.MinimumVariableNameLength: '3' - modernize-use-emplace.EmplacyFunctions: 'vector::emplace_back;vector::emplace;deque::emplace;deque::emplace_front;deque::emplace_back;forward_list::emplace_after;forward_list::emplace_front;list::emplace;list::emplace_back;list::emplace_front;set::emplace;set::emplace_hint;map::emplace;map::emplace_hint;multiset::emplace;multiset::emplace_hint;multimap::emplace;multimap::emplace_hint;unordered_set::emplace;unordered_set::emplace_hint;unordered_map::emplace;unordered_map::emplace_hint;unordered_multiset::emplace;unordered_multiset::emplace_hint;unordered_multimap::emplace;unordered_multimap::emplace_hint;stack::emplace;queue::emplace;priority_queue::emplace' - zircon-temporary-objects.Names: '' - cppcoreguidelines-narrowing-conversions.WarnOnEquivalentBitWidth: 'true' - hicpp-use-emplace.TupleTypes: '::std::pair;::std::tuple' - cppcoreguidelines-non-private-member-variables-in-classes.IgnorePublicMemberVariables: 'false' - readability-implicit-bool-conversion.AllowPointerConditions: 'false' - cppcoreguidelines-special-member-functions.AllowMissingMoveFunctionsWhenCopyIsDeleted: 'false' - cert-oop57-cpp.MemCmpNames: '' - modernize-use-noexcept.UseNoexceptFalse: 'true' - readability-function-cognitive-complexity.Threshold: '25' - cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic: 'true' - readability-simplify-boolean-expr.SimplifyDeMorganRelaxed: 'false' - bugprone-narrowing-conversions.WarnOnEquivalentBitWidth: 'true' - bugprone-sizeof-expression.WarnOnSizeOfIntegerExpression: 'false' - performance-faster-string-find.StringLikeClasses: '::std::basic_string;::std::basic_string_view' - cppcoreguidelines-narrowing-conversions.WarnOnIntegerToFloatingPointNarrowingConversion: 'true' - google-readability-function-size.VariableThreshold: '4294967295' - bugprone-assert-side-effect.CheckFunctionCalls: 'false' - bugprone-string-constructor.StringNames: '::std::basic_string;::std::basic_string_view' - bugprone-assert-side-effect.AssertMacros: assert,NSAssert,NSCAssert - bugprone-exception-escape.IgnoredExceptions: '' - bugprone-signed-char-misuse.DiagnoseSignedUnsignedCharComparisons: 'true' - altera-unroll-loops.MaxLoopIterations: '100' - llvm-qualified-auto.AddConstToQualified: 'false' - hicpp-use-emplace.ContainersWithPush: '::std::stack;::std::queue;::std::priority_queue' - modernize-use-default-member-init.IgnoreMacros: 'true' - cert-str34-c.CharTypdefsToIgnore: '' - misc-use-anonymous-namespace.HeaderFileExtensions: ';h;hh;hpp;hxx' - llvm-else-after-return.WarnOnConditionVariables: 'false' - bugprone-sizeof-expression.WarnOnSizeOfCompareToConstant: 'true' - bugprone-argument-comment.IgnoreSingleArgument: '0' - modernize-raw-string-literal.DelimiterStem: lit - readability-suspicious-call-argument.Dice: 'true' - misc-throw-by-value-catch-by-reference.WarnOnLargeObjects: 'false' - readability-identifier-length.IgnoredLoopCounterNames: '^[ijk_]$' - cert-dcl37-c.Invert: 'false' - altera-single-work-item-barrier.AOCVersion: '1600' - cppcoreguidelines-avoid-do-while.IgnoreMacros: 'false' - modernize-raw-string-literal.ReplaceShorterLiterals: 'false' - fuchsia-header-anon-namespaces.HeaderFileExtensions: ';h;hh;hpp;hxx' - readability-magic-numbers.IgnoredIntegerValues: '1;2;3;4;' - modernize-use-auto.RemoveStars: 'false' - abseil-string-find-str-contains.IncludeStyle: llvm - bugprone-implicit-widening-of-multiplication-result.IncludeStyle: llvm - llvmlibc-restrict-system-libc-headers.Includes: '-*' - hicpp-use-nullptr.NullMacros: '' - readability-redundant-member-init.IgnoreBaseInCopyConstructors: 'false' - modernize-replace-disallow-copy-and-assign-macro.MacroName: DISALLOW_COPY_AND_ASSIGN - performance-unnecessary-value-param.IncludeStyle: llvm - llvm-else-after-return.WarnOnUnfixable: 'false' - cert-msc32-c.DisallowedSeedTypes: 'time_t,std::time_t' -... \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index d938626..c973386 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,7 +114,7 @@ install( # Clang tidy add_custom_target(clang-tidy-check - clang-tidy -p ${CMAKE_BINARY_DIR}/compile_commands.json -checks=* -dump-config -checks=*,-clang-analyzer-alpha.*,-llvm-include-order ${SOURCE_FILES} ${HEADER_FILES} - # clang-tidy -p ${CMAKE_BINARY_DIR}/compile_commands.json -checks=* -dump-config${SOURCE_FILES} ${HEADER_FILES} + # clang-tidy -checks=-*,clang-analyzer-*,clang-analyzer-cplusplus*,cert-*,cppcoreguidelines-*,portability-*,readability-*,clang-diagnostic-* -dump-config -p ${CMAKE_BINARY_DIR}/compile_commands.json ${SOURCE_FILES} ${HEADER_FILES} > ../.clang-tidy + clang-tidy -p ${CMAKE_BINARY_DIR}/compile_commands.json ${SOURCE_FILES} ${HEADER_FILES} DEPENDS ${SOURCE_FILES} ${HEADER_FILES} ) \ No newline at end of file From 806832c3a27e044c6893199ada9c80a6a52bb212 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Thu, 1 Feb 2024 22:24:06 -0500 Subject: [PATCH 089/131] Updated the clang format file one more time and added commands to dump the clang-tidy file with current checks and run the fixes --- .clang-tidy | 160 +++++++++++++++++++++++++++++++++++++++++++++++++ CMakeLists.txt | 13 +++- 2 files changed, 171 insertions(+), 2 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index e69de29..cc7ef80 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -0,0 +1,160 @@ +--- +Checks: 'clang-diagnostic-*,clang-analyzer-*,-*,clang-analyzer-*,clang-analyzer-cplusplus*,cert-*,cppcoreguidelines-*,portability-*,readability-*,clang-diagnostic-*' +WarningsAsErrors: '' +HeaderFilterRegex: '' +AnalyzeTemporaryDtors: false +FormatStyle: none +User: dwag +CheckOptions: + readability-simplify-subscript-expr.Types: '::std::basic_string;::std::basic_string_view;::std::vector;::std::array' + readability-suspicious-call-argument.PrefixSimilarAbove: '30' + modernize-replace-auto-ptr.IncludeStyle: llvm + cppcoreguidelines-no-malloc.Reallocations: '::realloc' + cppcoreguidelines-owning-memory.LegacyResourceConsumers: '::free;::realloc;::freopen;::fclose' + readability-static-accessed-through-instance.NameSpecifierNestingThreshold: '3' + readability-simplify-boolean-expr.SimplifyDeMorgan: 'true' + readability-function-size.VariableThreshold: '4294967295' + cert-dcl16-c.NewSuffixes: 'L;LL;LU;LLU' + cert-dcl51-cpp.AggressiveDependentMemberLookup: 'false' + readability-identifier-naming.GetConfigPerFile: 'true' + cert-err61-cpp.MaxSize: '-1' + cert-sig30-c.AsyncSafeFunctionSet: POSIX + readability-inconsistent-declaration-parameter-name.Strict: 'false' + cppcoreguidelines-macro-usage.CheckCapsOnly: 'false' + readability-suspicious-call-argument.DiceDissimilarBelow: '60' + cert-dcl37-c.AllowedIdentifiers: '' + readability-function-size.NestingThreshold: '4294967295' + cppcoreguidelines-narrowing-conversions.IgnoreConversionFromTypes: '' + readability-function-size.ParameterThreshold: '4294967295' + readability-suspicious-call-argument.Equality: 'true' + readability-function-cognitive-complexity.IgnoreMacros: 'false' + cert-str34-c.DiagnoseSignedUnsignedCharComparisons: 'false' + cert-err33-c.CheckedFunctions: '::aligned_alloc;::asctime_s;::at_quick_exit;::atexit;::bsearch;::bsearch_s;::btowc;::c16rtomb;::c32rtomb;::calloc;::clock;::cnd_broadcast;::cnd_init;::cnd_signal;::cnd_timedwait;::cnd_wait;::ctime_s;::fclose;::fflush;::fgetc;::fgetpos;::fgets;::fgetwc;::fopen;::fopen_s;::fprintf;::fprintf_s;::fputc;::fputs;::fputwc;::fputws;::fread;::freopen;::freopen_s;::fscanf;::fscanf_s;::fseek;::fsetpos;::ftell;::fwprintf;::fwprintf_s;::fwrite;::fwscanf;::fwscanf_s;::getc;::getchar;::getenv;::getenv_s;::gets_s;::getwc;::getwchar;::gmtime;::gmtime_s;::localtime;::localtime_s;::malloc;::mbrtoc16;::mbrtoc32;::mbsrtowcs;::mbsrtowcs_s;::mbstowcs;::mbstowcs_s;::memchr;::mktime;::mtx_init;::mtx_lock;::mtx_timedlock;::mtx_trylock;::mtx_unlock;::printf_s;::putc;::putwc;::raise;::realloc;::remove;::rename;::scanf;::scanf_s;::setlocale;::setvbuf;::signal;::snprintf;::snprintf_s;::sprintf;::sprintf_s;::sscanf;::sscanf_s;::strchr;::strerror_s;::strftime;::strpbrk;::strrchr;::strstr;::strtod;::strtof;::strtoimax;::strtok;::strtok_s;::strtol;::strtold;::strtoll;::strtoul;::strtoull;::strtoumax;::strxfrm;::swprintf;::swprintf_s;::swscanf;::swscanf_s;::thrd_create;::thrd_detach;::thrd_join;::thrd_sleep;::time;::timespec_get;::tmpfile;::tmpfile_s;::tmpnam;::tmpnam_s;::tss_create;::tss_get;::tss_set;::ungetc;::ungetwc;::vfprintf;::vfprintf_s;::vfscanf;::vfscanf_s;::vfwprintf;::vfwprintf_s;::vfwscanf;::vfwscanf_s;::vprintf_s;::vscanf;::vscanf_s;::vsnprintf;::vsnprintf_s;::vsprintf;::vsprintf_s;::vsscanf;::vsscanf_s;::vswprintf;::vswprintf_s;::vswscanf;::vswscanf_s;::vwprintf_s;::vwscanf;::vwscanf_s;::wcrtomb;::wcschr;::wcsftime;::wcspbrk;::wcsrchr;::wcsrtombs;::wcsrtombs_s;::wcsstr;::wcstod;::wcstof;::wcstoimax;::wcstok;::wcstok_s;::wcstol;::wcstold;::wcstoll;::wcstombs;::wcstombs_s;::wcstoul;::wcstoull;::wcstoumax;::wcsxfrm;::wctob;::wctrans;::wctype;::wmemchr;::wprintf_s;::wscanf;::wscanf_s;' + cppcoreguidelines-explicit-virtual-functions.AllowOverrideAndFinal: 'false' + readability-redundant-smartptr-get.IgnoreMacros: 'true' + readability-identifier-naming.AggressiveDependentMemberLookup: 'false' + readability-const-return-type.IgnoreMacros: 'true' + cert-err61-cpp.WarnOnLargeObjects: 'false' + cert-err09-cpp.WarnOnLargeObjects: 'false' + readability-identifier-length.MinimumParameterNameLength: '3' + cppcoreguidelines-owning-memory.LegacyResourceProducers: '::malloc;::aligned_alloc;::realloc;::calloc;::fopen;::freopen;::tmpfile' + cppcoreguidelines-narrowing-conversions.WarnOnFloatingPointNarrowingConversion: 'true' + cppcoreguidelines-init-variables.IncludeStyle: llvm + readability-avoid-const-params-in-decls.IgnoreMacros: 'true' + google-readability-namespace-comments.ShortNamespaceLines: '10' + readability-suspicious-call-argument.JaroWinklerDissimilarBelow: '75' + readability-suspicious-call-argument.SuffixSimilarAbove: '30' + readability-suspicious-call-argument.Suffix: 'true' + cert-err09-cpp.MaxSize: '-1' + cppcoreguidelines-narrowing-conversions.WarnOnIntegerNarrowingConversion: 'true' + cppcoreguidelines-prefer-member-initializer.UseAssignment: 'false' + cert-oop57-cpp.MemSetNames: '' + cppcoreguidelines-explicit-virtual-functions.FinalSpelling: final + readability-function-cognitive-complexity.DescribeBasicIncrements: 'true' + readability-suspicious-call-argument.MinimumIdentifierNameLength: '3' + modernize-loop-convert.NamingStyle: CamelCase + cppcoreguidelines-pro-type-member-init.UseAssignment: 'false' + readability-inconsistent-declaration-parameter-name.IgnoreMacros: 'true' + readability-suspicious-call-argument.SubstringDissimilarBelow: '40' + readability-identifier-naming.IgnoreFailedSplit: 'false' + modernize-pass-by-value.IncludeStyle: llvm + readability-qualified-auto.AddConstToQualified: 'true' + cppcoreguidelines-explicit-virtual-functions.OverrideSpelling: override + readability-simplify-boolean-expr.ChainedConditionalReturn: 'false' + readability-else-after-return.WarnOnConditionVariables: 'true' + readability-uppercase-literal-suffix.IgnoreMacros: 'true' + modernize-use-nullptr.NullMacros: 'NULL' + cert-dcl59-cpp.HeaderFileExtensions: ';h;hh;hpp;hxx' + readability-suspicious-call-argument.SuffixDissimilarBelow: '25' + cppcoreguidelines-macro-usage.AllowedRegexp: '^DEBUG_*' + readability-suspicious-call-argument.LevenshteinSimilarAbove: '66' + cppcoreguidelines-narrowing-conversions.PedanticMode: 'false' + readability-suspicious-call-argument.Levenshtein: 'true' + readability-suspicious-call-argument.JaroWinkler: 'true' + readability-suspicious-call-argument.Prefix: 'true' + readability-simplify-boolean-expr.ChainedConditionalAssignment: 'false' + cppcoreguidelines-avoid-magic-numbers.IgnoreAllFloatingPointValues: 'false' + cppcoreguidelines-special-member-functions.AllowMissingMoveFunctions: 'false' + cert-oop54-cpp.WarnOnlyIfThisHasSuspiciousField: 'false' + cert-err09-cpp.CheckThrowTemporaries: 'true' + cert-dcl51-cpp.Invert: 'false' + readability-function-size.LineThreshold: '4294967295' + modernize-loop-convert.MaxCopySize: '16' + readability-suspicious-call-argument.PrefixDissimilarBelow: '25' + portability-simd-intrinsics.Suggest: 'false' + cppcoreguidelines-pro-bounds-constant-array-index.GslHeader: '' + cppcoreguidelines-explicit-virtual-functions.IgnoreDestructors: 'false' + readability-redundant-string-init.StringNames: '::std::basic_string_view;::std::basic_string' + readability-magic-numbers.IgnoreBitFieldsWidths: 'true' + readability-braces-around-statements.ShortStatementLines: '0' + readability-suspicious-call-argument.LevenshteinDissimilarBelow: '50' + readability-magic-numbers.IgnoredFloatingPointValues: '1.0;100.0;' + readability-redundant-declaration.IgnoreMacros: 'true' + readability-implicit-bool-conversion.AllowPointerConditions: 'false' + readability-identifier-length.IgnoredExceptionVariableNames: '^[e]$' + google-readability-braces-around-statements.ShortStatementLines: '1' + portability-restrict-system-includes.Includes: '*' + cppcoreguidelines-pro-type-member-init.IgnoreArrays: 'false' + readability-else-after-return.WarnOnUnfixable: 'true' + cert-dcl51-cpp.AllowedIdentifiers: '' + cppcoreguidelines-avoid-magic-numbers.IgnoredFloatingPointValues: '1.0;100.0;' + cert-oop57-cpp.MemCpyNames: '' + readability-suspicious-call-argument.SubstringSimilarAbove: '50' + cppcoreguidelines-macro-usage.IgnoreCommandLineMacros: 'true' + readability-suspicious-call-argument.Substring: 'true' + cppcoreguidelines-pro-bounds-constant-array-index.IncludeStyle: llvm + cppcoreguidelines-narrowing-conversions.WarnWithinTemplateInstantiation: 'false' + readability-identifier-length.IgnoredVariableNames: '' + readability-magic-numbers.IgnoreAllFloatingPointValues: 'false' + readability-identifier-length.MinimumVariableNameLength: '3' + readability-suspicious-call-argument.Abbreviations: 'arr=array;cnt=count;idx=index;src=source;stmt=statement;cpy=copy;dest=destination;dist=distancedst=distance;ptr=pointer;wdth=width;str=string;ln=line;srv=server;attr=attribute;ref=reference;buf=buffer;col=column;nr=number;vec=vector;len=length;elem=element;val=value;i=index;var=variable;hght=height;cl=client;num=number;pos=position;lst=list;addr=address' + cppcoreguidelines-narrowing-conversions.WarnOnEquivalentBitWidth: 'true' + cppcoreguidelines-avoid-magic-numbers.IgnoredIntegerValues: '1;2;3;4;' + cppcoreguidelines-non-private-member-variables-in-classes.IgnorePublicMemberVariables: 'false' + modernize-loop-convert.MinConfidence: reasonable + readability-uniqueptr-delete-release.PreferResetCall: 'false' + cppcoreguidelines-avoid-magic-numbers.IgnorePowersOf2IntegerValues: 'false' + readability-identifier-length.MinimumExceptionNameLength: '2' + cert-oop57-cpp.MemCmpNames: '' + google-readability-namespace-comments.SpacesBeforeComments: '2' + cppcoreguidelines-avoid-magic-numbers.IgnoreBitFieldsWidths: 'true' + cppcoreguidelines-non-private-member-variables-in-classes.IgnoreClassesWithAllMemberVariablesBeingPublic: 'true' + readability-uppercase-literal-suffix.NewSuffixes: '' + readability-function-cognitive-complexity.Threshold: '25' + cppcoreguidelines-no-malloc.Allocations: '::malloc;::calloc' + readability-simplify-boolean-expr.SimplifyDeMorganRelaxed: 'false' + cppcoreguidelines-narrowing-conversions.WarnOnIntegerToFloatingPointNarrowingConversion: 'true' + readability-function-size.BranchThreshold: '4294967295' + cert-err61-cpp.CheckThrowTemporaries: 'true' + readability-implicit-bool-conversion.AllowIntegerConditions: 'false' + readability-identifier-length.IgnoredParameterNames: '^[n]$' + readability-function-size.StatementThreshold: '800' + readability-identifier-naming.IgnoreMainLikeFunctions: 'false' + llvm-qualified-auto.AddConstToQualified: 'false' + cppcoreguidelines-special-member-functions.AllowMissingMoveFunctionsWhenCopyIsDeleted: 'false' + cppcoreguidelines-init-variables.MathHeader: '' + cert-str34-c.CharTypdefsToIgnore: '' + google-readability-function-size.StatementThreshold: '800' + llvm-else-after-return.WarnOnConditionVariables: 'false' + cert-msc51-cpp.DisallowedSeedTypes: 'time_t,std::time_t' + readability-suspicious-call-argument.DiceSimilarAbove: '70' + readability-suspicious-call-argument.Dice: 'true' + readability-suspicious-call-argument.Abbreviation: 'true' + cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor: 'false' + readability-identifier-length.IgnoredLoopCounterNames: '^[ijk_]$' + cert-dcl37-c.Invert: 'false' + cert-dcl37-c.AggressiveDependentMemberLookup: 'false' + readability-identifier-length.MinimumLoopCounterNameLength: '2' + cppcoreguidelines-avoid-do-while.IgnoreMacros: 'false' + cert-msc54-cpp.AsyncSafeFunctionSet: POSIX + cppcoreguidelines-no-malloc.Deallocations: '::free' + readability-magic-numbers.IgnoredIntegerValues: '1;2;3;4;' + readability-magic-numbers.IgnorePowersOf2IntegerValues: 'false' + portability-simd-intrinsics.Std: '' + readability-redundant-member-init.IgnoreBaseInCopyConstructors: 'false' + readability-suspicious-call-argument.JaroWinklerSimilarAbove: '85' + cert-dcl16-c.IgnoreMacros: 'true' + llvm-else-after-return.WarnOnUnfixable: 'false' + cert-msc32-c.DisallowedSeedTypes: 'time_t,std::time_t' +... + diff --git a/CMakeLists.txt b/CMakeLists.txt index c973386..362821f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -114,7 +114,16 @@ install( # Clang tidy add_custom_target(clang-tidy-check - # clang-tidy -checks=-*,clang-analyzer-*,clang-analyzer-cplusplus*,cert-*,cppcoreguidelines-*,portability-*,readability-*,clang-diagnostic-* -dump-config -p ${CMAKE_BINARY_DIR}/compile_commands.json ${SOURCE_FILES} ${HEADER_FILES} > ../.clang-tidy clang-tidy -p ${CMAKE_BINARY_DIR}/compile_commands.json ${SOURCE_FILES} ${HEADER_FILES} DEPENDS ${SOURCE_FILES} ${HEADER_FILES} - ) \ No newline at end of file +) + +add_custom_target(clang-tidy-dump + clang-tidy -checks=-*,clang-analyzer-*,clang-analyzer-cplusplus*,cert-*,cppcoreguidelines-*,portability-*,readability-*,clang-diagnostic-* -dump-config -p ${CMAKE_BINARY_DIR}/compile_commands.json ${SOURCE_FILES} ${HEADER_FILES} > ../.clang-tidy + DEPENDS ${SOURCE_FILES} ${HEADER_FILES} +) + +add_custom_target(clang-tidy-fix + clang-tidy -fix-notes -p ${CMAKE_BINARY_DIR}/compile_commands.json ${SOURCE_FILES} ${HEADER_FILES} + DEPENDS ${SOURCE_FILES} ${HEADER_FILES} +) \ No newline at end of file From f179a7e4ae4ae25d0c49bc90c211da7b8c789b29 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Thu, 29 Feb 2024 21:52:31 -0500 Subject: [PATCH 090/131] Bump cmake minimum version to version 3.23 #23 --- CMakeLists.txt | 242 ++++++++++++++++++++++++++----------------------- 1 file changed, 129 insertions(+), 113 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e3afc99..020425e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,113 +1,129 @@ -cmake_minimum_required(VERSION 3.16) - -# Keep this on one line for release checking -project(dbc VERSION 0.2.0 DESCRIPTION "C++ DBC Parser") - -# -- PROJECT OPTIONS -- # -option(DBC_ENABLE_TESTS "Enable Unittests" ON) -option(DBC_TEST_LOCALE_INDEPENDENCE "Used to deterime if the libary is locale agnostic when it comes to converting floats. You need `de_DE.UTF-8` locale installed for this testing." OFF) -option(DBC_GENERATE_DOCS "Use doxygen if installed to generated documentation files" OFF) -option(DBC_GENERATE_SINGLE_HEADER "This will run the generator for the single header file version. Default is OFF since we make a static build. Requires cargo installed." OFF) -# ---------------------- # - -set(CMAKE_EXPORT_COMPILE_COMMANDS ON) - -# package -set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}) -set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR}) -set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH}) -set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE) -set(CPACK_RESOURCE_FILE_README ${CMAKE_CURRENT_SOURCE_DIR}/README.md) -include(CPack) - -# specify the C++ standard -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_STANDARD_REQUIRED True) - -find_package(FastFloat QUIET) -if (NOT ${FastFloat_FOUND}) - include(FetchContent) - FetchContent_Declare( - FastFloat - GIT_REPOSITORY https://github.com/fastfloat/fast_float.git - GIT_TAG 1ea4f27b2aeee2859a1354a3c24cff52a116cad1 - ) - FetchContent_MakeAvailable(FastFloat) -endif() - -# add where to find the source files -list(APPEND SOURCE_FILES - ${PROJECT_SOURCE_DIR}/src/utils.cpp - ${PROJECT_SOURCE_DIR}/src/message.cpp - ${PROJECT_SOURCE_DIR}/src/signal.cpp - ${PROJECT_SOURCE_DIR}/src/dbc.cpp -) - -list(APPEND HEADER_FILES - ${PROJECT_SOURCE_DIR}/include/libdbc/dbc.hpp - ${PROJECT_SOURCE_DIR}/include/libdbc/message.hpp - ${PROJECT_SOURCE_DIR}/include/libdbc/signal.hpp - ${PROJECT_SOURCE_DIR}/include/libdbc/utils/utils.hpp - ${PROJECT_SOURCE_DIR}/include/libdbc/exceptions/error.hpp -) - -if(DBC_ENABLE_TESTS) - include(CTest) - add_subdirectory(test) -endif() - -if(DBC_GENERATE_DOCS) - add_subdirectory(doc) -endif() - -list(APPEND GCC_CLANG_COMPILE_FLAGS - -Wall -Wextra -Wpedantic - -Wconversion -Wint-in-bool-context - -Wmissing-declarations -Wmissing-field-initializers - -Werror -) - - -if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC") - add_compile_options(/W4 /WX) -elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") - # Clang shadow warnings aren't as sensitive as gcc - add_compile_options(${GCC_CLANG_COMPILE_FLAGS} -Wshadow) -else() - add_compile_options(${GCC_CLANG_COMPILE_FLAGS}) -endif() - -add_library(${PROJECT_NAME} STATIC ${SOURCE_FILES}) -target_link_libraries(${PROJECT_NAME} FastFloat::fast_float) -target_include_directories(${PROJECT_NAME} PUBLIC - $ - $ -) -target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) - -target_sources(${PROJECT_NAME} INTERFACE FILE_SET HEADERS - TYPE HEADERS - BASE_DIRS ${PROJECT_SOURCE_DIR}/include/libdbc - FILES ${HEADER_FILES} -) - -if(DBC_GENERATE_SINGLE_HEADER) - add_custom_target(single_header ALL - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - COMMAND ${CMAKE_SOURCE_DIR}/scripts/create_single_header.sh - ) -endif() - -## Installation -# install lib -install(TARGETS ${PROJECT_NAME} - DESTINATION ${CMAKE_INSTALL_LIBDIR}) - -# install headers -install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/libdbc DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) - -# Generate pkg-config file -configure_file(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY) -install( - FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc - DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) +cmake_minimum_required(VERSION 3.23) + +# Keep this on one line for release checking +project(dbc VERSION 0.2.0 DESCRIPTION "C++ DBC Parser") + +# -- PROJECT OPTIONS -- # +option(DBC_ENABLE_TESTS "Enable Unittests" ON) +option(DBC_TEST_LOCALE_INDEPENDENCE "Used to deterime if the libary is locale agnostic when it comes to converting floats. You need `de_DE.UTF-8` locale installed for this testing." OFF) +option(DBC_GENERATE_DOCS "Use doxygen if installed to generated documentation files" OFF) +option(DBC_GENERATE_SINGLE_HEADER "This will run the generator for the single header file version. Default is OFF since we make a static build. Requires cargo installed." OFF) +# ---------------------- # + +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +# package +set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}) +set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR}) +set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH}) +set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE) +set(CPACK_RESOURCE_FILE_README ${CMAKE_CURRENT_SOURCE_DIR}/README.md) +include(CPack) + +# specify the C++ standard +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED True) + +find_package(FastFloat QUIET) +if (NOT ${FastFloat_FOUND}) + include(FetchContent) + FetchContent_Declare( + FastFloat + GIT_REPOSITORY https://github.com/fastfloat/fast_float.git + GIT_TAG 1ea4f27b2aeee2859a1354a3c24cff52a116cad1 + ) + FetchContent_MakeAvailable(FastFloat) +endif() + +# add where to find the source files +list(APPEND SOURCE_FILES + ${PROJECT_SOURCE_DIR}/src/utils.cpp + ${PROJECT_SOURCE_DIR}/src/message.cpp + ${PROJECT_SOURCE_DIR}/src/signal.cpp + ${PROJECT_SOURCE_DIR}/src/dbc.cpp +) + +list(APPEND HEADER_FILES + ${PROJECT_SOURCE_DIR}/include/libdbc/dbc.hpp + ${PROJECT_SOURCE_DIR}/include/libdbc/message.hpp + ${PROJECT_SOURCE_DIR}/include/libdbc/signal.hpp + ${PROJECT_SOURCE_DIR}/include/libdbc/utils/utils.hpp + ${PROJECT_SOURCE_DIR}/include/libdbc/exceptions/error.hpp +) + +if(DBC_ENABLE_TESTS) + include(CTest) + add_subdirectory(test) +endif() + +if(DBC_GENERATE_DOCS) + add_subdirectory(doc) +endif() + +list(APPEND GCC_CLANG_COMPILE_FLAGS + -Wall -Wextra -Wpedantic + -Wconversion -Wint-in-bool-context + -Wmissing-declarations -Wmissing-field-initializers + -Werror +) + + +if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC") + add_compile_options(/W4 /WX) +elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + # Clang shadow warnings aren't as sensitive as gcc + add_compile_options(${GCC_CLANG_COMPILE_FLAGS} -Wshadow) +else() + add_compile_options(${GCC_CLANG_COMPILE_FLAGS}) +endif() + +add_library(${PROJECT_NAME} STATIC ${SOURCE_FILES}) +target_link_libraries(${PROJECT_NAME} FastFloat::fast_float) +target_include_directories(${PROJECT_NAME} PUBLIC + $ + $ +) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) + +target_sources(${PROJECT_NAME} INTERFACE FILE_SET HEADERS + TYPE HEADERS + BASE_DIRS ${PROJECT_SOURCE_DIR}/include/libdbc + FILES ${HEADER_FILES} +) + +if(DBC_GENERATE_SINGLE_HEADER) + add_custom_target(single_header ALL + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + COMMAND ${CMAKE_SOURCE_DIR}/scripts/create_single_header.sh + ) +endif() + +## Installation +# install lib +install(TARGETS ${PROJECT_NAME} + DESTINATION ${CMAKE_INSTALL_LIBDIR}) + +# install headers +install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/libdbc DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + +# Generate pkg-config file +configure_file(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY) +install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) + +# Clang tidy +add_custom_target(clang-tidy-check + clang-tidy -p ${CMAKE_BINARY_DIR}/compile_commands.json ${SOURCE_FILES} ${HEADER_FILES} + DEPENDS ${SOURCE_FILES} ${HEADER_FILES} +) + +add_custom_target(clang-tidy-dump + clang-tidy -checks=-*,clang-analyzer-*,clang-analyzer-cplusplus*,cert-*,cppcoreguidelines-*,portability-*,readability-*,clang-diagnostic-* -dump-config -p ${CMAKE_BINARY_DIR}/compile_commands.json ${SOURCE_FILES} ${HEADER_FILES} > ../.clang-tidy + DEPENDS ${SOURCE_FILES} ${HEADER_FILES} +) + +add_custom_target(clang-tidy-fix + clang-tidy -fix-notes -p ${CMAKE_BINARY_DIR}/compile_commands.json ${SOURCE_FILES} ${HEADER_FILES} + DEPENDS ${SOURCE_FILES} ${HEADER_FILES} +) From 5343d15d1dcd62cb9d99beb4ef54287debcfe2ac Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Thu, 29 Feb 2024 22:10:53 -0500 Subject: [PATCH 091/131] Standardize line endings to LF only (unix) and fix clang tidy errors about reserved define includes guards --- .clang-format | 1 + include/libdbc/dbc.hpp | 110 ++--- include/libdbc/exceptions/error.hpp | 48 +-- include/libdbc/message.hpp | 98 ++--- include/libdbc/signal.hpp | 108 ++--- include/libdbc/utils/utils.hpp | 102 ++--- src/dbc.cpp | 616 ++++++++++++++-------------- src/message.cpp | 230 +++++------ src/signal.cpp | 110 ++--- src/utils.cpp | 162 ++++---- test/test_dbc.cpp | 440 ++++++++++---------- test/test_utils.cpp | 168 ++++---- 12 files changed, 1097 insertions(+), 1096 deletions(-) diff --git a/.clang-format b/.clang-format index c409644..350cdc2 100644 --- a/.clang-format +++ b/.clang-format @@ -106,3 +106,4 @@ AllowShortLambdasOnASingleLine: Empty AllowAllArgumentsOnNextLine: false InsertNewlineAtEOF: true +LineEnding: LF diff --git a/include/libdbc/dbc.hpp b/include/libdbc/dbc.hpp index bff9c4e..109b89f 100644 --- a/include/libdbc/dbc.hpp +++ b/include/libdbc/dbc.hpp @@ -1,55 +1,55 @@ -#ifndef __DBC_HPP__ -#define __DBC_HPP__ - -#include -#include -#include -#include - -#include - -namespace libdbc { - -class Parser { -public: - virtual ~Parser() = default; - - virtual void parse_file(const std::string& file) = 0; - -protected: -}; - -class DbcParser : public Parser { -public: - DbcParser(); - - virtual ~DbcParser() = default; - - virtual void parse_file(const std::string& file) final override; - - std::string get_version() const; - std::vector get_nodes() const; - std::vector get_messages() const; - - Message::ParseSignalsStatus parseMessage(const uint32_t id, const std::vector& data, std::vector& out_values); - -private: - std::string version; - std::vector nodes; - std::vector messages; - - const std::regex version_re; - const std::regex bit_timing_re; - const std::regex name_space_re; - const std::regex node_re; - const std::regex message_re; - const std::regex signal_re; - - void parse_dbc_header(std::istream& file_stream); - void parse_dbc_nodes(std::istream& file_stream); - void parse_dbc_messages(const std::vector& lines); -}; - -} - -#endif // __DBC_HPP__ +#ifndef DBC_HPP +#define DBC_HPP + +#include +#include +#include +#include + +#include + +namespace libdbc { + +class Parser { +public: + virtual ~Parser() = default; + + virtual void parse_file(const std::string& file) = 0; + +protected: +}; + +class DbcParser : public Parser { +public: + DbcParser(); + + virtual ~DbcParser() = default; + + virtual void parse_file(const std::string& file) final override; + + std::string get_version() const; + std::vector get_nodes() const; + std::vector get_messages() const; + + Message::ParseSignalsStatus parseMessage(const uint32_t id, const std::vector& data, std::vector& out_values); + +private: + std::string version; + std::vector nodes; + std::vector messages; + + const std::regex version_re; + const std::regex bit_timing_re; + const std::regex name_space_re; + const std::regex node_re; + const std::regex message_re; + const std::regex signal_re; + + void parse_dbc_header(std::istream& file_stream); + void parse_dbc_nodes(std::istream& file_stream); + void parse_dbc_messages(const std::vector& lines); +}; + +} + +#endif // DBC_HPP diff --git a/include/libdbc/exceptions/error.hpp b/include/libdbc/exceptions/error.hpp index 175cac7..a6a3653 100644 --- a/include/libdbc/exceptions/error.hpp +++ b/include/libdbc/exceptions/error.hpp @@ -1,24 +1,24 @@ -#ifndef __ERROR_HPP__ -#define __ERROR_HPP__ - -#include - -namespace libdbc { - -class exception : public std::exception { -public: - const char* what() const throw() { - return "libdbc exception occurred"; - } -}; - -class validity_error : public exception { -public: - const char* what() const throw() { - return "Invalid DBC file"; - } -}; - -} // libdbc - -#endif // __ERROR_HPP__ +#ifndef ERROR_HPP +#define ERROR_HPP + +#include + +namespace libdbc { + +class exception : public std::exception { +public: + const char* what() const throw() { + return "libdbc exception occurred"; + } +}; + +class validity_error : public exception { +public: + const char* what() const throw() { + return "Invalid DBC file"; + } +}; + +} // libdbc + +#endif // ERROR_HPP diff --git a/include/libdbc/message.hpp b/include/libdbc/message.hpp index f3b0b66..a018a31 100644 --- a/include/libdbc/message.hpp +++ b/include/libdbc/message.hpp @@ -1,49 +1,49 @@ -#ifndef __MESSAGE_HPP__ -#define __MESSAGE_HPP__ - -#include -#include -#include -#include -#include - -namespace libdbc { -struct Message { - Message() = delete; - virtual ~Message() = default; - explicit Message(uint32_t id, const std::string& name, uint8_t size, const std::string& node); - - enum class ParseSignalsStatus { - Success, - ErrorMessageToLong, - ErrorBigEndian, - ErrorUnknownID, - ErrorInvalidConversion, - }; - - ParseSignalsStatus parseSignals(const std::vector& data, std::vector& values) const; - - void appendSignal(const Signal& signal); - const std::vector getSignals() const; - uint32_t id() const; - uint8_t size() const; - const std::string& name() const; - void addValueDescription(const std::string& signal_name, const std::vector&); - - virtual bool operator==(const Message& rhs) const; - -private: - uint32_t m_id; - std::string m_name; - uint8_t m_size; - std::string m_node; - std::vector m_signals; - - friend std::ostream& operator<<(std::ostream& os, const Message& dt); -}; - -std::ostream& operator<<(std::ostream& out, const Message& msg); - -} - -#endif // __MESSAGE_HPP__ +#ifndef MESSAGE_HPP +#define MESSAGE_HPP + +#include +#include +#include +#include +#include + +namespace libdbc { +struct Message { + Message() = delete; + virtual ~Message() = default; + explicit Message(uint32_t id, const std::string& name, uint8_t size, const std::string& node); + + enum class ParseSignalsStatus { + Success, + ErrorMessageToLong, + ErrorBigEndian, + ErrorUnknownID, + ErrorInvalidConversion, + }; + + ParseSignalsStatus parseSignals(const std::vector& data, std::vector& values) const; + + void appendSignal(const Signal& signal); + const std::vector getSignals() const; + uint32_t id() const; + uint8_t size() const; + const std::string& name() const; + void addValueDescription(const std::string& signal_name, const std::vector&); + + virtual bool operator==(const Message& rhs) const; + +private: + uint32_t m_id; + std::string m_name; + uint8_t m_size; + std::string m_node; + std::vector m_signals; + + friend std::ostream& operator<<(std::ostream& os, const Message& dt); +}; + +std::ostream& operator<<(std::ostream& out, const Message& msg); + +} + +#endif // MESSAGE_HPP diff --git a/include/libdbc/signal.hpp b/include/libdbc/signal.hpp index c7311cb..cdfd018 100644 --- a/include/libdbc/signal.hpp +++ b/include/libdbc/signal.hpp @@ -1,54 +1,54 @@ - -#ifndef __SIGNAL_HPP__ -#define __SIGNAL_HPP__ - -#include -#include -#include -#include - -namespace libdbc { -struct Signal { - struct SignalValueDescriptions { - uint32_t value; - std::string description; - }; - - 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 receivers; - std::vector svDescriptions; - - Signal() = delete; - virtual ~Signal() = default; - explicit 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 recievers); - - virtual bool operator==(const Signal& rhs) const; - bool operator<(const Signal& rhs) const; -}; - -std::ostream& operator<<(std::ostream& out, const Signal& sig); - -} - -#endif // __SIGNAL_HPP__ + +#ifndef SIGNAL_HPP +#define SIGNAL_HPP + +#include +#include +#include +#include + +namespace libdbc { +struct Signal { + struct SignalValueDescriptions { + uint32_t value; + std::string description; + }; + + 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 receivers; + std::vector svDescriptions; + + Signal() = delete; + virtual ~Signal() = default; + explicit 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 recievers); + + virtual bool operator==(const Signal& rhs) const; + bool operator<(const Signal& rhs) const; +}; + +std::ostream& operator<<(std::ostream& out, const Signal& sig); + +} + +#endif // SIGNAL_HPP diff --git a/include/libdbc/utils/utils.hpp b/include/libdbc/utils/utils.hpp index 21ff540..8763af6 100644 --- a/include/libdbc/utils/utils.hpp +++ b/include/libdbc/utils/utils.hpp @@ -1,51 +1,51 @@ - -#ifndef __UTILS_HPP__ -#define __UTILS_HPP__ - -#include -#include -#include -#include -#include -#include - -namespace utils { - -class StreamHandler { -public: - /** - * This is a safe non line ending specific get_ine function. This is to help with files - * carried over from different systems. i.e Unix file comes to Windows with LF endings - * instead of CRLF. - * - * @param stream [description] - * @param line [description] - * @return [description] - */ - static std::istream& get_line(std::istream& stream, std::string& line); - - static std::istream& get_next_non_blank_line(std::istream& stream, std::string& line); - - static std::istream& skip_to_next_blank_line(std::istream& stream, std::string& line); -}; - -class String { -public: - static std::string trim(const std::string& line); - - template - static void split(const std::string& str, Container& cont, char delim = ' ') { - std::stringstream ss(str); - std::string token; - - while (std::getline(ss, token, delim)) { - cont.push_back(token); - } - } - - static double convert_to_double(const std::string& value, double default_value = 0); -}; - -} - -#endif // __UTILS_HPP__ + +#ifndef UTILS_HPP +#define UTILS_HPP + +#include +#include +#include +#include +#include +#include + +namespace utils { + +class StreamHandler { +public: + /** + * This is a safe non line ending specific get_ine function. This is to help with files + * carried over from different systems. i.e Unix file comes to Windows with LF endings + * instead of CRLF. + * + * @param stream [description] + * @param line [description] + * @return [description] + */ + static std::istream& get_line(std::istream& stream, std::string& line); + + static std::istream& get_next_non_blank_line(std::istream& stream, std::string& line); + + static std::istream& skip_to_next_blank_line(std::istream& stream, std::string& line); +}; + +class String { +public: + static std::string trim(const std::string& line); + + template + static void split(const std::string& str, Container& cont, char delim = ' ') { + std::stringstream ss(str); + std::string token; + + while (std::getline(ss, token, delim)) { + cont.push_back(token); + } + } + + static double convert_to_double(const std::string& value, double default_value = 0); +}; + +} + +#endif // UTILS_HPP diff --git a/src/dbc.cpp b/src/dbc.cpp index 7ea7ce3..d78c32e 100644 --- a/src/dbc.cpp +++ b/src/dbc.cpp @@ -1,308 +1,308 @@ -#include -#include -#include -#include - -#include - -namespace libdbc { - -const auto floatPattern = "(-?\\d+\\.?(\\d+)?)"; // Can be negative - -const auto signalIdentifierPattern = "(SG_)"; -const auto namePattern = "(\\w+)"; -const auto bitStartPattern = "(\\d+)"; // Cannot be negative -const auto lengthPattern = "(\\d+)"; // Cannot be negative -const auto byteOrderPattern = "([0-1])"; -const auto signPattern = "(\\+|\\-)"; -const auto scalePattern = "(\\d+\\.?(\\d+)?)"; // Non negative float -const auto offsetPattern = floatPattern; -const auto offsetScalePattern = std::string("\\(") + scalePattern + "\\," + offsetPattern + "\\)"; -const auto minPattern = floatPattern; -const auto maxPattern = floatPattern; -const auto minMaxPattern = std::string("\\[") + minPattern + "\\|" + maxPattern + "\\]"; -const auto unitPattern = "\"(.*)\""; // Random string -const auto receiverPattern = "([\\w\\,]+|Vector__XXX)*"; -const auto whiteSpace = "\\s"; - -enum VALToken { Identifier = 0, CANId, SignalName, Value, Description }; - -struct VALObject { - uint32_t can_id; - std::string signal_name; - std::vector vd; -}; - -static bool parseVal(const std::string& str, VALObject& obj); -bool parseVal(const std::string& str, VALObject& obj) { - obj.signal_name = ""; - obj.vd.clear(); - auto state = Identifier; - const char* a = str.data(); - Signal::SignalValueDescriptions vd; - for (;;) { - switch (state) { - case Identifier: { - if (*a != 'V') { - return false; - } - a++; - if (*a != 'A') { - return false; - } - a++; - if (*a != 'L') { - return false; - } - a++; - if (*a != '_') { - return false; - } - a++; - if (*a != ' ') { - return false; - } - a++; // skip whitespace - state = CANId; - break; - } - case CANId: { - std::string can_id_str; - while (*a >= '0' && *a <= '9') { - can_id_str += *a; - a++; - } - if (can_id_str.empty()) { - return false; - } - obj.can_id = static_cast(std::stoul(can_id_str)); - if (*a != ' ') { - return false; - } - a++; // skip whitespace - state = SignalName; - break; - } - case SignalName: { - if ((*a >= 'a' && *a <= 'z') || (*a >= 'A' && *a <= 'Z') || *a == '_') { - obj.signal_name += *a; - } else { - return false; - } - a++; - while ((*a >= 'a' && *a <= 'z') || (*a >= 'A' && *a <= 'Z') || *a == '_' || (*a >= '0' && *a <= '9')) { - obj.signal_name += *a; - a++; - } - if (*a != ' ') { - return false; - } - a++; // skip whitespace - state = Value; - break; - } - case Value: { - std::string value_str; - while (*a >= '0' && *a <= '9') { - value_str += *a; - a++; - } - if (*a == ';') { - if (value_str.empty()) { - return true; - } - return false; - } - if (value_str.empty()) { - return false; - } - - if (*a != ' ') { - return false; - } - a++; // skip whitespace - vd.value = (uint32_t)std::stoul(value_str); - state = Description; - break; - } - case Description: { - std::string desc; - if (*a != '"') { - return false; - } - a++; - while (*a != '"' && *a != 0) { - desc += *a; - a++; - } - if (*a == 0) { - return false; - } - a++; - if (*a != ' ') { - return false; - } - a++; // skip whitespace - - vd.description = desc; - obj.vd.push_back(vd); - - state = Value; - break; - } - } - } - return false; -} - -DbcParser::DbcParser() - : version("") - , nodes() - , version_re("^(VERSION)\\s\"(.*)\"") - , bit_timing_re("^(BS_:)") - , name_space_re("^(NS_)\\s\\:") - , node_re("^(BU_:)\\s((?:[\\w]+?\\s?)*)") - , message_re("^(BO_)\\s(\\d+)\\s(\\w+)\\:\\s(\\d+)\\s(\\w+|Vector__XXX)") - , - // NOTE: No multiplex support yet - signal_re(std::string("^") + whiteSpace + signalIdentifierPattern + whiteSpace + namePattern + whiteSpace + "\\:" + whiteSpace + bitStartPattern + "\\|" - + lengthPattern + "\\@" + byteOrderPattern + signPattern + whiteSpace + offsetScalePattern + whiteSpace + minMaxPattern + whiteSpace + unitPattern - + whiteSpace + receiverPattern) { -} - -void DbcParser::parse_file(const std::string& file) { - std::ifstream s(file.c_str()); - std::string line; - std::vector lines; - - messages.clear(); - - parse_dbc_header(s); - - parse_dbc_nodes(s); - - while (!s.eof()) { - utils::StreamHandler::get_next_non_blank_line(s, line); - lines.push_back(line); - } - - parse_dbc_messages(lines); -} - -std::string DbcParser::get_version() const { - return version; -} - -std::vector DbcParser::get_nodes() const { - return nodes; -} - -std::vector DbcParser::get_messages() const { - return messages; -} - -Message::ParseSignalsStatus DbcParser::parseMessage(const uint32_t id, const std::vector& data, std::vector& out_values) { - for (const auto& message : messages) { - if (message.id() == id) { - return message.parseSignals(data, out_values); - } - } - return Message::ParseSignalsStatus::ErrorUnknownID; -} - -void DbcParser::parse_dbc_header(std::istream& file_stream) { - std::string line; - std::smatch match; - - utils::StreamHandler::get_line(file_stream, line); - - if (!std::regex_search(line, match, version_re)) { - throw validity_error(); - } - - version = match.str(2); - - utils::StreamHandler::get_next_non_blank_line(file_stream, line); - utils::StreamHandler::skip_to_next_blank_line(file_stream, line); - utils::StreamHandler::get_next_non_blank_line(file_stream, line); - - if (!std::regex_search(line, match, bit_timing_re)) { - throw validity_error(); - } -} - -void DbcParser::parse_dbc_nodes(std::istream& file_stream) { - std::string line; - std::smatch match; - - utils::StreamHandler::get_next_non_blank_line(file_stream, line); - - if (!std::regex_search(line, match, node_re)) { - throw validity_error(); - } - - if (match.length() > 2) { - std::string n = match.str(2); - utils::String::split(n, nodes); - } -} - -void DbcParser::parse_dbc_messages(const std::vector& lines) { - std::smatch match; - - std::vector sv; - - VALObject obj{}; - for (const auto& line : lines) { - if (std::regex_search(line, match, message_re)) { - uint32_t id = static_cast(std::stoul(match.str(2))); - std::string name = match.str(3); - uint8_t size = static_cast(std::stoul(match.str(4))); - std::string node = match.str(5); - - Message msg(id, name, size, node); - - messages.push_back(msg); - continue; - } - - if (std::regex_search(line, match, signal_re)) { - std::string name = match.str(2); - bool is_multiplexed = false; // No support yet - uint32_t start_bit = static_cast(std::stoul(match.str(3))); - uint32_t size = static_cast(std::stoul(match.str(4))); - bool is_bigendian = (std::stoul(match.str(5)) == 0); - bool is_signed = (match.str(6) == "-"); - - double factor = utils::String::convert_to_double(match.str(7).data()); - double offset = utils::String::convert_to_double(match.str(9).data()); - double min = utils::String::convert_to_double(match.str(11).data()); - double max = utils::String::convert_to_double(match.str(13).data()); - - std::string unit = match.str(15); - - std::vector receivers; - utils::String::split(match.str(16), receivers, ','); - - Signal sig(name, is_multiplexed, start_bit, size, is_bigendian, is_signed, factor, offset, min, max, unit, receivers); - messages.back().appendSignal(sig); - continue; - } - - if (parseVal(line, obj)) { - sv.push_back(obj); - continue; - } - } - - for (const auto& signal : sv) { - for (auto& msg : messages) { - if (msg.id() == signal.can_id) { - msg.addValueDescription(signal.signal_name, signal.vd); - break; - } - } - } -} - -} +#include +#include +#include +#include + +#include + +namespace libdbc { + +const auto floatPattern = "(-?\\d+\\.?(\\d+)?)"; // Can be negative + +const auto signalIdentifierPattern = "(SG_)"; +const auto namePattern = "(\\w+)"; +const auto bitStartPattern = "(\\d+)"; // Cannot be negative +const auto lengthPattern = "(\\d+)"; // Cannot be negative +const auto byteOrderPattern = "([0-1])"; +const auto signPattern = "(\\+|\\-)"; +const auto scalePattern = "(\\d+\\.?(\\d+)?)"; // Non negative float +const auto offsetPattern = floatPattern; +const auto offsetScalePattern = std::string("\\(") + scalePattern + "\\," + offsetPattern + "\\)"; +const auto minPattern = floatPattern; +const auto maxPattern = floatPattern; +const auto minMaxPattern = std::string("\\[") + minPattern + "\\|" + maxPattern + "\\]"; +const auto unitPattern = "\"(.*)\""; // Random string +const auto receiverPattern = "([\\w\\,]+|Vector__XXX)*"; +const auto whiteSpace = "\\s"; + +enum VALToken { Identifier = 0, CANId, SignalName, Value, Description }; + +struct VALObject { + uint32_t can_id; + std::string signal_name; + std::vector vd; +}; + +static bool parseVal(const std::string& str, VALObject& obj); +bool parseVal(const std::string& str, VALObject& obj) { + obj.signal_name = ""; + obj.vd.clear(); + auto state = Identifier; + const char* a = str.data(); + Signal::SignalValueDescriptions vd; + for (;;) { + switch (state) { + case Identifier: { + if (*a != 'V') { + return false; + } + a++; + if (*a != 'A') { + return false; + } + a++; + if (*a != 'L') { + return false; + } + a++; + if (*a != '_') { + return false; + } + a++; + if (*a != ' ') { + return false; + } + a++; // skip whitespace + state = CANId; + break; + } + case CANId: { + std::string can_id_str; + while (*a >= '0' && *a <= '9') { + can_id_str += *a; + a++; + } + if (can_id_str.empty()) { + return false; + } + obj.can_id = static_cast(std::stoul(can_id_str)); + if (*a != ' ') { + return false; + } + a++; // skip whitespace + state = SignalName; + break; + } + case SignalName: { + if ((*a >= 'a' && *a <= 'z') || (*a >= 'A' && *a <= 'Z') || *a == '_') { + obj.signal_name += *a; + } else { + return false; + } + a++; + while ((*a >= 'a' && *a <= 'z') || (*a >= 'A' && *a <= 'Z') || *a == '_' || (*a >= '0' && *a <= '9')) { + obj.signal_name += *a; + a++; + } + if (*a != ' ') { + return false; + } + a++; // skip whitespace + state = Value; + break; + } + case Value: { + std::string value_str; + while (*a >= '0' && *a <= '9') { + value_str += *a; + a++; + } + if (*a == ';') { + if (value_str.empty()) { + return true; + } + return false; + } + if (value_str.empty()) { + return false; + } + + if (*a != ' ') { + return false; + } + a++; // skip whitespace + vd.value = (uint32_t)std::stoul(value_str); + state = Description; + break; + } + case Description: { + std::string desc; + if (*a != '"') { + return false; + } + a++; + while (*a != '"' && *a != 0) { + desc += *a; + a++; + } + if (*a == 0) { + return false; + } + a++; + if (*a != ' ') { + return false; + } + a++; // skip whitespace + + vd.description = desc; + obj.vd.push_back(vd); + + state = Value; + break; + } + } + } + return false; +} + +DbcParser::DbcParser() + : version("") + , nodes() + , version_re("^(VERSION)\\s\"(.*)\"") + , bit_timing_re("^(BS_:)") + , name_space_re("^(NS_)\\s\\:") + , node_re("^(BU_:)\\s((?:[\\w]+?\\s?)*)") + , message_re("^(BO_)\\s(\\d+)\\s(\\w+)\\:\\s(\\d+)\\s(\\w+|Vector__XXX)") + , + // NOTE: No multiplex support yet + signal_re(std::string("^") + whiteSpace + signalIdentifierPattern + whiteSpace + namePattern + whiteSpace + "\\:" + whiteSpace + bitStartPattern + "\\|" + + lengthPattern + "\\@" + byteOrderPattern + signPattern + whiteSpace + offsetScalePattern + whiteSpace + minMaxPattern + whiteSpace + unitPattern + + whiteSpace + receiverPattern) { +} + +void DbcParser::parse_file(const std::string& file) { + std::ifstream s(file.c_str()); + std::string line; + std::vector lines; + + messages.clear(); + + parse_dbc_header(s); + + parse_dbc_nodes(s); + + while (!s.eof()) { + utils::StreamHandler::get_next_non_blank_line(s, line); + lines.push_back(line); + } + + parse_dbc_messages(lines); +} + +std::string DbcParser::get_version() const { + return version; +} + +std::vector DbcParser::get_nodes() const { + return nodes; +} + +std::vector DbcParser::get_messages() const { + return messages; +} + +Message::ParseSignalsStatus DbcParser::parseMessage(const uint32_t id, const std::vector& data, std::vector& out_values) { + for (const auto& message : messages) { + if (message.id() == id) { + return message.parseSignals(data, out_values); + } + } + return Message::ParseSignalsStatus::ErrorUnknownID; +} + +void DbcParser::parse_dbc_header(std::istream& file_stream) { + std::string line; + std::smatch match; + + utils::StreamHandler::get_line(file_stream, line); + + if (!std::regex_search(line, match, version_re)) { + throw validity_error(); + } + + version = match.str(2); + + utils::StreamHandler::get_next_non_blank_line(file_stream, line); + utils::StreamHandler::skip_to_next_blank_line(file_stream, line); + utils::StreamHandler::get_next_non_blank_line(file_stream, line); + + if (!std::regex_search(line, match, bit_timing_re)) { + throw validity_error(); + } +} + +void DbcParser::parse_dbc_nodes(std::istream& file_stream) { + std::string line; + std::smatch match; + + utils::StreamHandler::get_next_non_blank_line(file_stream, line); + + if (!std::regex_search(line, match, node_re)) { + throw validity_error(); + } + + if (match.length() > 2) { + std::string n = match.str(2); + utils::String::split(n, nodes); + } +} + +void DbcParser::parse_dbc_messages(const std::vector& lines) { + std::smatch match; + + std::vector sv; + + VALObject obj{}; + for (const auto& line : lines) { + if (std::regex_search(line, match, message_re)) { + uint32_t id = static_cast(std::stoul(match.str(2))); + std::string name = match.str(3); + uint8_t size = static_cast(std::stoul(match.str(4))); + std::string node = match.str(5); + + Message msg(id, name, size, node); + + messages.push_back(msg); + continue; + } + + if (std::regex_search(line, match, signal_re)) { + std::string name = match.str(2); + bool is_multiplexed = false; // No support yet + uint32_t start_bit = static_cast(std::stoul(match.str(3))); + uint32_t size = static_cast(std::stoul(match.str(4))); + bool is_bigendian = (std::stoul(match.str(5)) == 0); + bool is_signed = (match.str(6) == "-"); + + double factor = utils::String::convert_to_double(match.str(7).data()); + double offset = utils::String::convert_to_double(match.str(9).data()); + double min = utils::String::convert_to_double(match.str(11).data()); + double max = utils::String::convert_to_double(match.str(13).data()); + + std::string unit = match.str(15); + + std::vector receivers; + utils::String::split(match.str(16), receivers, ','); + + Signal sig(name, is_multiplexed, start_bit, size, is_bigendian, is_signed, factor, offset, min, max, unit, receivers); + messages.back().appendSignal(sig); + continue; + } + + if (parseVal(line, obj)) { + sv.push_back(obj); + continue; + } + } + + for (const auto& signal : sv) { + for (auto& msg : messages) { + if (msg.id() == signal.can_id) { + msg.addValueDescription(signal.signal_name, signal.vd); + break; + } + } + } +} + +} diff --git a/src/message.cpp b/src/message.cpp index f16677a..89b47ac 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -1,115 +1,115 @@ -#include -#include -#include - -namespace libdbc { -Message::Message(uint32_t id, const std::string& name, uint8_t size, const std::string& node) - : m_id(id) - , m_name(name) - , m_size(size) - , m_node(node) { -} - -bool Message::operator==(const Message& rhs) const { - return (m_id == rhs.id()) && (m_name == rhs.m_name) && (m_size == rhs.m_size) && (m_node == rhs.m_node); -} - -Message::ParseSignalsStatus Message::parseSignals(const std::vector& data, std::vector& values) const { - auto size = data.size(); - if (size > 8) { - return ParseSignalsStatus::ErrorMessageToLong; // not supported yet - } - - uint64_t data_little_endian = 0; - uint64_t data_big_endian = 0; - for (size_t i = 0; i < size; i++) { - data_little_endian |= ((uint64_t)data[i]) << i * 8; - data_big_endian = (data_big_endian << 8) | (uint64_t)data[i]; - } - - // TODO: does this also work on a big endian machine? - - const auto len = size * 8; - uint64_t v = 0; - for (const auto& signal : m_signals) { - if (signal.is_bigendian) { - uint32_t start_bit = 8 * (signal.start_bit / 8) + (7 - (signal.start_bit % 8)); // Calculation taken from python CAN - v = data_big_endian << start_bit; - v = v >> (len - signal.size); - } else { - v = data_little_endian >> signal.start_bit; - } - - if (signal.is_signed && signal.size > 1) { - switch (signal.size) { - case 8: - values.push_back(static_cast(v) * signal.factor + signal.offset); - break; - case 16: - values.push_back(static_cast(v) * signal.factor + signal.offset); - break; - case 32: - values.push_back(static_cast(v) * signal.factor + signal.offset); - break; - case 64: - values.push_back(static_cast(v) * signal.factor + signal.offset); - break; - default: { - // 2 complement -> decimal - const int negative = (v & (1ull << (signal.size - 1))) != 0; - int64_t nativeInt; - if (negative) { - nativeInt = static_cast(v | ~((1ull << signal.size) - 1)); // invert all bits above signal.size - } else { - nativeInt = static_cast(v & ((1ull << signal.size) - 1)); // masking - } - values.push_back(static_cast(nativeInt) * signal.factor + signal.offset); - break; - } - } - } else { - // use only the relevant bits - v = v & ((1 << signal.size) - 1); // masking - values.push_back(static_cast(v) * signal.factor + signal.offset); - } - } - return ParseSignalsStatus::Success; -} - -void Message::appendSignal(const Signal& signal) { - m_signals.push_back(signal); -} - -const std::vector Message::getSignals() const { - return m_signals; -} - -uint32_t Message::id() const { - return m_id; -} - -uint8_t Message::size() const { - return m_size; -} - -const std::string& Message::name() const { - return m_name; -} - -void Message::addValueDescription(const std::string& signal_name, const std::vector& vd) { - for (auto& s : m_signals) { - if (s.name.compare(signal_name) == 0) { - s.svDescriptions = vd; - return; - } - } -} - -std::ostream& operator<<(std::ostream& out, const Message& msg) { - out << "Message: {id: " << msg.id() << ", "; - out << "name: " << msg.m_name << ", "; - out << "size: " << msg.m_size << ", "; - out << "node: " << msg.m_node << "}"; - return out; -} -} +#include +#include +#include + +namespace libdbc { +Message::Message(uint32_t id, const std::string& name, uint8_t size, const std::string& node) + : m_id(id) + , m_name(name) + , m_size(size) + , m_node(node) { +} + +bool Message::operator==(const Message& rhs) const { + return (m_id == rhs.id()) && (m_name == rhs.m_name) && (m_size == rhs.m_size) && (m_node == rhs.m_node); +} + +Message::ParseSignalsStatus Message::parseSignals(const std::vector& data, std::vector& values) const { + auto size = data.size(); + if (size > 8) { + return ParseSignalsStatus::ErrorMessageToLong; // not supported yet + } + + uint64_t data_little_endian = 0; + uint64_t data_big_endian = 0; + for (size_t i = 0; i < size; i++) { + data_little_endian |= ((uint64_t)data[i]) << i * 8; + data_big_endian = (data_big_endian << 8) | (uint64_t)data[i]; + } + + // TODO: does this also work on a big endian machine? + + const auto len = size * 8; + uint64_t v = 0; + for (const auto& signal : m_signals) { + if (signal.is_bigendian) { + uint32_t start_bit = 8 * (signal.start_bit / 8) + (7 - (signal.start_bit % 8)); // Calculation taken from python CAN + v = data_big_endian << start_bit; + v = v >> (len - signal.size); + } else { + v = data_little_endian >> signal.start_bit; + } + + if (signal.is_signed && signal.size > 1) { + switch (signal.size) { + case 8: + values.push_back(static_cast(v) * signal.factor + signal.offset); + break; + case 16: + values.push_back(static_cast(v) * signal.factor + signal.offset); + break; + case 32: + values.push_back(static_cast(v) * signal.factor + signal.offset); + break; + case 64: + values.push_back(static_cast(v) * signal.factor + signal.offset); + break; + default: { + // 2 complement -> decimal + const int negative = (v & (1ull << (signal.size - 1))) != 0; + int64_t nativeInt; + if (negative) { + nativeInt = static_cast(v | ~((1ull << signal.size) - 1)); // invert all bits above signal.size + } else { + nativeInt = static_cast(v & ((1ull << signal.size) - 1)); // masking + } + values.push_back(static_cast(nativeInt) * signal.factor + signal.offset); + break; + } + } + } else { + // use only the relevant bits + v = v & ((1 << signal.size) - 1); // masking + values.push_back(static_cast(v) * signal.factor + signal.offset); + } + } + return ParseSignalsStatus::Success; +} + +void Message::appendSignal(const Signal& signal) { + m_signals.push_back(signal); +} + +const std::vector Message::getSignals() const { + return m_signals; +} + +uint32_t Message::id() const { + return m_id; +} + +uint8_t Message::size() const { + return m_size; +} + +const std::string& Message::name() const { + return m_name; +} + +void Message::addValueDescription(const std::string& signal_name, const std::vector& vd) { + for (auto& s : m_signals) { + if (s.name.compare(signal_name) == 0) { + s.svDescriptions = vd; + return; + } + } +} + +std::ostream& operator<<(std::ostream& out, const Message& msg) { + out << "Message: {id: " << msg.id() << ", "; + out << "name: " << msg.m_name << ", "; + out << "size: " << msg.m_size << ", "; + out << "node: " << msg.m_node << "}"; + return out; +} +} diff --git a/src/signal.cpp b/src/signal.cpp index d1ab7d8..b9ce591 100644 --- a/src/signal.cpp +++ b/src/signal.cpp @@ -1,55 +1,55 @@ -#include - -namespace libdbc { -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 receivers) - : name(name) - , is_multiplexed(is_multiplexed) - , start_bit(start_bit) - , size(size) - , is_bigendian(is_bigendian) - , is_signed(is_signed) - , factor(factor) - , offset(offset) - , min(min) - , max(max) - , unit(unit) - , receivers(receivers) { -} - -bool Signal::operator==(const Signal& rhs) const { - return (this->name == rhs.name) && (this->is_multiplexed == rhs.is_multiplexed) && (this->start_bit == rhs.start_bit) && (this->size == rhs.size) - && (this->is_bigendian == rhs.is_bigendian) && (this->is_signed == rhs.is_signed) && (this->offset == rhs.offset) && (this->min == rhs.min) - && (this->max == rhs.max) && (this->unit == rhs.unit) && (this->receivers == rhs.receivers); -} - -bool Signal::operator<(const Signal& rhs) const { - return start_bit < rhs.start_bit; -} - -std::ostream& operator<<(std::ostream& out, const Signal& sig) { - out << "Signal {name: " << sig.name << ", "; - out << "Multiplexed: " << (sig.is_multiplexed ? "True" : "False") << ", "; - out << "Start bit: " << sig.start_bit << ", "; - out << "Size: " << sig.size << ", "; - out << "Endianness: " << (sig.is_bigendian ? "Big endian" : "Little endian") << ", "; - out << "Value Type: " << (sig.is_signed ? "Signed" : "Unsigned") << ", "; - out << "Min: " << sig.min << ", Max: " << sig.max << ", "; - out << "Unit: (" << sig.unit << "), "; - out << "receivers: "; - for (const auto& r : sig.receivers) { - out << r; - } - return out << "}"; -} -} +#include + +namespace libdbc { +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 receivers) + : name(name) + , is_multiplexed(is_multiplexed) + , start_bit(start_bit) + , size(size) + , is_bigendian(is_bigendian) + , is_signed(is_signed) + , factor(factor) + , offset(offset) + , min(min) + , max(max) + , unit(unit) + , receivers(receivers) { +} + +bool Signal::operator==(const Signal& rhs) const { + return (this->name == rhs.name) && (this->is_multiplexed == rhs.is_multiplexed) && (this->start_bit == rhs.start_bit) && (this->size == rhs.size) + && (this->is_bigendian == rhs.is_bigendian) && (this->is_signed == rhs.is_signed) && (this->offset == rhs.offset) && (this->min == rhs.min) + && (this->max == rhs.max) && (this->unit == rhs.unit) && (this->receivers == rhs.receivers); +} + +bool Signal::operator<(const Signal& rhs) const { + return start_bit < rhs.start_bit; +} + +std::ostream& operator<<(std::ostream& out, const Signal& sig) { + out << "Signal {name: " << sig.name << ", "; + out << "Multiplexed: " << (sig.is_multiplexed ? "True" : "False") << ", "; + out << "Start bit: " << sig.start_bit << ", "; + out << "Size: " << sig.size << ", "; + out << "Endianness: " << (sig.is_bigendian ? "Big endian" : "Little endian") << ", "; + out << "Value Type: " << (sig.is_signed ? "Signed" : "Unsigned") << ", "; + out << "Min: " << sig.min << ", Max: " << sig.max << ", "; + out << "Unit: (" << sig.unit << "), "; + out << "receivers: "; + for (const auto& r : sig.receivers) { + out << r; + } + return out << "}"; +} +} diff --git a/src/utils.cpp b/src/utils.cpp index f39cc81..ed715cb 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -1,81 +1,81 @@ -#include -#include -#include -#include - -#include - -namespace utils { - -std::istream& StreamHandler::get_line(std::istream& stream, std::string& line) { - std::string newline; - - std::getline(stream, newline); - - // Windows CRLF (\r\n) - if (newline.size() && newline[newline.size() - 1] == '\r') { - line = newline.substr(0, newline.size() - 1); - // MacOS LF (\r) - } else if (newline.size() && newline[newline.size()] == '\r') { - line = newline.replace(newline.size(), 1, "\n"); - } else { - line = newline; - } - - return stream; -} - -std::istream& StreamHandler::get_next_non_blank_line(std::istream& stream, std::string& line) { - bool is_blank = true; - - const std::regex whitespace_re("\\s*(.*)"); - std::smatch match; - - while (is_blank) { - utils::StreamHandler::get_line(stream, line); - - std::regex_search(line, match, whitespace_re); - - if ((!line.empty() && !match.empty()) || (stream.eof())) { - if ((match.length(1) > 0) || (stream.eof())) { - is_blank = false; - } - } - } - - return stream; -} - -std::istream& StreamHandler::skip_to_next_blank_line(std::istream& stream, std::string& line) { - bool line_is_empty = false; - - const std::regex whitespace_re("\\s*(.*)"); - std::smatch match; - - while (!line_is_empty) { - utils::StreamHandler::get_line(stream, line); - - std::regex_search(line, match, whitespace_re); - - if ((match.length(1) == 0) || (stream.eof())) { - line_is_empty = true; - } - } - - return stream; -} - -std::string String::trim(const std::string& line) { - const char* WhiteSpace = " \t\v\r\n"; - std::size_t start = line.find_first_not_of(WhiteSpace); - std::size_t end = line.find_last_not_of(WhiteSpace); - return start == end ? std::string() : line.substr(start, end - start + 1); -} - -double String::convert_to_double(const std::string& value, double default_value) { - double converted_value = default_value; - fast_float::from_chars(value.data(), value.data() + value.size(), converted_value); - return converted_value; -} - -} // Namespace Utils +#include +#include +#include +#include + +#include + +namespace utils { + +std::istream& StreamHandler::get_line(std::istream& stream, std::string& line) { + std::string newline; + + std::getline(stream, newline); + + // Windows CRLF (\r\n) + if (newline.size() && newline[newline.size() - 1] == '\r') { + line = newline.substr(0, newline.size() - 1); + // MacOS LF (\r) + } else if (newline.size() && newline[newline.size()] == '\r') { + line = newline.replace(newline.size(), 1, "\n"); + } else { + line = newline; + } + + return stream; +} + +std::istream& StreamHandler::get_next_non_blank_line(std::istream& stream, std::string& line) { + bool is_blank = true; + + const std::regex whitespace_re("\\s*(.*)"); + std::smatch match; + + while (is_blank) { + utils::StreamHandler::get_line(stream, line); + + std::regex_search(line, match, whitespace_re); + + if ((!line.empty() && !match.empty()) || (stream.eof())) { + if ((match.length(1) > 0) || (stream.eof())) { + is_blank = false; + } + } + } + + return stream; +} + +std::istream& StreamHandler::skip_to_next_blank_line(std::istream& stream, std::string& line) { + bool line_is_empty = false; + + const std::regex whitespace_re("\\s*(.*)"); + std::smatch match; + + while (!line_is_empty) { + utils::StreamHandler::get_line(stream, line); + + std::regex_search(line, match, whitespace_re); + + if ((match.length(1) == 0) || (stream.eof())) { + line_is_empty = true; + } + } + + return stream; +} + +std::string String::trim(const std::string& line) { + const char* WhiteSpace = " \t\v\r\n"; + std::size_t start = line.find_first_not_of(WhiteSpace); + std::size_t end = line.find_last_not_of(WhiteSpace); + return start == end ? std::string() : line.substr(start, end - start + 1); +} + +double String::convert_to_double(const std::string& value, double default_value) { + double converted_value = default_value; + fast_float::from_chars(value.data(), value.data() + value.size(), converted_value); + return converted_value; +} + +} // Namespace Utils diff --git a/test/test_dbc.cpp b/test/test_dbc.cpp index 508df5c..ff0645f 100644 --- a/test/test_dbc.cpp +++ b/test/test_dbc.cpp @@ -1,207 +1,207 @@ -#include "testing_utils/common.hpp" -#include "testing_utils/defines.hpp" -#include -#include -#include -#include -#include - -TEST_CASE("Testing dbc file loading error issues", "[fileio][error]") { - auto parser = std::unique_ptr(new libdbc::DbcParser()); - - SECTION("Loading a non dbc file should throw an error", "[error]") { - REQUIRE_THROWS_AS(parser->parse_file(TEXT_FILE), libdbc::validity_error); - } - - SECTION("Loading a dbc with bad headers throws an error", "[error]") { - REQUIRE_THROWS_AS(parser->parse_file(MISSING_VERSION_DBC_FILE), libdbc::validity_error); - } - - SECTION("Loading a dbc without the required bit timing section (BS_:)", "[error]") { - REQUIRE_THROWS_AS(parser->parse_file(MISSING_BIT_TIMING_DBC_FILE), libdbc::validity_error); - } - - SECTION("Loading a dbc with some missing namespace section tags (NS_ :)", "[error]") { - // Confusion about this type of error. it appears that the header isn't - // very well standardized for now we ignore this type of error. - CHECK_NOTHROW(parser->parse_file(MISSING_NEW_SYMBOLS_DBC_FILE)); - } - - SECTION("Verify that what() method is accessible for all exceptions", "[error]") { - auto generic_error = libdbc::exception(); - REQUIRE(std::string{generic_error.what()} == "libdbc exception occurred"); - - auto validity_check = libdbc::validity_error(); - REQUIRE(std::string{validity_check.what()} == "Invalid DBC file"); - } -} - -TEST_CASE("Testing dbc file loading", "[fileio]") { - auto parser = std::unique_ptr(new libdbc::DbcParser()); - - SECTION("Loading a single simple dbc file", "[dbc]") { - std::vector nodes = {"DBG", "DRIVER", "IO", "MOTOR", "SENSOR"}; - - libdbc::Message msg(500, "IO_DEBUG", 4, "IO"); - - std::vector receivers{"DBG"}; - libdbc::Signal sig("IO_DEBUG_test_unsigned", false, 0, 8, false, false, 1, 0, 0, 0, "", receivers); - msg.appendSignal(sig); - - std::vector msgs = {msg}; - - parser->parse_file(SIMPLE_DBC_FILE); - - REQUIRE(parser->get_version() == "1.0.0"); - - REQUIRE(parser->get_nodes() == nodes); - - REQUIRE(parser->get_messages() == msgs); - - REQUIRE(parser->get_messages().front().getSignals() == msg.getSignals()); - } -} - -TEST_CASE("Testing big endian, little endian") { +#include "testing_utils/common.hpp" +#include "testing_utils/defines.hpp" +#include +#include +#include +#include +#include + +TEST_CASE("Testing dbc file loading error issues", "[fileio][error]") { + auto parser = std::unique_ptr(new libdbc::DbcParser()); + + SECTION("Loading a non dbc file should throw an error", "[error]") { + REQUIRE_THROWS_AS(parser->parse_file(TEXT_FILE), libdbc::validity_error); + } + + SECTION("Loading a dbc with bad headers throws an error", "[error]") { + REQUIRE_THROWS_AS(parser->parse_file(MISSING_VERSION_DBC_FILE), libdbc::validity_error); + } + + SECTION("Loading a dbc without the required bit timing section (BS_:)", "[error]") { + REQUIRE_THROWS_AS(parser->parse_file(MISSING_BIT_TIMING_DBC_FILE), libdbc::validity_error); + } + + SECTION("Loading a dbc with some missing namespace section tags (NS_ :)", "[error]") { + // Confusion about this type of error. it appears that the header isn't + // very well standardized for now we ignore this type of error. + CHECK_NOTHROW(parser->parse_file(MISSING_NEW_SYMBOLS_DBC_FILE)); + } + + SECTION("Verify that what() method is accessible for all exceptions", "[error]") { + auto generic_error = libdbc::exception(); + REQUIRE(std::string{generic_error.what()} == "libdbc exception occurred"); + + auto validity_check = libdbc::validity_error(); + REQUIRE(std::string{validity_check.what()} == "Invalid DBC file"); + } +} + +TEST_CASE("Testing dbc file loading", "[fileio]") { + auto parser = std::unique_ptr(new libdbc::DbcParser()); + + SECTION("Loading a single simple dbc file", "[dbc]") { + std::vector nodes = {"DBG", "DRIVER", "IO", "MOTOR", "SENSOR"}; + + libdbc::Message msg(500, "IO_DEBUG", 4, "IO"); + + std::vector receivers{"DBG"}; + libdbc::Signal sig("IO_DEBUG_test_unsigned", false, 0, 8, false, false, 1, 0, 0, 0, "", receivers); + msg.appendSignal(sig); + + std::vector msgs = {msg}; + + parser->parse_file(SIMPLE_DBC_FILE); + + REQUIRE(parser->get_version() == "1.0.0"); + + REQUIRE(parser->get_nodes() == nodes); + + REQUIRE(parser->get_messages() == msgs); + + REQUIRE(parser->get_messages().front().getSignals() == msg.getSignals()); + } +} + +TEST_CASE("Testing big endian, little endian") { std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 234 MSG1: 8 Vector__XXX SG_ Sig1 : 55|16@0- (0.1,0) [-3276.8|-3276.7] "C" Vector__XXX - SG_ Sig2 : 39|16@1- (0.1,0) [-3276.8|-3276.7] "C" Vector__XXX)"; - const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); - - auto parser = libdbc::DbcParser(); - parser.parse_file(filename.c_str()); - - REQUIRE(parser.get_messages().size() == 1); - REQUIRE(parser.get_messages().at(0).name() == "MSG1"); - REQUIRE(parser.get_messages().at(0).size() == 8); - REQUIRE(parser.get_messages().at(0).getSignals().size() == 2); - { - const auto signal = parser.get_messages().at(0).getSignals().at(0); - REQUIRE(signal.is_bigendian == true); - } - { - const auto signal = parser.get_messages().at(0).getSignals().at(1); - REQUIRE(signal.is_bigendian == false); - } -} - -TEST_CASE("Testing negative values") { + SG_ Sig2 : 39|16@1- (0.1,0) [-3276.8|-3276.7] "C" Vector__XXX)"; + const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); + + auto parser = libdbc::DbcParser(); + parser.parse_file(filename.c_str()); + + REQUIRE(parser.get_messages().size() == 1); + REQUIRE(parser.get_messages().at(0).name() == "MSG1"); + REQUIRE(parser.get_messages().at(0).size() == 8); + REQUIRE(parser.get_messages().at(0).getSignals().size() == 2); + { + const auto signal = parser.get_messages().at(0).getSignals().at(0); + REQUIRE(signal.is_bigendian == true); + } + { + const auto signal = parser.get_messages().at(0).getSignals().at(1); + REQUIRE(signal.is_bigendian == false); + } +} + +TEST_CASE("Testing negative values") { std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 234 MSG1: 58 Vector__XXX SG_ Sig1 : 55|16@0- (0.1,0) [-3276.8|-3276.7] "C" Vector__XXX SG_ Sig2 : 39|16@0- (0.1,0) [-3276.8|-3276.7] "C" Vector__XXX SG_ Sig3 : 23|16@0- (10,0) [-3276.8|-3276.7] "C" Vector__XXX - SG_ Sig4 : 7|16@0- (1,-10) [0|32767] "" Vector__XXX)"; - const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); - - auto parser = libdbc::DbcParser(); - parser.parse_file(filename.c_str()); - - REQUIRE(parser.get_messages().size() == 1); - REQUIRE(parser.get_messages().at(0).name() == "MSG1"); - REQUIRE(parser.get_messages().at(0).size() == 58); - REQUIRE(parser.get_messages().at(0).getSignals().size() == 4); - - SECTION("Evaluating first message") { - const auto signal = parser.get_messages().at(0).getSignals().at(0); - REQUIRE(signal.factor == 0.1); - REQUIRE(signal.offset == 0); - REQUIRE(signal.min == -3276.8); - REQUIRE(signal.max == -3276.7); - } - SECTION("Evaluating second message") { - const auto signal = parser.get_messages().at(0).getSignals().at(1); - REQUIRE(signal.factor == 0.1); - REQUIRE(signal.offset == 0); - REQUIRE(signal.min == -3276.8); - REQUIRE(signal.max == -3276.7); - } - SECTION("Evaluating third message") { - const auto signal = parser.get_messages().at(0).getSignals().at(2); - REQUIRE(signal.factor == 10); - REQUIRE(signal.offset == 0); - REQUIRE(signal.min == -3276.8); - REQUIRE(signal.max == -3276.7); - } - SECTION("Evaluating fourth message") { - const auto signal = parser.get_messages().at(0).getSignals().at(3); - REQUIRE(signal.factor == 1); - REQUIRE(signal.offset == -10); - REQUIRE(signal.min == 0); - REQUIRE(signal.max == 32767); - } -} - -TEST_CASE("Special characters in unit") { + SG_ Sig4 : 7|16@0- (1,-10) [0|32767] "" Vector__XXX)"; + const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); + + auto parser = libdbc::DbcParser(); + parser.parse_file(filename.c_str()); + + REQUIRE(parser.get_messages().size() == 1); + REQUIRE(parser.get_messages().at(0).name() == "MSG1"); + REQUIRE(parser.get_messages().at(0).size() == 58); + REQUIRE(parser.get_messages().at(0).getSignals().size() == 4); + + SECTION("Evaluating first message") { + const auto signal = parser.get_messages().at(0).getSignals().at(0); + REQUIRE(signal.factor == 0.1); + REQUIRE(signal.offset == 0); + REQUIRE(signal.min == -3276.8); + REQUIRE(signal.max == -3276.7); + } + SECTION("Evaluating second message") { + const auto signal = parser.get_messages().at(0).getSignals().at(1); + REQUIRE(signal.factor == 0.1); + REQUIRE(signal.offset == 0); + REQUIRE(signal.min == -3276.8); + REQUIRE(signal.max == -3276.7); + } + SECTION("Evaluating third message") { + const auto signal = parser.get_messages().at(0).getSignals().at(2); + REQUIRE(signal.factor == 10); + REQUIRE(signal.offset == 0); + REQUIRE(signal.min == -3276.8); + REQUIRE(signal.max == -3276.7); + } + SECTION("Evaluating fourth message") { + const auto signal = parser.get_messages().at(0).getSignals().at(3); + REQUIRE(signal.factor == 1); + REQUIRE(signal.offset == -10); + REQUIRE(signal.min == 0); + REQUIRE(signal.max == 32767); + } +} + +TEST_CASE("Special characters in unit") { std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 234 MSG1: 255 Vector__XXX - SG_ Speed : 0|8@1+ (1,0) [0|204] "Km/h" DEVICE1,DEVICE2,DEVICE3)"; - const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); - - auto parser = libdbc::DbcParser(); - parser.parse_file(filename.c_str()); - - REQUIRE(parser.get_messages().size() == 1); - REQUIRE(parser.get_messages().at(0).name() == "MSG1"); - REQUIRE(parser.get_messages().at(0).size() == 255); - REQUIRE(parser.get_messages().at(0).getSignals().size() == 1); - SECTION("Checking that signal with special characters as unit is parsed correctly") { - const auto signal = parser.get_messages().at(0).getSignals().at(0); - REQUIRE(signal.unit.compare("Km/h") == 0); - } -} - -TEST_CASE("Signal Value Description") { + SG_ Speed : 0|8@1+ (1,0) [0|204] "Km/h" DEVICE1,DEVICE2,DEVICE3)"; + const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); + + auto parser = libdbc::DbcParser(); + parser.parse_file(filename.c_str()); + + REQUIRE(parser.get_messages().size() == 1); + REQUIRE(parser.get_messages().at(0).name() == "MSG1"); + REQUIRE(parser.get_messages().at(0).size() == 255); + REQUIRE(parser.get_messages().at(0).getSignals().size() == 1); + SECTION("Checking that signal with special characters as unit is parsed correctly") { + const auto signal = parser.get_messages().at(0).getSignals().at(0); + REQUIRE(signal.unit.compare("Km/h") == 0); + } +} + +TEST_CASE("Signal Value Description") { std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 234 MSG1: 8 Vector__XXX SG_ State1 : 0|8@1+ (1,0) [0|200] "Km/h" DEVICE1,DEVICE2,DEVICE3 SG_ State2 : 0|8@1+ (1,0) [0|204] "" DEVICE1,DEVICE2,DEVICE3 -VAL_ 234 State1 123 "Description 1" 0 "Description 2" 90903489 "Big value and special characters &$§())!" ;)"; - const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); - - auto parser = libdbc::DbcParser(); - parser.parse_file(filename.c_str()); - - REQUIRE(parser.get_messages().size() == 1); - REQUIRE(parser.get_messages().at(0).name() == "MSG1"); - REQUIRE(parser.get_messages().at(0).getSignals().size() == 2); - - REQUIRE(parser.get_messages().at(0).getSignals().at(0).svDescriptions.size() == 3); - REQUIRE(parser.get_messages().at(0).getSignals().at(1).svDescriptions.size() == 0); - - const auto signal = parser.get_messages().at(0).getSignals().at(0); - REQUIRE(signal.svDescriptions.at(0).value == 123); - REQUIRE(signal.svDescriptions.at(0).description == "Description 1"); - REQUIRE(signal.svDescriptions.at(1).value == 0); - REQUIRE(signal.svDescriptions.at(1).description == "Description 2"); - REQUIRE(signal.svDescriptions.at(2).value == 90903489); - REQUIRE(signal.svDescriptions.at(2).description == "Big value and special characters &$§())!"); -} - -TEST_CASE("Signal Value Description Extended CAN id") { +VAL_ 234 State1 123 "Description 1" 0 "Description 2" 90903489 "Big value and special characters &$§())!" ;)"; + const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); + + auto parser = libdbc::DbcParser(); + parser.parse_file(filename.c_str()); + + REQUIRE(parser.get_messages().size() == 1); + REQUIRE(parser.get_messages().at(0).name() == "MSG1"); + REQUIRE(parser.get_messages().at(0).getSignals().size() == 2); + + REQUIRE(parser.get_messages().at(0).getSignals().at(0).svDescriptions.size() == 3); + REQUIRE(parser.get_messages().at(0).getSignals().at(1).svDescriptions.size() == 0); + + const auto signal = parser.get_messages().at(0).getSignals().at(0); + REQUIRE(signal.svDescriptions.at(0).value == 123); + REQUIRE(signal.svDescriptions.at(0).description == "Description 1"); + REQUIRE(signal.svDescriptions.at(1).value == 0); + REQUIRE(signal.svDescriptions.at(1).description == "Description 2"); + REQUIRE(signal.svDescriptions.at(2).value == 90903489); + REQUIRE(signal.svDescriptions.at(2).description == "Big value and special characters &$§())!"); +} + +TEST_CASE("Signal Value Description Extended CAN id") { std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 3221225472 MSG1: 8 Vector__XXX SG_ State1 : 0|8@1+ (1,0) [0|200] "Km/h" DEVICE1,DEVICE2,DEVICE3 SG_ State2 : 0|8@1+ (1,0) [0|204] "" DEVICE1,DEVICE2,DEVICE3 -VAL_ 3221225472 State1 123 "Description 1" 0 "Description 2" 4000000000 "Big value and special characters &$§())!" ;)"; - const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); - - auto parser = libdbc::DbcParser(); - parser.parse_file(filename.c_str()); - - REQUIRE(parser.get_messages().size() == 1); - REQUIRE(parser.get_messages().at(0).name() == "MSG1"); - REQUIRE(parser.get_messages().at(0).getSignals().size() == 2); - - REQUIRE(parser.get_messages().at(0).getSignals().at(0).svDescriptions.size() == 3); - REQUIRE(parser.get_messages().at(0).getSignals().at(1).svDescriptions.size() == 0); - - const auto signal = parser.get_messages().at(0).getSignals().at(0); - REQUIRE(signal.svDescriptions.at(0).value == 123); - REQUIRE(signal.svDescriptions.at(0).description == "Description 1"); - REQUIRE(signal.svDescriptions.at(1).value == 0); - REQUIRE(signal.svDescriptions.at(1).description == "Description 2"); - REQUIRE(signal.svDescriptions.at(2).value == 4000000000); - REQUIRE(signal.svDescriptions.at(2).description == "Big value and special characters &$§())!"); -} - -TEST_CASE("Signal Value Multiple VAL_") { +VAL_ 3221225472 State1 123 "Description 1" 0 "Description 2" 4000000000 "Big value and special characters &$§())!" ;)"; + const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); + + auto parser = libdbc::DbcParser(); + parser.parse_file(filename.c_str()); + + REQUIRE(parser.get_messages().size() == 1); + REQUIRE(parser.get_messages().at(0).name() == "MSG1"); + REQUIRE(parser.get_messages().at(0).getSignals().size() == 2); + + REQUIRE(parser.get_messages().at(0).getSignals().at(0).svDescriptions.size() == 3); + REQUIRE(parser.get_messages().at(0).getSignals().at(1).svDescriptions.size() == 0); + + const auto signal = parser.get_messages().at(0).getSignals().at(0); + REQUIRE(signal.svDescriptions.at(0).value == 123); + REQUIRE(signal.svDescriptions.at(0).description == "Description 1"); + REQUIRE(signal.svDescriptions.at(1).value == 0); + REQUIRE(signal.svDescriptions.at(1).description == "Description 2"); + REQUIRE(signal.svDescriptions.at(2).value == 4000000000); + REQUIRE(signal.svDescriptions.at(2).description == "Big value and special characters &$§())!"); +} + +TEST_CASE("Signal Value Multiple VAL_") { std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 3221225472 MSG1: 8 Vector__XXX SG_ State1 : 0|8@1+ (1,0) [0|200] "Km/h" DEVICE1,DEVICE2,DEVICE3 SG_ State2 : 0|8@1+ (1,0) [0|204] "" DEVICE1,DEVICE2,DEVICE3" @@ -209,32 +209,32 @@ BO_ 123 MSG2: 8 Vector__XXX SG_ State1 : 0|8@1+ (1,0) [0|200] "Km/h" DEVICE1,DEVICE2,DEVICE3 SG_ State2 : 0|8@1+ (1,0) [0|204] "" DEVICE1,DEVICE2,DEVICE3 VAL_ 3221225472 State1 123 "Description 1" 0 "Description 2" ; -VAL_ 123 State1 123 "Description 3" 0 "Description 4" ;)"; - const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); - - auto parser = libdbc::DbcParser(); - parser.parse_file(filename.c_str()); - - REQUIRE(parser.get_messages().size() == 2); - REQUIRE(parser.get_messages().at(0).name() == "MSG1"); - REQUIRE(parser.get_messages().at(1).name() == "MSG2"); - - REQUIRE(parser.get_messages().at(0).getSignals().size() == 2); - - REQUIRE(parser.get_messages().at(0).getSignals().at(0).svDescriptions.size() == 2); - REQUIRE(parser.get_messages().at(0).getSignals().at(1).svDescriptions.size() == 0); - REQUIRE(parser.get_messages().at(1).getSignals().at(0).svDescriptions.size() == 2); - REQUIRE(parser.get_messages().at(1).getSignals().at(1).svDescriptions.size() == 0); - - const auto signal = parser.get_messages().at(0).getSignals().at(0); - REQUIRE(signal.svDescriptions.at(0).value == 123); - REQUIRE(signal.svDescriptions.at(0).description == "Description 1"); - REQUIRE(signal.svDescriptions.at(1).value == 0); - REQUIRE(signal.svDescriptions.at(1).description == "Description 2"); - - const auto signal2 = parser.get_messages().at(1).getSignals().at(0); - REQUIRE(signal2.svDescriptions.at(0).value == 123); - REQUIRE(signal2.svDescriptions.at(0).description == "Description 3"); - REQUIRE(signal2.svDescriptions.at(1).value == 0); - REQUIRE(signal2.svDescriptions.at(1).description == "Description 4"); -} +VAL_ 123 State1 123 "Description 3" 0 "Description 4" ;)"; + const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); + + auto parser = libdbc::DbcParser(); + parser.parse_file(filename.c_str()); + + REQUIRE(parser.get_messages().size() == 2); + REQUIRE(parser.get_messages().at(0).name() == "MSG1"); + REQUIRE(parser.get_messages().at(1).name() == "MSG2"); + + REQUIRE(parser.get_messages().at(0).getSignals().size() == 2); + + REQUIRE(parser.get_messages().at(0).getSignals().at(0).svDescriptions.size() == 2); + REQUIRE(parser.get_messages().at(0).getSignals().at(1).svDescriptions.size() == 0); + REQUIRE(parser.get_messages().at(1).getSignals().at(0).svDescriptions.size() == 2); + REQUIRE(parser.get_messages().at(1).getSignals().at(1).svDescriptions.size() == 0); + + const auto signal = parser.get_messages().at(0).getSignals().at(0); + REQUIRE(signal.svDescriptions.at(0).value == 123); + REQUIRE(signal.svDescriptions.at(0).description == "Description 1"); + REQUIRE(signal.svDescriptions.at(1).value == 0); + REQUIRE(signal.svDescriptions.at(1).description == "Description 2"); + + const auto signal2 = parser.get_messages().at(1).getSignals().at(0); + REQUIRE(signal2.svDescriptions.at(0).value == 123); + REQUIRE(signal2.svDescriptions.at(0).description == "Description 3"); + REQUIRE(signal2.svDescriptions.at(1).value == 0); + REQUIRE(signal2.svDescriptions.at(1).description == "Description 4"); +} diff --git a/test/test_utils.cpp b/test/test_utils.cpp index ea3d594..fe7a064 100644 --- a/test/test_utils.cpp +++ b/test/test_utils.cpp @@ -1,37 +1,37 @@ -#include "testing_utils/defines.hpp" -#include -#include - -#include - -using namespace utils; - -TEST_CASE("Basic file input with safe get_line that is non line ending specific", "") { - SECTION("Verify various line ending input files") { - std::ifstream TextFile; - std::string test; - - TextFile.open(TEXT_FILE, std::ios::in); - CHECK(TextFile.is_open()); - - if (TextFile.is_open()) { - StreamHandler::get_line(TextFile, test); - REQUIRE(test == "This is a non dbc formatted file."); - StreamHandler::get_line(TextFile, test); - REQUIRE(test == ""); - StreamHandler::get_line(TextFile, test); - REQUIRE(test == "Make sure things pass with this"); - StreamHandler::get_line(TextFile, test); - REQUIRE(test == "Who knows what might happen."); - - TextFile.close(); - } - } -} - -TEST_CASE("Test line finding utility functions", "") { - std::string line; - std::string test_string = +#include "testing_utils/defines.hpp" +#include +#include + +#include + +using namespace utils; + +TEST_CASE("Basic file input with safe get_line that is non line ending specific", "") { + SECTION("Verify various line ending input files") { + std::ifstream TextFile; + std::string test; + + TextFile.open(TEXT_FILE, std::ios::in); + CHECK(TextFile.is_open()); + + if (TextFile.is_open()) { + StreamHandler::get_line(TextFile, test); + REQUIRE(test == "This is a non dbc formatted file."); + StreamHandler::get_line(TextFile, test); + REQUIRE(test == ""); + StreamHandler::get_line(TextFile, test); + REQUIRE(test == "Make sure things pass with this"); + StreamHandler::get_line(TextFile, test); + REQUIRE(test == "Who knows what might happen."); + + TextFile.close(); + } + } +} + +TEST_CASE("Test line finding utility functions", "") { + std::string line; + std::string test_string = "hello\n\ \n\ \n\ @@ -41,53 +41,53 @@ maybe not this one either\n\ \n\ Someone wrote something....\n\ b\n\ -end"; - - std::istringstream stream(test_string); - - SECTION("Test skipping empty lines") { - StreamHandler::get_line(stream, line); - - CHECK(line == "hello"); - - StreamHandler::get_next_non_blank_line(stream, line); - REQUIRE(line == "this is not blank"); - - StreamHandler::skip_to_next_blank_line(stream, line); - REQUIRE(line == ""); - - StreamHandler::get_next_non_blank_line(stream, line); - REQUIRE(line == "Someone wrote something...."); - - StreamHandler::get_next_non_blank_line(stream, line); - REQUIRE(line == " b"); - - StreamHandler::get_next_non_blank_line(stream, line); - REQUIRE(line == "end"); - - SECTION("Test end of the files", "[edge case]") { - StreamHandler::get_next_non_blank_line(stream, line); - REQUIRE(line == ""); - - StreamHandler::skip_to_next_blank_line(stream, line); - REQUIRE(line == ""); - } - } -} - -TEST_CASE("Test the string trim feature", "[string]") { - std::string s = " there might be some white space.... "; - - REQUIRE(String::trim(s) == "there might be some white space...."); -} - -TEST_CASE("Test string split feature", "[string]") { - std::string s = "name1 name2 name3 name4 name5 "; - std::vector vs = {"name1", "name2", "name3", "name4", "name5"}; - - std::vector v; - - String::split(s, v); - - REQUIRE(v == vs); -} +end"; + + std::istringstream stream(test_string); + + SECTION("Test skipping empty lines") { + StreamHandler::get_line(stream, line); + + CHECK(line == "hello"); + + StreamHandler::get_next_non_blank_line(stream, line); + REQUIRE(line == "this is not blank"); + + StreamHandler::skip_to_next_blank_line(stream, line); + REQUIRE(line == ""); + + StreamHandler::get_next_non_blank_line(stream, line); + REQUIRE(line == "Someone wrote something...."); + + StreamHandler::get_next_non_blank_line(stream, line); + REQUIRE(line == " b"); + + StreamHandler::get_next_non_blank_line(stream, line); + REQUIRE(line == "end"); + + SECTION("Test end of the files", "[edge case]") { + StreamHandler::get_next_non_blank_line(stream, line); + REQUIRE(line == ""); + + StreamHandler::skip_to_next_blank_line(stream, line); + REQUIRE(line == ""); + } + } +} + +TEST_CASE("Test the string trim feature", "[string]") { + std::string s = " there might be some white space.... "; + + REQUIRE(String::trim(s) == "there might be some white space...."); +} + +TEST_CASE("Test string split feature", "[string]") { + std::string s = "name1 name2 name3 name4 name5 "; + std::vector vs = {"name1", "name2", "name3", "name4", "name5"}; + + std::vector v; + + String::split(s, v); + + REQUIRE(v == vs); +} From 604fdafb4be8ddb8ae1b100b197d6464007a5939 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Fri, 15 Mar 2024 21:40:43 -0400 Subject: [PATCH 092/131] fix(utils): cleaned up clang-tidy warnings in utils.cpp --- src/utils.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/utils.cpp b/src/utils.cpp index ed715cb..d2ea6b7 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -13,10 +13,10 @@ std::istream& StreamHandler::get_line(std::istream& stream, std::string& line) { std::getline(stream, newline); // Windows CRLF (\r\n) - if (newline.size() && newline[newline.size() - 1] == '\r') { + if (!newline.empty() && newline[newline.size() - 1] == '\r') { line = newline.substr(0, newline.size() - 1); // MacOS LF (\r) - } else if (newline.size() && newline[newline.size()] == '\r') { + } else if (!newline.empty() && newline[newline.size()] == '\r') { line = newline.replace(newline.size(), 1, "\n"); } else { line = newline; @@ -74,7 +74,9 @@ std::string String::trim(const std::string& line) { double String::convert_to_double(const std::string& value, double default_value) { double converted_value = default_value; - fast_float::from_chars(value.data(), value.data() + value.size(), converted_value); + auto begin = value.begin(); + auto end = value.end(); + fast_float::from_chars(&(*begin), &(*end), converted_value); return converted_value; } From b138a2f0ad2d40a50e3106b6ed9dac3f86a9b353 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sat, 16 Mar 2024 12:07:19 -0400 Subject: [PATCH 093/131] fix(clang-tidy): Fixing the warning from clang-tidy of signal and message source files --- include/libdbc/message.hpp | 2 +- src/message.cpp | 69 +++++++++++++++++++++----------------- src/signal.cpp | 4 +-- 3 files changed, 41 insertions(+), 34 deletions(-) diff --git a/include/libdbc/message.hpp b/include/libdbc/message.hpp index a018a31..05bd022 100644 --- a/include/libdbc/message.hpp +++ b/include/libdbc/message.hpp @@ -24,7 +24,7 @@ struct Message { ParseSignalsStatus parseSignals(const std::vector& data, std::vector& values) const; void appendSignal(const Signal& signal); - const std::vector getSignals() const; + std::vector getSignals() const; uint32_t id() const; uint8_t size() const; const std::string& name() const; diff --git a/src/message.cpp b/src/message.cpp index 89b47ac..791ecc9 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -1,10 +1,17 @@ -#include #include #include namespace libdbc { -Message::Message(uint32_t id, const std::string& name, uint8_t size, const std::string& node) - : m_id(id) + +constexpr unsigned ONE_BYTE = 8; +constexpr unsigned TWO_BYTES = 16; +constexpr unsigned FOUR_BYTES = 32; +constexpr unsigned EIGHT_BYTES = 64; + +constexpr unsigned SEVEN_BITS = 7; + +Message::Message(uint32_t message_id, const std::string& name, uint8_t size, const std::string& node) + : m_id(message_id) , m_name(name) , m_size(size) , m_node(node) { @@ -16,52 +23,52 @@ bool Message::operator==(const Message& rhs) const { Message::ParseSignalsStatus Message::parseSignals(const std::vector& data, std::vector& values) const { auto size = data.size(); - if (size > 8) { + if (size > ONE_BYTE) { return ParseSignalsStatus::ErrorMessageToLong; // not supported yet } uint64_t data_little_endian = 0; uint64_t data_big_endian = 0; for (size_t i = 0; i < size; i++) { - data_little_endian |= ((uint64_t)data[i]) << i * 8; - data_big_endian = (data_big_endian << 8) | (uint64_t)data[i]; + data_little_endian |= ((uint64_t)data[i]) << i * ONE_BYTE; + data_big_endian = (data_big_endian << ONE_BYTE) | (uint64_t)data[i]; } // TODO: does this also work on a big endian machine? const auto len = size * 8; - uint64_t v = 0; + uint64_t value = 0; for (const auto& signal : m_signals) { if (signal.is_bigendian) { - uint32_t start_bit = 8 * (signal.start_bit / 8) + (7 - (signal.start_bit % 8)); // Calculation taken from python CAN - v = data_big_endian << start_bit; - v = v >> (len - signal.size); + uint32_t start_bit = ONE_BYTE * (signal.start_bit / ONE_BYTE) + (SEVEN_BITS - (signal.start_bit % ONE_BYTE)); // Calculation taken from python CAN + value = data_big_endian << start_bit; + value = value >> (len - signal.size); } else { - v = data_little_endian >> signal.start_bit; + value = data_little_endian >> signal.start_bit; } if (signal.is_signed && signal.size > 1) { switch (signal.size) { - case 8: - values.push_back(static_cast(v) * signal.factor + signal.offset); + case ONE_BYTE: + values.push_back(static_cast(value) * signal.factor + signal.offset); break; - case 16: - values.push_back(static_cast(v) * signal.factor + signal.offset); + case TWO_BYTES: + values.push_back(static_cast(value) * signal.factor + signal.offset); break; - case 32: - values.push_back(static_cast(v) * signal.factor + signal.offset); + case FOUR_BYTES: + values.push_back(static_cast(value) * signal.factor + signal.offset); break; - case 64: - values.push_back(static_cast(v) * signal.factor + signal.offset); + case EIGHT_BYTES: + values.push_back(static_cast(value) * signal.factor + signal.offset); break; default: { // 2 complement -> decimal - const int negative = (v & (1ull << (signal.size - 1))) != 0; - int64_t nativeInt; - if (negative) { - nativeInt = static_cast(v | ~((1ull << signal.size) - 1)); // invert all bits above signal.size + const bool is_negative = (value & (1ULL << (signal.size - 1))) != 0; + int64_t nativeInt = 0; + if (is_negative) { + nativeInt = static_cast(value | ~((1ULL << signal.size) - 1)); // invert all bits above signal.size } else { - nativeInt = static_cast(v & ((1ull << signal.size) - 1)); // masking + nativeInt = static_cast(value & ((1ULL << signal.size) - 1)); // masking } values.push_back(static_cast(nativeInt) * signal.factor + signal.offset); break; @@ -69,8 +76,8 @@ Message::ParseSignalsStatus Message::parseSignals(const std::vector& da } } else { // use only the relevant bits - v = v & ((1 << signal.size) - 1); // masking - values.push_back(static_cast(v) * signal.factor + signal.offset); + value = value & ((1 << signal.size) - 1); // masking + values.push_back(static_cast(value) * signal.factor + signal.offset); } } return ParseSignalsStatus::Success; @@ -80,7 +87,7 @@ void Message::appendSignal(const Signal& signal) { m_signals.push_back(signal); } -const std::vector Message::getSignals() const { +std::vector Message::getSignals() const { return m_signals; } @@ -96,10 +103,10 @@ const std::string& Message::name() const { return m_name; } -void Message::addValueDescription(const std::string& signal_name, const std::vector& vd) { - for (auto& s : m_signals) { - if (s.name.compare(signal_name) == 0) { - s.svDescriptions = vd; +void Message::addValueDescription(const std::string& signal_name, const std::vector& value_descriptor) { + for (auto& signal : m_signals) { + if (signal.name == signal_name) { + signal.svDescriptions = value_descriptor; return; } } diff --git a/src/signal.cpp b/src/signal.cpp index b9ce591..edb8407 100644 --- a/src/signal.cpp +++ b/src/signal.cpp @@ -47,8 +47,8 @@ std::ostream& operator<<(std::ostream& out, const Signal& sig) { out << "Min: " << sig.min << ", Max: " << sig.max << ", "; out << "Unit: (" << sig.unit << "), "; out << "receivers: "; - for (const auto& r : sig.receivers) { - out << r; + for (const auto& reciever : sig.receivers) { + out << reciever; } return out << "}"; } From 694a835a295dcd888a28b45dc2cdfa5daf4e8849 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sat, 16 Mar 2024 12:28:15 -0400 Subject: [PATCH 094/131] fix(dbc): cleaning up magic numbers and short variable names in dbc.cpp --- src/dbc.cpp | 173 +++++++++++++++++++++++++++++----------------------- 1 file changed, 96 insertions(+), 77 deletions(-) diff --git a/src/dbc.cpp b/src/dbc.cpp index d78c32e..7eec99a 100644 --- a/src/dbc.cpp +++ b/src/dbc.cpp @@ -17,14 +17,33 @@ const auto byteOrderPattern = "([0-1])"; const auto signPattern = "(\\+|\\-)"; const auto scalePattern = "(\\d+\\.?(\\d+)?)"; // Non negative float const auto offsetPattern = floatPattern; +// NOLINTNEXTLINE -- Disable warning for runtime initialization and can throw. Can't fix until newer c++ version with constexpr const auto offsetScalePattern = std::string("\\(") + scalePattern + "\\," + offsetPattern + "\\)"; const auto minPattern = floatPattern; const auto maxPattern = floatPattern; +// NOLINTNEXTLINE -- Disable warning for runtime initialization and can throw. Can't fix until newer c++ version with constexpr const auto minMaxPattern = std::string("\\[") + minPattern + "\\|" + maxPattern + "\\]"; const auto unitPattern = "\"(.*)\""; // Random string const auto receiverPattern = "([\\w\\,]+|Vector__XXX)*"; const auto whiteSpace = "\\s"; +constexpr unsigned SIGNAL_NAME_GROUP = 2; +constexpr unsigned SIGNAL_START_BIT_GROUP = 3; +constexpr unsigned SIGNAL_SIZE_GROUP = 4; +constexpr unsigned SIGNAL_ENDIAN_GROUP = 5; +constexpr unsigned SIGNAL_SIGNED_GROUP = 6; +constexpr unsigned SIGNAL_FACTOR_GROUP = 7; +constexpr unsigned SIGNAL_OFFSET_GROUP = 9; +constexpr unsigned SIGNAL_MIN_GROUP = 11; +constexpr unsigned SIGNAL_MAX_GROUP = 13; +constexpr unsigned SIGNAL_UNIT_GROUP = 15; +constexpr unsigned SIGNAL_RECIEVER_GROUP = 16; + +constexpr unsigned MESSAGE_ID_GROUP = 2; +constexpr unsigned MESSAGE_NAME_GROUP = 3; +constexpr unsigned MESSAGE_SIZE_GROUP = 4; +constexpr unsigned MESSAGE_NODE_GROUP = 5; + enum VALToken { Identifier = 0, CANId, SignalName, Value, Description }; struct VALObject { @@ -33,81 +52,83 @@ struct VALObject { std::vector vd; }; -static bool parseVal(const std::string& str, VALObject& obj); -bool parseVal(const std::string& str, VALObject& obj) { +static bool parse_value(const std::string& str, VALObject& obj); + +bool parse_value(const std::string& str, VALObject& obj) { obj.signal_name = ""; obj.vd.clear(); auto state = Identifier; - const char* a = str.data(); - Signal::SignalValueDescriptions vd; + const char* value_data = str.data(); + Signal::SignalValueDescriptions value_description; for (;;) { switch (state) { case Identifier: { - if (*a != 'V') { + if (*value_data != 'V') { return false; } - a++; - if (*a != 'A') { + value_data++; + if (*value_data != 'A') { return false; } - a++; - if (*a != 'L') { + value_data++; + if (*value_data != 'L') { return false; } - a++; - if (*a != '_') { + value_data++; + if (*value_data != '_') { return false; } - a++; - if (*a != ' ') { + value_data++; + if (*value_data != ' ') { return false; } - a++; // skip whitespace + value_data++; // skip whitespace state = CANId; break; } case CANId: { std::string can_id_str; - while (*a >= '0' && *a <= '9') { - can_id_str += *a; - a++; + while (*value_data >= '0' && *value_data <= '9') { + can_id_str += *value_data; + value_data++; } if (can_id_str.empty()) { return false; } obj.can_id = static_cast(std::stoul(can_id_str)); - if (*a != ' ') { + if (*value_data != ' ') { return false; } - a++; // skip whitespace + value_data++; // skip whitespace state = SignalName; break; } case SignalName: { - if ((*a >= 'a' && *a <= 'z') || (*a >= 'A' && *a <= 'Z') || *a == '_') { - obj.signal_name += *a; + if ((*value_data >= 'a' && *value_data <= 'z') || (*value_data >= 'A' && *value_data <= 'Z') || *value_data == '_') { + obj.signal_name += *value_data; } else { return false; } - a++; - while ((*a >= 'a' && *a <= 'z') || (*a >= 'A' && *a <= 'Z') || *a == '_' || (*a >= '0' && *a <= '9')) { - obj.signal_name += *a; - a++; + value_data++; + while ((*value_data >= 'a' && *value_data <= 'z') || (*value_data >= 'A' && *value_data <= 'Z') || *value_data == '_' + || (*value_data >= '0' && *value_data <= '9')) { + obj.signal_name += *value_data; + value_data++; } - if (*a != ' ') { + if (*value_data != ' ') { return false; } - a++; // skip whitespace + value_data++; // skip whitespace state = Value; break; } case Value: { std::string value_str; - while (*a >= '0' && *a <= '9') { - value_str += *a; - a++; + while (*value_data >= '0' && *value_data <= '9') { + value_str += *value_data; + value_data++; } - if (*a == ';') { + if (*value_data == ';') { if (value_str.empty()) { return true; } @@ -117,35 +138,35 @@ bool parseVal(const std::string& str, VALObject& obj) { return false; } - if (*a != ' ') { + if (*value_data != ' ') { return false; } - a++; // skip whitespace - vd.value = (uint32_t)std::stoul(value_str); + value_data++; // skip whitespace + value_description.value = (uint32_t)std::stoul(value_str); state = Description; break; } case Description: { std::string desc; - if (*a != '"') { + if (*value_data != '"') { return false; } - a++; - while (*a != '"' && *a != 0) { - desc += *a; - a++; + value_data++; + while (*value_data != '"' && *value_data != 0) { + desc += *value_data; + value_data++; } - if (*a == 0) { + if (*value_data == 0) { return false; } - a++; - if (*a != ' ') { + value_data++; + if (*value_data != ' ') { return false; } - a++; // skip whitespace + value_data++; // skip whitespace - vd.description = desc; - obj.vd.push_back(vd); + value_description.description = desc; + obj.vd.push_back(value_description); state = Value; break; @@ -156,9 +177,7 @@ bool parseVal(const std::string& str, VALObject& obj) { } DbcParser::DbcParser() - : version("") - , nodes() - , version_re("^(VERSION)\\s\"(.*)\"") + : version_re("^(VERSION)\\s\"(.*)\"") , bit_timing_re("^(BS_:)") , name_space_re("^(NS_)\\s\\:") , node_re("^(BU_:)\\s((?:[\\w]+?\\s?)*)") @@ -171,18 +190,18 @@ DbcParser::DbcParser() } void DbcParser::parse_file(const std::string& file) { - std::ifstream s(file.c_str()); + std::ifstream stream(file.c_str()); std::string line; std::vector lines; messages.clear(); - parse_dbc_header(s); + parse_dbc_header(stream); - parse_dbc_nodes(s); + parse_dbc_nodes(stream); - while (!s.eof()) { - utils::StreamHandler::get_next_non_blank_line(s, line); + while (!stream.eof()) { + utils::StreamHandler::get_next_non_blank_line(stream, line); lines.push_back(line); } @@ -201,9 +220,9 @@ std::vector DbcParser::get_messages() const { return messages; } -Message::ParseSignalsStatus DbcParser::parseMessage(const uint32_t id, const std::vector& data, std::vector& out_values) { +Message::ParseSignalsStatus DbcParser::parseMessage(const uint32_t message_id, const std::vector& data, std::vector& out_values) { for (const auto& message : messages) { - if (message.id() == id) { + if (message.id() == message_id) { return message.parseSignals(data, out_values); } } @@ -242,60 +261,60 @@ void DbcParser::parse_dbc_nodes(std::istream& file_stream) { } if (match.length() > 2) { - std::string n = match.str(2); - utils::String::split(n, nodes); + std::string node = match.str(2); + utils::String::split(node, nodes); } } void DbcParser::parse_dbc_messages(const std::vector& lines) { std::smatch match; - std::vector sv; + std::vector signal_value; VALObject obj{}; for (const auto& line : lines) { if (std::regex_search(line, match, message_re)) { - uint32_t id = static_cast(std::stoul(match.str(2))); - std::string name = match.str(3); - uint8_t size = static_cast(std::stoul(match.str(4))); - std::string node = match.str(5); + uint32_t message_id = static_cast(std::stoul(match.str(MESSAGE_ID_GROUP))); + std::string name = match.str(MESSAGE_NAME_GROUP); + uint8_t size = static_cast(std::stoul(match.str(MESSAGE_SIZE_GROUP))); + std::string node = match.str(MESSAGE_NODE_GROUP); - Message msg(id, name, size, node); + Message msg(message_id, name, size, node); messages.push_back(msg); continue; } if (std::regex_search(line, match, signal_re)) { - std::string name = match.str(2); + std::string name = match.str(SIGNAL_NAME_GROUP); bool is_multiplexed = false; // No support yet - uint32_t start_bit = static_cast(std::stoul(match.str(3))); - uint32_t size = static_cast(std::stoul(match.str(4))); - bool is_bigendian = (std::stoul(match.str(5)) == 0); - bool is_signed = (match.str(6) == "-"); + uint32_t start_bit = static_cast(std::stoul(match.str(SIGNAL_START_BIT_GROUP))); + uint32_t size = static_cast(std::stoul(match.str(SIGNAL_SIZE_GROUP))); + bool is_bigendian = (std::stoul(match.str(SIGNAL_ENDIAN_GROUP)) == 0); + bool is_signed = (match.str(SIGNAL_SIGNED_GROUP) == "-"); - double factor = utils::String::convert_to_double(match.str(7).data()); - double offset = utils::String::convert_to_double(match.str(9).data()); - double min = utils::String::convert_to_double(match.str(11).data()); - double max = utils::String::convert_to_double(match.str(13).data()); + double factor = utils::String::convert_to_double(match.str(SIGNAL_FACTOR_GROUP)); + double offset = utils::String::convert_to_double(match.str(SIGNAL_OFFSET_GROUP)); + double min = utils::String::convert_to_double(match.str(SIGNAL_MIN_GROUP)); + double max = utils::String::convert_to_double(match.str(SIGNAL_MAX_GROUP)); - std::string unit = match.str(15); + std::string unit = match.str(SIGNAL_UNIT_GROUP); std::vector receivers; - utils::String::split(match.str(16), receivers, ','); + utils::String::split(match.str(SIGNAL_RECIEVER_GROUP), receivers, ','); Signal sig(name, is_multiplexed, start_bit, size, is_bigendian, is_signed, factor, offset, min, max, unit, receivers); messages.back().appendSignal(sig); continue; } - if (parseVal(line, obj)) { - sv.push_back(obj); + if (parse_value(line, obj)) { + signal_value.push_back(obj); continue; } } - for (const auto& signal : sv) { + for (const auto& signal : signal_value) { for (auto& msg : messages) { if (msg.id() == signal.can_id) { msg.addValueDescription(signal.signal_name, signal.vd); From 78629e447bbcae6ca27e378555da0031fbe60ca1 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sat, 16 Mar 2024 13:19:37 -0400 Subject: [PATCH 095/131] refactor(value_parsing): removed the state machine based parsing in favor of regex expressions --- include/libdbc/dbc.hpp | 1 + src/dbc.cpp | 151 +++++++---------------------------------- 2 files changed, 26 insertions(+), 126 deletions(-) diff --git a/include/libdbc/dbc.hpp b/include/libdbc/dbc.hpp index 109b89f..7486db3 100644 --- a/include/libdbc/dbc.hpp +++ b/include/libdbc/dbc.hpp @@ -43,6 +43,7 @@ class DbcParser : public Parser { const std::regex name_space_re; const std::regex node_re; const std::regex message_re; + const std::regex value_re; const std::regex signal_re; void parse_dbc_header(std::istream& file_stream); diff --git a/src/dbc.cpp b/src/dbc.cpp index 7eec99a..4ad8780 100644 --- a/src/dbc.cpp +++ b/src/dbc.cpp @@ -4,6 +4,7 @@ #include #include +#include namespace libdbc { @@ -52,136 +53,13 @@ struct VALObject { std::vector vd; }; -static bool parse_value(const std::string& str, VALObject& obj); - -bool parse_value(const std::string& str, VALObject& obj) { - obj.signal_name = ""; - obj.vd.clear(); - auto state = Identifier; - const char* value_data = str.data(); - Signal::SignalValueDescriptions value_description; - for (;;) { - switch (state) { - case Identifier: { - if (*value_data != 'V') { - return false; - } - value_data++; - if (*value_data != 'A') { - return false; - } - value_data++; - if (*value_data != 'L') { - return false; - } - value_data++; - if (*value_data != '_') { - return false; - } - value_data++; - if (*value_data != ' ') { - return false; - } - value_data++; // skip whitespace - state = CANId; - break; - } - case CANId: { - std::string can_id_str; - while (*value_data >= '0' && *value_data <= '9') { - can_id_str += *value_data; - value_data++; - } - if (can_id_str.empty()) { - return false; - } - obj.can_id = static_cast(std::stoul(can_id_str)); - if (*value_data != ' ') { - return false; - } - value_data++; // skip whitespace - state = SignalName; - break; - } - case SignalName: { - if ((*value_data >= 'a' && *value_data <= 'z') || (*value_data >= 'A' && *value_data <= 'Z') || *value_data == '_') { - obj.signal_name += *value_data; - } else { - return false; - } - value_data++; - while ((*value_data >= 'a' && *value_data <= 'z') || (*value_data >= 'A' && *value_data <= 'Z') || *value_data == '_' - || (*value_data >= '0' && *value_data <= '9')) { - obj.signal_name += *value_data; - value_data++; - } - if (*value_data != ' ') { - return false; - } - value_data++; // skip whitespace - state = Value; - break; - } - case Value: { - std::string value_str; - while (*value_data >= '0' && *value_data <= '9') { - value_str += *value_data; - value_data++; - } - if (*value_data == ';') { - if (value_str.empty()) { - return true; - } - return false; - } - if (value_str.empty()) { - return false; - } - - if (*value_data != ' ') { - return false; - } - value_data++; // skip whitespace - value_description.value = (uint32_t)std::stoul(value_str); - state = Description; - break; - } - case Description: { - std::string desc; - if (*value_data != '"') { - return false; - } - value_data++; - while (*value_data != '"' && *value_data != 0) { - desc += *value_data; - value_data++; - } - if (*value_data == 0) { - return false; - } - value_data++; - if (*value_data != ' ') { - return false; - } - value_data++; // skip whitespace - - value_description.description = desc; - obj.vd.push_back(value_description); - - state = Value; - break; - } - } - } - return false; -} - DbcParser::DbcParser() : version_re("^(VERSION)\\s\"(.*)\"") , bit_timing_re("^(BS_:)") , name_space_re("^(NS_)\\s\\:") , node_re("^(BU_:)\\s((?:[\\w]+?\\s?)*)") , message_re("^(BO_)\\s(\\d+)\\s(\\w+)\\:\\s(\\d+)\\s(\\w+|Vector__XXX)") + , value_re("^(VAL_)\\s(\\d+)\\s(\\w+)((?:\\s(\\d+)\\s\"([^\"]*)\")+)\\s;$") , // NOTE: No multiplex support yet signal_re(std::string("^") + whiteSpace + signalIdentifierPattern + whiteSpace + namePattern + whiteSpace + "\\:" + whiteSpace + bitStartPattern + "\\|" @@ -271,7 +149,6 @@ void DbcParser::parse_dbc_messages(const std::vector& lines) { std::vector signal_value; - VALObject obj{}; for (const auto& line : lines) { if (std::regex_search(line, match, message_re)) { uint32_t message_id = static_cast(std::stoul(match.str(MESSAGE_ID_GROUP))); @@ -308,7 +185,29 @@ void DbcParser::parse_dbc_messages(const std::vector& lines) { continue; } - if (parse_value(line, obj)) { + if (std::regex_search(line, match, value_re)) { + uint32_t message_id = static_cast(std::stoul(match.str(2))); + std::string signal_name = match.str(3); + + // Loop over the rest of the descriptions + std::string rest_of_descriptions = match.str(4); + std::regex description_re("\\s(\\d+)\\s\"([^\"]*)\""); + + std::sregex_iterator desc_iter(rest_of_descriptions.begin(), rest_of_descriptions.end(), description_re); + std::sregex_iterator desc_end; + + std::vector values{}; + while (desc_iter != desc_end) { + std::smatch desc_match = *desc_iter; + uint32_t number = static_cast(std::stoul(desc_match.str(1))); + std::string text = desc_match.str(2); + + values.push_back(Signal::SignalValueDescriptions{number, text}); + ++desc_iter; + } + + VALObject obj{message_id, signal_name, values}; + signal_value.push_back(obj); continue; } From df07224827d98843c185cfd0502a8307a0bc47a0 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sat, 16 Mar 2024 13:35:18 -0400 Subject: [PATCH 096/131] fix(clang-tidy): fixed all clang-tidy warnings within the library. Added exception for default destructor of special member functions in clang tidy. --- .clang-tidy | 2 +- include/libdbc/dbc.hpp | 20 +++++++++----------- include/libdbc/exceptions/error.hpp | 6 +++--- include/libdbc/message.hpp | 4 ++-- include/libdbc/signal.hpp | 2 +- include/libdbc/utils/utils.hpp | 4 ++-- 6 files changed, 18 insertions(+), 20 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index cc7ef80..4b627d2 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -140,7 +140,7 @@ CheckOptions: readability-suspicious-call-argument.DiceSimilarAbove: '70' readability-suspicious-call-argument.Dice: 'true' readability-suspicious-call-argument.Abbreviation: 'true' - cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor: 'false' + cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor: 'true' readability-identifier-length.IgnoredLoopCounterNames: '^[ijk_]$' cert-dcl37-c.Invert: 'false' cert-dcl37-c.AggressiveDependentMemberLookup: 'false' diff --git a/include/libdbc/dbc.hpp b/include/libdbc/dbc.hpp index 7486db3..50178f8 100644 --- a/include/libdbc/dbc.hpp +++ b/include/libdbc/dbc.hpp @@ -23,28 +23,26 @@ class DbcParser : public Parser { public: DbcParser(); - virtual ~DbcParser() = default; - - virtual void parse_file(const std::string& file) final override; + void parse_file(const std::string& file) override; std::string get_version() const; std::vector get_nodes() const; std::vector get_messages() const; - Message::ParseSignalsStatus parseMessage(const uint32_t id, const std::vector& data, std::vector& out_values); + Message::ParseSignalsStatus parseMessage(uint32_t message_id, const std::vector& data, std::vector& out_values); private: std::string version; std::vector nodes; std::vector messages; - const std::regex version_re; - const std::regex bit_timing_re; - const std::regex name_space_re; - const std::regex node_re; - const std::regex message_re; - const std::regex value_re; - const std::regex signal_re; + 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; void parse_dbc_header(std::istream& file_stream); void parse_dbc_nodes(std::istream& file_stream); diff --git a/include/libdbc/exceptions/error.hpp b/include/libdbc/exceptions/error.hpp index a6a3653..4749d2d 100644 --- a/include/libdbc/exceptions/error.hpp +++ b/include/libdbc/exceptions/error.hpp @@ -1,20 +1,20 @@ #ifndef ERROR_HPP #define ERROR_HPP -#include +#include namespace libdbc { class exception : public std::exception { public: - const char* what() const throw() { + const char* what() const throw() override { return "libdbc exception occurred"; } }; class validity_error : public exception { public: - const char* what() const throw() { + const char* what() const throw() override { return "Invalid DBC file"; } }; diff --git a/include/libdbc/message.hpp b/include/libdbc/message.hpp index 05bd022..21527bf 100644 --- a/include/libdbc/message.hpp +++ b/include/libdbc/message.hpp @@ -11,7 +11,7 @@ namespace libdbc { struct Message { Message() = delete; virtual ~Message() = default; - explicit Message(uint32_t id, const std::string& name, uint8_t size, const std::string& node); + explicit Message(uint32_t message_id, const std::string& name, uint8_t size, const std::string& node); enum class ParseSignalsStatus { Success, @@ -39,7 +39,7 @@ struct Message { std::string m_node; std::vector m_signals; - friend std::ostream& operator<<(std::ostream& os, const Message& dt); + friend std::ostream& operator<<(std::ostream& out, const Message& msg); }; std::ostream& operator<<(std::ostream& out, const Message& msg); diff --git a/include/libdbc/signal.hpp b/include/libdbc/signal.hpp index cdfd018..4694f1e 100644 --- a/include/libdbc/signal.hpp +++ b/include/libdbc/signal.hpp @@ -41,7 +41,7 @@ struct Signal { double min, double max, std::string unit, - std::vector recievers); + std::vector receivers); virtual bool operator==(const Signal& rhs) const; bool operator<(const Signal& rhs) const; diff --git a/include/libdbc/utils/utils.hpp b/include/libdbc/utils/utils.hpp index 8763af6..6ab2292 100644 --- a/include/libdbc/utils/utils.hpp +++ b/include/libdbc/utils/utils.hpp @@ -35,10 +35,10 @@ class String { template static void split(const std::string& str, Container& cont, char delim = ' ') { - std::stringstream ss(str); + std::stringstream stream(str); std::string token; - while (std::getline(ss, token, delim)) { + while (std::getline(stream, token, delim)) { cont.push_back(token); } } From 8ad386ef359859d0a321678344a755647031e6d7 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sat, 16 Mar 2024 16:37:00 -0400 Subject: [PATCH 097/131] feat(clang-tidy): Add warnings into errors for cmake command. Add naming conventions. --- .clang-tidy | 13 ++- CMakeLists.txt | 258 ++++++++++++++++++++++++------------------------- 2 files changed, 140 insertions(+), 131 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 4b627d2..2b65fe4 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -17,7 +17,7 @@ CheckOptions: cert-dcl16-c.NewSuffixes: 'L;LL;LU;LLU' cert-dcl51-cpp.AggressiveDependentMemberLookup: 'false' readability-identifier-naming.GetConfigPerFile: 'true' - cert-err61-cpp.MaxSize: '-1' + cert-err61-cpp.MaxSize: '10' cert-sig30-c.AsyncSafeFunctionSet: POSIX readability-inconsistent-declaration-parameter-name.Strict: 'false' cppcoreguidelines-macro-usage.CheckCapsOnly: 'false' @@ -45,7 +45,7 @@ CheckOptions: readability-suspicious-call-argument.JaroWinklerDissimilarBelow: '75' readability-suspicious-call-argument.SuffixSimilarAbove: '30' readability-suspicious-call-argument.Suffix: 'true' - cert-err09-cpp.MaxSize: '-1' + cert-err09-cpp.MaxSize: '10' cppcoreguidelines-narrowing-conversions.WarnOnIntegerNarrowingConversion: 'true' cppcoreguidelines-prefer-member-initializer.UseAssignment: 'false' cert-oop57-cpp.MemSetNames: '' @@ -156,5 +156,14 @@ CheckOptions: cert-dcl16-c.IgnoreMacros: 'true' llvm-else-after-return.WarnOnUnfixable: 'false' cert-msc32-c.DisallowedSeedTypes: 'time_t,std::time_t' + readability-identifier-naming.NamespaceCase: 'CamelCase' + readability-identifier-naming.UnionCase: 'CamelCase' + readability-identifier-naming.ClassCase: 'CamelCase' + readability-identifier-naming.ClassMemberCase: 'lower_case' + readability-identifier-naming.ClassMethodCase: 'lower_case' + readability-identifier-naming.StructCase: 'CamelCase' + readability-identifier-naming.MemberCase: 'lower_case' + readability-identifier-naming.MethodCase: 'lower_case' + readability-identifier-naming.FunctionCase: 'lower_case' ... diff --git a/CMakeLists.txt b/CMakeLists.txt index 362821f..539e72b 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,129 +1,129 @@ -cmake_minimum_required(VERSION 3.16) - -# Keep this on one line for release checking -project(dbc VERSION 0.2.0 DESCRIPTION "C++ DBC Parser") - -# -- PROJECT OPTIONS -- # -option(DBC_ENABLE_TESTS "Enable Unittests" ON) -option(DBC_TEST_LOCALE_INDEPENDENCE "Used to deterime if the libary is locale agnostic when it comes to converting floats. You need `de_DE.UTF-8` locale installed for this testing." OFF) -option(DBC_GENERATE_DOCS "Use doxygen if installed to generated documentation files" OFF) -option(DBC_GENERATE_SINGLE_HEADER "This will run the generator for the single header file version. Default is OFF since we make a static build. Requires cargo installed." OFF) -# ---------------------- # - -set(CMAKE_EXPORT_COMPILE_COMMANDS ON) - -# package -set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}) -set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR}) -set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH}) -set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE) -set(CPACK_RESOURCE_FILE_README ${CMAKE_CURRENT_SOURCE_DIR}/README.md) -include(CPack) - -# specify the C++ standard -set(CMAKE_CXX_STANDARD 11) -set(CMAKE_CXX_STANDARD_REQUIRED True) - -find_package(FastFloat QUIET) -if (NOT ${FastFloat_FOUND}) - include(FetchContent) - FetchContent_Declare( - FastFloat - GIT_REPOSITORY https://github.com/fastfloat/fast_float.git - GIT_TAG 1ea4f27b2aeee2859a1354a3c24cff52a116cad1 - ) - FetchContent_MakeAvailable(FastFloat) -endif() - -# add where to find the source files -list(APPEND SOURCE_FILES - ${PROJECT_SOURCE_DIR}/src/utils.cpp - ${PROJECT_SOURCE_DIR}/src/message.cpp - ${PROJECT_SOURCE_DIR}/src/signal.cpp - ${PROJECT_SOURCE_DIR}/src/dbc.cpp -) - -list(APPEND HEADER_FILES - ${PROJECT_SOURCE_DIR}/include/libdbc/dbc.hpp - ${PROJECT_SOURCE_DIR}/include/libdbc/message.hpp - ${PROJECT_SOURCE_DIR}/include/libdbc/signal.hpp - ${PROJECT_SOURCE_DIR}/include/libdbc/utils/utils.hpp - ${PROJECT_SOURCE_DIR}/include/libdbc/exceptions/error.hpp -) - -if(DBC_ENABLE_TESTS) - include(CTest) - add_subdirectory(test) -endif() - -if(DBC_GENERATE_DOCS) - add_subdirectory(doc) -endif() - -list(APPEND GCC_CLANG_COMPILE_FLAGS - -Wall -Wextra -Wpedantic - -Wconversion -Wint-in-bool-context - -Wmissing-declarations -Wmissing-field-initializers - -Werror -) - - -if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC") - add_compile_options(/W4 /WX) -elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") - # Clang shadow warnings aren't as sensitive as gcc - add_compile_options(${GCC_CLANG_COMPILE_FLAGS} -Wshadow) -else() - add_compile_options(${GCC_CLANG_COMPILE_FLAGS}) -endif() - -add_library(${PROJECT_NAME} STATIC ${SOURCE_FILES}) -target_link_libraries(${PROJECT_NAME} FastFloat::fast_float) -target_include_directories(${PROJECT_NAME} PUBLIC - $ - $ -) -target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) - -target_sources(${PROJECT_NAME} INTERFACE FILE_SET HEADERS - TYPE HEADERS - BASE_DIRS ${PROJECT_SOURCE_DIR}/include/libdbc - FILES ${HEADER_FILES} -) - -if(DBC_GENERATE_SINGLE_HEADER) - add_custom_target(single_header ALL - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} - COMMAND ${CMAKE_SOURCE_DIR}/scripts/create_single_header.sh - ) -endif() - -## Installation -# install lib -install(TARGETS ${PROJECT_NAME} - DESTINATION ${CMAKE_INSTALL_LIBDIR}) - -# install headers -install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/libdbc DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) - -# Generate pkg-config file -configure_file(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY) -install( - FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc - DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) - -# Clang tidy -add_custom_target(clang-tidy-check - clang-tidy -p ${CMAKE_BINARY_DIR}/compile_commands.json ${SOURCE_FILES} ${HEADER_FILES} - DEPENDS ${SOURCE_FILES} ${HEADER_FILES} -) - -add_custom_target(clang-tidy-dump - clang-tidy -checks=-*,clang-analyzer-*,clang-analyzer-cplusplus*,cert-*,cppcoreguidelines-*,portability-*,readability-*,clang-diagnostic-* -dump-config -p ${CMAKE_BINARY_DIR}/compile_commands.json ${SOURCE_FILES} ${HEADER_FILES} > ../.clang-tidy - DEPENDS ${SOURCE_FILES} ${HEADER_FILES} -) - -add_custom_target(clang-tidy-fix - clang-tidy -fix-notes -p ${CMAKE_BINARY_DIR}/compile_commands.json ${SOURCE_FILES} ${HEADER_FILES} - DEPENDS ${SOURCE_FILES} ${HEADER_FILES} -) \ No newline at end of file +cmake_minimum_required(VERSION 3.16) + +# Keep this on one line for release checking +project(dbc VERSION 0.2.0 DESCRIPTION "C++ DBC Parser") + +# -- PROJECT OPTIONS -- # +option(DBC_ENABLE_TESTS "Enable Unittests" ON) +option(DBC_TEST_LOCALE_INDEPENDENCE "Used to deterime if the libary is locale agnostic when it comes to converting floats. You need `de_DE.UTF-8` locale installed for this testing." OFF) +option(DBC_GENERATE_DOCS "Use doxygen if installed to generated documentation files" OFF) +option(DBC_GENERATE_SINGLE_HEADER "This will run the generator for the single header file version. Default is OFF since we make a static build. Requires cargo installed." OFF) +# ---------------------- # + +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +# package +set(CPACK_PACKAGE_VERSION_MAJOR ${PROJECT_VERSION_MAJOR}) +set(CPACK_PACKAGE_VERSION_MINOR ${PROJECT_VERSION_MINOR}) +set(CPACK_PACKAGE_VERSION_PATCH ${PROJECT_VERSION_PATCH}) +set(CPACK_RESOURCE_FILE_LICENSE ${CMAKE_CURRENT_SOURCE_DIR}/LICENSE) +set(CPACK_RESOURCE_FILE_README ${CMAKE_CURRENT_SOURCE_DIR}/README.md) +include(CPack) + +# specify the C++ standard +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD_REQUIRED True) + +find_package(FastFloat QUIET) +if (NOT ${FastFloat_FOUND}) + include(FetchContent) + FetchContent_Declare( + FastFloat + GIT_REPOSITORY https://github.com/fastfloat/fast_float.git + GIT_TAG 1ea4f27b2aeee2859a1354a3c24cff52a116cad1 + ) + FetchContent_MakeAvailable(FastFloat) +endif() + +# add where to find the source files +list(APPEND SOURCE_FILES + ${PROJECT_SOURCE_DIR}/src/utils.cpp + ${PROJECT_SOURCE_DIR}/src/message.cpp + ${PROJECT_SOURCE_DIR}/src/signal.cpp + ${PROJECT_SOURCE_DIR}/src/dbc.cpp +) + +list(APPEND HEADER_FILES + ${PROJECT_SOURCE_DIR}/include/libdbc/dbc.hpp + ${PROJECT_SOURCE_DIR}/include/libdbc/message.hpp + ${PROJECT_SOURCE_DIR}/include/libdbc/signal.hpp + ${PROJECT_SOURCE_DIR}/include/libdbc/utils/utils.hpp + ${PROJECT_SOURCE_DIR}/include/libdbc/exceptions/error.hpp +) + +if(DBC_ENABLE_TESTS) + include(CTest) + add_subdirectory(test) +endif() + +if(DBC_GENERATE_DOCS) + add_subdirectory(doc) +endif() + +list(APPEND GCC_CLANG_COMPILE_FLAGS + -Wall -Wextra -Wpedantic + -Wconversion -Wint-in-bool-context + -Wmissing-declarations -Wmissing-field-initializers + -Werror +) + + +if (CMAKE_CXX_COMPILER_ID MATCHES "MSVC") + add_compile_options(/W4 /WX) +elseif(CMAKE_CXX_COMPILER_ID MATCHES "Clang") + # Clang shadow warnings aren't as sensitive as gcc + add_compile_options(${GCC_CLANG_COMPILE_FLAGS} -Wshadow) +else() + add_compile_options(${GCC_CLANG_COMPILE_FLAGS}) +endif() + +add_library(${PROJECT_NAME} STATIC ${SOURCE_FILES}) +target_link_libraries(${PROJECT_NAME} FastFloat::fast_float) +target_include_directories(${PROJECT_NAME} PUBLIC + $ + $ +) +target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) + +target_sources(${PROJECT_NAME} INTERFACE FILE_SET HEADERS + TYPE HEADERS + BASE_DIRS ${PROJECT_SOURCE_DIR}/include/libdbc + FILES ${HEADER_FILES} +) + +if(DBC_GENERATE_SINGLE_HEADER) + add_custom_target(single_header ALL + WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + COMMAND ${CMAKE_SOURCE_DIR}/scripts/create_single_header.sh + ) +endif() + +## Installation +# install lib +install(TARGETS ${PROJECT_NAME} + DESTINATION ${CMAKE_INSTALL_LIBDIR}) + +# install headers +install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/libdbc DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) + +# Generate pkg-config file +configure_file(${PROJECT_NAME}.pc.in ${PROJECT_NAME}.pc @ONLY) +install( + FILES ${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME}.pc + DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig) + +# Clang tidy +add_custom_target(clang-tidy-check + clang-tidy -p ${CMAKE_BINARY_DIR}/compile_commands.json -warnings-as-errors=* ${SOURCE_FILES} ${HEADER_FILES} + DEPENDS ${SOURCE_FILES} ${HEADER_FILES} +) + +add_custom_target(clang-tidy-dump + clang-tidy -checks=-*,clang-analyzer-*,clang-analyzer-cplusplus*,cert-*,cppcoreguidelines-*,portability-*,readability-*,clang-diagnostic-* -dump-config -p ${CMAKE_BINARY_DIR}/compile_commands.json ${SOURCE_FILES} ${HEADER_FILES} > ../.clang-tidy + DEPENDS ${SOURCE_FILES} ${HEADER_FILES} +) + +add_custom_target(clang-tidy-fix + clang-tidy -fix-notes -p ${CMAKE_BINARY_DIR}/compile_commands.json ${SOURCE_FILES} ${HEADER_FILES} + DEPENDS ${SOURCE_FILES} ${HEADER_FILES} +) From 62ab43912eacb11b07fa385bf3bc8906927a3582 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sat, 16 Mar 2024 16:41:46 -0400 Subject: [PATCH 098/131] Adding timeout after finding out some windows debug builds were timing out --- .github/workflows/pipeline.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index b630847..af193f2 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -62,6 +62,7 @@ jobs: run: cmake --build build --parallel `nproc` - name: Run tests + timeout-minutes: 3 env: CTEST_OUTPUT_ON_FAILURE: 1 run: ctest --output-on-failure --test-dir build -j `nproc` @@ -98,6 +99,7 @@ jobs: shell: cmd - name: Run tests + timeout-minutes: 3 env: CTEST_OUTPUT_ON_FAILURE: 1 working-directory: ${{runner.workspace}} @@ -142,10 +144,11 @@ jobs: run: cmake --build build --parallel `sysctl -n hw.ncpu` - name: Run tests + timeout-minutes: 3 env: CTEST_OUTPUT_ON_FAILURE: 1 working-directory: ${{runner.workspace}} - run: ctest --output-on-failure --test-dir build -j `sysctl -n hw.ncpu` + run: ctest --output-on-failure --test-dir build -j `sysctl -n hw.ncpu` -V format-check: runs-on: ubuntu-latest From 20259bcc2b889d518c9cef104c736695a5ebd907 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sat, 16 Mar 2024 16:50:25 -0400 Subject: [PATCH 099/131] fix(test): change while loop of the iterator for value description to for loop to try and prevent windows debug build from infinite loops --- src/dbc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dbc.cpp b/src/dbc.cpp index 4ad8780..385c9fb 100644 --- a/src/dbc.cpp +++ b/src/dbc.cpp @@ -194,10 +194,10 @@ void DbcParser::parse_dbc_messages(const std::vector& lines) { std::regex description_re("\\s(\\d+)\\s\"([^\"]*)\""); std::sregex_iterator desc_iter(rest_of_descriptions.begin(), rest_of_descriptions.end(), description_re); - std::sregex_iterator desc_end; + std::sregex_iterator desc_end = std::sregex_iterator(); std::vector values{}; - while (desc_iter != desc_end) { + for (std::sregex_iterator i = desc_iter; i != desc_end; ++i) { std::smatch desc_match = *desc_iter; uint32_t number = static_cast(std::stoul(desc_match.str(1))); std::string text = desc_match.str(2); From 048779b9f7f4db7f6c0a84de21f6c4c61940a5bf Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sat, 16 Mar 2024 16:59:17 -0400 Subject: [PATCH 100/131] debug: Comment out the infinite loop that is hanging up the test in debug for windows builds --- src/dbc.cpp | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/dbc.cpp b/src/dbc.cpp index 385c9fb..9c10913 100644 --- a/src/dbc.cpp +++ b/src/dbc.cpp @@ -185,32 +185,32 @@ void DbcParser::parse_dbc_messages(const std::vector& lines) { continue; } - if (std::regex_search(line, match, value_re)) { - uint32_t message_id = static_cast(std::stoul(match.str(2))); - std::string signal_name = match.str(3); + // if (std::regex_search(line, match, value_re)) { + // uint32_t message_id = static_cast(std::stoul(match.str(2))); + // std::string signal_name = match.str(3); - // Loop over the rest of the descriptions - std::string rest_of_descriptions = match.str(4); - std::regex description_re("\\s(\\d+)\\s\"([^\"]*)\""); + // // Loop over the rest of the descriptions + // std::string rest_of_descriptions = match.str(4); + // std::regex description_re("\\s(\\d+)\\s\"([^\"]*)\""); - std::sregex_iterator desc_iter(rest_of_descriptions.begin(), rest_of_descriptions.end(), description_re); - std::sregex_iterator desc_end = std::sregex_iterator(); + // std::sregex_iterator desc_iter(rest_of_descriptions.begin(), rest_of_descriptions.end(), description_re); + // std::sregex_iterator desc_end = std::sregex_iterator(); - std::vector values{}; - for (std::sregex_iterator i = desc_iter; i != desc_end; ++i) { - std::smatch desc_match = *desc_iter; - uint32_t number = static_cast(std::stoul(desc_match.str(1))); - std::string text = desc_match.str(2); + // std::vector values{}; + // for (std::sregex_iterator i = desc_iter; i != desc_end; ++i) { + // std::smatch desc_match = *desc_iter; + // uint32_t number = static_cast(std::stoul(desc_match.str(1))); + // std::string text = desc_match.str(2); - values.push_back(Signal::SignalValueDescriptions{number, text}); - ++desc_iter; - } + // values.push_back(Signal::SignalValueDescriptions{number, text}); + // ++desc_iter; + // } - VALObject obj{message_id, signal_name, values}; + // VALObject obj{message_id, signal_name, values}; - signal_value.push_back(obj); - continue; - } + // signal_value.push_back(obj); + // continue; + // } } for (const auto& signal : signal_value) { From fd74751073595bf7657e2b8ae66024bee3415bd4 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sat, 16 Mar 2024 17:05:07 -0400 Subject: [PATCH 101/131] debug(test): reverting commented out code. Attempting to set env of the build type in windows --- .github/workflows/pipeline.yml | 3 +++ src/dbc.cpp | 40 +++++++++++++++++----------------- 2 files changed, 23 insertions(+), 20 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index af193f2..d3f1440 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -78,6 +78,9 @@ jobs: build_type: [Debug, Release] std: [11] + env: + BUILD_TYPE: ${{matrix.build_type}} + steps: - uses: actions/checkout@v4 diff --git a/src/dbc.cpp b/src/dbc.cpp index 9c10913..385c9fb 100644 --- a/src/dbc.cpp +++ b/src/dbc.cpp @@ -185,32 +185,32 @@ void DbcParser::parse_dbc_messages(const std::vector& lines) { continue; } - // if (std::regex_search(line, match, value_re)) { - // uint32_t message_id = static_cast(std::stoul(match.str(2))); - // std::string signal_name = match.str(3); + if (std::regex_search(line, match, value_re)) { + uint32_t message_id = static_cast(std::stoul(match.str(2))); + std::string signal_name = match.str(3); - // // Loop over the rest of the descriptions - // std::string rest_of_descriptions = match.str(4); - // std::regex description_re("\\s(\\d+)\\s\"([^\"]*)\""); + // Loop over the rest of the descriptions + std::string rest_of_descriptions = match.str(4); + std::regex description_re("\\s(\\d+)\\s\"([^\"]*)\""); - // std::sregex_iterator desc_iter(rest_of_descriptions.begin(), rest_of_descriptions.end(), description_re); - // std::sregex_iterator desc_end = std::sregex_iterator(); + std::sregex_iterator desc_iter(rest_of_descriptions.begin(), rest_of_descriptions.end(), description_re); + std::sregex_iterator desc_end = std::sregex_iterator(); - // std::vector values{}; - // for (std::sregex_iterator i = desc_iter; i != desc_end; ++i) { - // std::smatch desc_match = *desc_iter; - // uint32_t number = static_cast(std::stoul(desc_match.str(1))); - // std::string text = desc_match.str(2); + std::vector values{}; + for (std::sregex_iterator i = desc_iter; i != desc_end; ++i) { + std::smatch desc_match = *desc_iter; + uint32_t number = static_cast(std::stoul(desc_match.str(1))); + std::string text = desc_match.str(2); - // values.push_back(Signal::SignalValueDescriptions{number, text}); - // ++desc_iter; - // } + values.push_back(Signal::SignalValueDescriptions{number, text}); + ++desc_iter; + } - // VALObject obj{message_id, signal_name, values}; + VALObject obj{message_id, signal_name, values}; - // signal_value.push_back(obj); - // continue; - // } + signal_value.push_back(obj); + continue; + } } for (const auto& signal : signal_value) { From 04a381dd996c6c393e8a1e54679860b051663bd9 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sat, 16 Mar 2024 17:11:59 -0400 Subject: [PATCH 102/131] feat(ci): adding clang-tidy check to pipeline. --- .github/workflows/pipeline.yml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index d3f1440..5d6c79c 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -25,6 +25,8 @@ jobs: cc: clang-16 llvm_version: 16 + env: + steps: - uses: actions/checkout@v4 @@ -126,6 +128,9 @@ jobs: - cxx: clang++ cc: clang + env: + BUILD_TYPE: ${{matrix.build_type}} + steps: - uses: actions/checkout@v4 @@ -173,3 +178,15 @@ jobs: - name: Test format with clang format run: ./scripts/fmt.sh + clang-tidy-check: + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v4 + + - name: Make build directory + run: cmake -Bbuild -H$GITHUB_WORKSPACE + + - name: Run clang-tidy check + run: cmake --build build --target clang-tidy-check + From bbe7f3a756cfd2ffcce9d0605e96af843654f708 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sat, 16 Mar 2024 17:15:09 -0400 Subject: [PATCH 103/131] fix(ci): missing env section for linux --- .github/workflows/pipeline.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 5d6c79c..dec1ac8 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -26,6 +26,7 @@ jobs: llvm_version: 16 env: + BUILD_TYPE: ${{matrix.build_type}} steps: - uses: actions/checkout@v4 From db271871570c09e08c8367da11e1edea44a9951e Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sat, 16 Mar 2024 17:27:26 -0400 Subject: [PATCH 104/131] fix(test): Attempting to remove the variables to see if the debug windows build is a compiler issue --- src/utils.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/utils.cpp b/src/utils.cpp index d2ea6b7..2f671d5 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -74,9 +74,7 @@ std::string String::trim(const std::string& line) { double String::convert_to_double(const std::string& value, double default_value) { double converted_value = default_value; - auto begin = value.begin(); - auto end = value.end(); - fast_float::from_chars(&(*begin), &(*end), converted_value); + fast_float::from_chars(&(*value.begin()), &(*value.end()), converted_value); return converted_value; } From 67a7b3655cb7fffbca582f28200b6c2f778dbe60 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sat, 16 Mar 2024 17:34:54 -0400 Subject: [PATCH 105/131] fix(test): Fixed the fast_float to original arithmetic in an attempt to fix the windows debug build --- src/utils.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/utils.cpp b/src/utils.cpp index 2f671d5..8960e15 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -74,7 +74,9 @@ std::string String::trim(const std::string& line) { double String::convert_to_double(const std::string& value, double default_value) { double converted_value = default_value; - fast_float::from_chars(&(*value.begin()), &(*value.end()), converted_value); + fast_float::from_chars(value.data(), + value.data() + value.size(), + converted_value); // NOLINT -- Trying to iterators on the value causes the test to infinitly hang on windows builds return converted_value; } From b90af2d3d8cfb38ba7b42992de50cd8427b32791 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sat, 16 Mar 2024 17:36:21 -0400 Subject: [PATCH 106/131] feat(ci): update to clang-format 17and install clang-tidy 17. The server version is too old --- .github/workflows/pipeline.yml | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index dec1ac8..d63a1e1 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -169,12 +169,12 @@ jobs: run: | wget https://apt.llvm.org/llvm.sh chmod +x llvm.sh - sudo ./llvm.sh 16 + sudo ./llvm.sh 17 - sudo apt update && sudo apt install -y clang-format-16 - sudo ln -sf $(which clang-format-16) $(which clang-format) + sudo apt update && sudo apt install -y clang-format-17 + sudo ln -sf $(which clang-format-17) $(which clang-format) - test "$(clang-format --version)" == "$(clang-format-16 --version)" + test "$(clang-format --version)" == "$(clang-format-17 --version)" - name: Test format with clang format run: ./scripts/fmt.sh @@ -185,6 +185,17 @@ jobs: steps: - uses: actions/checkout@v4 + - name: Install clang-tidy version + run: | + wget https://apt.llvm.org/llvm.sh + chmod +x llvm.sh + sudo ./llvm.sh 17 + + sudo apt update && sudo apt install -y clang-tidy-17 + sudo ln -sf $(which clang-tidy-17) $(which clang-tidy) + + test "$(clang-tidy --version)" == "$(clang-tidy-17 --version)" + - name: Make build directory run: cmake -Bbuild -H$GITHUB_WORKSPACE From 089c1e5fd7c1f19684a6e2052a7e9fb345d821bd Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sat, 16 Mar 2024 18:09:01 -0400 Subject: [PATCH 107/131] refactor(naming)!: Breaking interface to follow standard naming convention. * Namespace `libdbc` -> `Libdbc` * Message method `parseMessage` -> `parse_message` * Exception class names `exception` -> `Exception`, `validity_error` -> `ValidityError` * Signal method names `parseSignals` -> `parse_signals`, `appendSignal` -> `append_signal`, -> `getSignals` -> `get_signals`, `addValueDescription` -> `add_value_description` * Signal class name change `SignalValueDescriptions` -> `ValueDescription` * Utils name space `utils` -> `Utils` Using naming scheme of CamelCase for classes, structs, and namespaces. Snake case for everything else --- include/libdbc/dbc.hpp | 8 +- include/libdbc/exceptions/error.hpp | 6 +- include/libdbc/message.hpp | 10 +- include/libdbc/signal.hpp | 6 +- include/libdbc/utils/utils.hpp | 2 +- src/dbc.cpp | 58 +++--- src/message.cpp | 12 +- src/signal.cpp | 2 +- src/utils.cpp | 11 +- test/locale_testing/test_locale_main.cpp | 14 +- .../test_single_header.cpp | 20 +- test/test_dbc.cpp | 175 +++++++++--------- test/test_parse_message.cpp | 28 +-- test/test_utils.cpp | 22 ++- 14 files changed, 187 insertions(+), 187 deletions(-) diff --git a/include/libdbc/dbc.hpp b/include/libdbc/dbc.hpp index 50178f8..060e9f7 100644 --- a/include/libdbc/dbc.hpp +++ b/include/libdbc/dbc.hpp @@ -8,7 +8,7 @@ #include -namespace libdbc { +namespace Libdbc { class Parser { public: @@ -27,14 +27,14 @@ class DbcParser : public Parser { std::string get_version() const; std::vector get_nodes() const; - std::vector get_messages() const; + std::vector get_messages() const; - Message::ParseSignalsStatus parseMessage(uint32_t message_id, const std::vector& data, std::vector& out_values); + Message::ParseSignalsStatus parse_message(uint32_t message_id, const std::vector& data, std::vector& out_values); private: std::string version; std::vector nodes; - std::vector messages; + std::vector messages; std::regex version_re; std::regex bit_timing_re; diff --git a/include/libdbc/exceptions/error.hpp b/include/libdbc/exceptions/error.hpp index 4749d2d..27e2fa4 100644 --- a/include/libdbc/exceptions/error.hpp +++ b/include/libdbc/exceptions/error.hpp @@ -3,16 +3,16 @@ #include -namespace libdbc { +namespace Libdbc { -class exception : public std::exception { +class Exception : public std::exception { public: const char* what() const throw() override { return "libdbc exception occurred"; } }; -class validity_error : public exception { +class ValidityError : public Exception { public: const char* what() const throw() override { return "Invalid DBC file"; diff --git a/include/libdbc/message.hpp b/include/libdbc/message.hpp index 21527bf..9ef29a5 100644 --- a/include/libdbc/message.hpp +++ b/include/libdbc/message.hpp @@ -7,7 +7,7 @@ #include #include -namespace libdbc { +namespace Libdbc { struct Message { Message() = delete; virtual ~Message() = default; @@ -21,14 +21,14 @@ struct Message { ErrorInvalidConversion, }; - ParseSignalsStatus parseSignals(const std::vector& data, std::vector& values) const; + ParseSignalsStatus parse_signals(const std::vector& data, std::vector& values) const; - void appendSignal(const Signal& signal); - std::vector getSignals() const; + void append_signal(const Signal& signal); + std::vector get_signals() const; uint32_t id() const; uint8_t size() const; const std::string& name() const; - void addValueDescription(const std::string& signal_name, const std::vector&); + void add_value_description(const std::string& signal_name, const std::vector&); virtual bool operator==(const Message& rhs) const; diff --git a/include/libdbc/signal.hpp b/include/libdbc/signal.hpp index 4694f1e..18ed3da 100644 --- a/include/libdbc/signal.hpp +++ b/include/libdbc/signal.hpp @@ -7,9 +7,9 @@ #include #include -namespace libdbc { +namespace Libdbc { struct Signal { - struct SignalValueDescriptions { + struct ValueDescription { uint32_t value; std::string description; }; @@ -26,7 +26,7 @@ struct Signal { double max; std::string unit; std::vector receivers; - std::vector svDescriptions; + std::vector value_descriptions; Signal() = delete; virtual ~Signal() = default; diff --git a/include/libdbc/utils/utils.hpp b/include/libdbc/utils/utils.hpp index 6ab2292..d626d83 100644 --- a/include/libdbc/utils/utils.hpp +++ b/include/libdbc/utils/utils.hpp @@ -9,7 +9,7 @@ #include #include -namespace utils { +namespace Utils { class StreamHandler { public: diff --git a/src/dbc.cpp b/src/dbc.cpp index 385c9fb..75e607d 100644 --- a/src/dbc.cpp +++ b/src/dbc.cpp @@ -6,7 +6,7 @@ #include #include -namespace libdbc { +namespace Libdbc { const auto floatPattern = "(-?\\d+\\.?(\\d+)?)"; // Can be negative @@ -45,12 +45,10 @@ constexpr unsigned MESSAGE_NAME_GROUP = 3; constexpr unsigned MESSAGE_SIZE_GROUP = 4; constexpr unsigned MESSAGE_NODE_GROUP = 5; -enum VALToken { Identifier = 0, CANId, SignalName, Value, Description }; - -struct VALObject { +struct Value { uint32_t can_id; std::string signal_name; - std::vector vd; + std::vector value_descriptions; }; DbcParser::DbcParser() @@ -79,7 +77,7 @@ void DbcParser::parse_file(const std::string& file) { parse_dbc_nodes(stream); while (!stream.eof()) { - utils::StreamHandler::get_next_non_blank_line(stream, line); + Utils::StreamHandler::get_next_non_blank_line(stream, line); lines.push_back(line); } @@ -94,14 +92,14 @@ std::vector DbcParser::get_nodes() const { return nodes; } -std::vector DbcParser::get_messages() const { +std::vector DbcParser::get_messages() const { return messages; } -Message::ParseSignalsStatus DbcParser::parseMessage(const uint32_t message_id, const std::vector& data, std::vector& out_values) { +Message::ParseSignalsStatus DbcParser::parse_message(const uint32_t message_id, const std::vector& data, std::vector& out_values) { for (const auto& message : messages) { if (message.id() == message_id) { - return message.parseSignals(data, out_values); + return message.parse_signals(data, out_values); } } return Message::ParseSignalsStatus::ErrorUnknownID; @@ -111,20 +109,20 @@ void DbcParser::parse_dbc_header(std::istream& file_stream) { std::string line; std::smatch match; - utils::StreamHandler::get_line(file_stream, line); + Utils::StreamHandler::get_line(file_stream, line); if (!std::regex_search(line, match, version_re)) { - throw validity_error(); + throw ValidityError(); } version = match.str(2); - utils::StreamHandler::get_next_non_blank_line(file_stream, line); - utils::StreamHandler::skip_to_next_blank_line(file_stream, line); - utils::StreamHandler::get_next_non_blank_line(file_stream, line); + Utils::StreamHandler::get_next_non_blank_line(file_stream, line); + Utils::StreamHandler::skip_to_next_blank_line(file_stream, line); + Utils::StreamHandler::get_next_non_blank_line(file_stream, line); if (!std::regex_search(line, match, bit_timing_re)) { - throw validity_error(); + throw ValidityError(); } } @@ -132,22 +130,22 @@ void DbcParser::parse_dbc_nodes(std::istream& file_stream) { std::string line; std::smatch match; - utils::StreamHandler::get_next_non_blank_line(file_stream, line); + Utils::StreamHandler::get_next_non_blank_line(file_stream, line); if (!std::regex_search(line, match, node_re)) { - throw validity_error(); + throw ValidityError(); } if (match.length() > 2) { std::string node = match.str(2); - utils::String::split(node, nodes); + Utils::String::split(node, nodes); } } void DbcParser::parse_dbc_messages(const std::vector& lines) { std::smatch match; - std::vector signal_value; + std::vector signal_value; for (const auto& line : lines) { if (std::regex_search(line, match, message_re)) { @@ -170,18 +168,18 @@ void DbcParser::parse_dbc_messages(const std::vector& lines) { bool is_bigendian = (std::stoul(match.str(SIGNAL_ENDIAN_GROUP)) == 0); bool is_signed = (match.str(SIGNAL_SIGNED_GROUP) == "-"); - double factor = utils::String::convert_to_double(match.str(SIGNAL_FACTOR_GROUP)); - double offset = utils::String::convert_to_double(match.str(SIGNAL_OFFSET_GROUP)); - double min = utils::String::convert_to_double(match.str(SIGNAL_MIN_GROUP)); - double max = utils::String::convert_to_double(match.str(SIGNAL_MAX_GROUP)); + double factor = Utils::String::convert_to_double(match.str(SIGNAL_FACTOR_GROUP)); + double offset = Utils::String::convert_to_double(match.str(SIGNAL_OFFSET_GROUP)); + double min = Utils::String::convert_to_double(match.str(SIGNAL_MIN_GROUP)); + double max = Utils::String::convert_to_double(match.str(SIGNAL_MAX_GROUP)); std::string unit = match.str(SIGNAL_UNIT_GROUP); std::vector receivers; - utils::String::split(match.str(SIGNAL_RECIEVER_GROUP), receivers, ','); + Utils::String::split(match.str(SIGNAL_RECIEVER_GROUP), receivers, ','); Signal sig(name, is_multiplexed, start_bit, size, is_bigendian, is_signed, factor, offset, min, max, unit, receivers); - messages.back().appendSignal(sig); + messages.back().append_signal(sig); continue; } @@ -196,19 +194,19 @@ void DbcParser::parse_dbc_messages(const std::vector& lines) { std::sregex_iterator desc_iter(rest_of_descriptions.begin(), rest_of_descriptions.end(), description_re); std::sregex_iterator desc_end = std::sregex_iterator(); - std::vector values{}; + std::vector values{}; for (std::sregex_iterator i = desc_iter; i != desc_end; ++i) { std::smatch desc_match = *desc_iter; uint32_t number = static_cast(std::stoul(desc_match.str(1))); std::string text = desc_match.str(2); - values.push_back(Signal::SignalValueDescriptions{number, text}); + values.push_back(Signal::ValueDescription{number, text}); ++desc_iter; } - VALObject obj{message_id, signal_name, values}; + Value val{message_id, signal_name, values}; - signal_value.push_back(obj); + signal_value.push_back(val); continue; } } @@ -216,7 +214,7 @@ void DbcParser::parse_dbc_messages(const std::vector& lines) { for (const auto& signal : signal_value) { for (auto& msg : messages) { if (msg.id() == signal.can_id) { - msg.addValueDescription(signal.signal_name, signal.vd); + msg.add_value_description(signal.signal_name, signal.value_descriptions); break; } } diff --git a/src/message.cpp b/src/message.cpp index 791ecc9..6bfdd23 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -1,7 +1,7 @@ #include #include -namespace libdbc { +namespace Libdbc { constexpr unsigned ONE_BYTE = 8; constexpr unsigned TWO_BYTES = 16; @@ -21,7 +21,7 @@ bool Message::operator==(const Message& rhs) const { return (m_id == rhs.id()) && (m_name == rhs.m_name) && (m_size == rhs.m_size) && (m_node == rhs.m_node); } -Message::ParseSignalsStatus Message::parseSignals(const std::vector& data, std::vector& values) const { +Message::ParseSignalsStatus Message::parse_signals(const std::vector& data, std::vector& values) const { auto size = data.size(); if (size > ONE_BYTE) { return ParseSignalsStatus::ErrorMessageToLong; // not supported yet @@ -83,11 +83,11 @@ Message::ParseSignalsStatus Message::parseSignals(const std::vector& da return ParseSignalsStatus::Success; } -void Message::appendSignal(const Signal& signal) { +void Message::append_signal(const Signal& signal) { m_signals.push_back(signal); } -std::vector Message::getSignals() const { +std::vector Message::get_signals() const { return m_signals; } @@ -103,10 +103,10 @@ const std::string& Message::name() const { return m_name; } -void Message::addValueDescription(const std::string& signal_name, const std::vector& value_descriptor) { +void Message::add_value_description(const std::string& signal_name, const std::vector& value_descriptor) { for (auto& signal : m_signals) { if (signal.name == signal_name) { - signal.svDescriptions = value_descriptor; + signal.value_descriptions = value_descriptor; return; } } diff --git a/src/signal.cpp b/src/signal.cpp index edb8407..e75c457 100644 --- a/src/signal.cpp +++ b/src/signal.cpp @@ -1,6 +1,6 @@ #include -namespace libdbc { +namespace Libdbc { Signal::Signal(std::string name, bool is_multiplexed, uint32_t start_bit, diff --git a/src/utils.cpp b/src/utils.cpp index 8960e15..0519541 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -5,7 +5,7 @@ #include -namespace utils { +namespace Utils { std::istream& StreamHandler::get_line(std::istream& stream, std::string& line) { std::string newline; @@ -32,7 +32,7 @@ std::istream& StreamHandler::get_next_non_blank_line(std::istream& stream, std:: std::smatch match; while (is_blank) { - utils::StreamHandler::get_line(stream, line); + Utils::StreamHandler::get_line(stream, line); std::regex_search(line, match, whitespace_re); @@ -53,7 +53,7 @@ std::istream& StreamHandler::skip_to_next_blank_line(std::istream& stream, std:: std::smatch match; while (!line_is_empty) { - utils::StreamHandler::get_line(stream, line); + Utils::StreamHandler::get_line(stream, line); std::regex_search(line, match, whitespace_re); @@ -74,9 +74,8 @@ std::string String::trim(const std::string& line) { double String::convert_to_double(const std::string& value, double default_value) { double converted_value = default_value; - fast_float::from_chars(value.data(), - value.data() + value.size(), - converted_value); // NOLINT -- Trying to iterators on the value causes the test to infinitly hang on windows builds + // NOLINTNEXTLINE -- Trying to iterators on the value causes the test to infinitly hang on windows builds + fast_float::from_chars(value.data(), value.data() + value.size(), converted_value); return converted_value; } diff --git a/test/locale_testing/test_locale_main.cpp b/test/locale_testing/test_locale_main.cpp index 7336545..537a81f 100644 --- a/test/locale_testing/test_locale_main.cpp +++ b/test/locale_testing/test_locale_main.cpp @@ -31,7 +31,7 @@ class testRunListener : public Catch::EventListenerBase { CATCH_REGISTER_LISTENER(testRunListener) TEST_CASE("Should parse doubld string locale independently") { - REQUIRE(Catch::Approx(utils::String::convert_to_double("6.82")) == 6.82); + REQUIRE(Catch::Approx(Utils::String::convert_to_double("6.82")) == 6.82); } TEST_CASE("Should process message with floats locale indpendently") { @@ -42,36 +42,36 @@ TEST_CASE("Should process message with floats locale indpendently") { SG_ Sig4 : 7|16@0- (1,-10) [0|32767] "" Vector__XXX)"; const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); - auto parser = libdbc::DbcParser(); + auto parser = Libdbc::DbcParser(); parser.parse_file(filename); REQUIRE(parser.get_messages().size() == 1); REQUIRE(parser.get_messages().at(0).name() == "MSG1"); - REQUIRE(parser.get_messages().at(0).getSignals().size() == 4); + REQUIRE(parser.get_messages().at(0).get_signals().size() == 4); SECTION("Evaluating first message") { - const auto signal = parser.get_messages().at(0).getSignals().at(0); + const auto signal = parser.get_messages().at(0).get_signals().at(0); REQUIRE(signal.factor == 0.1); REQUIRE(signal.offset == 0); REQUIRE(signal.min == -3276.8); REQUIRE(signal.max == -3276.7); } SECTION("Evaluating second message") { - const auto signal = parser.get_messages().at(0).getSignals().at(1); + const auto signal = parser.get_messages().at(0).get_signals().at(1); REQUIRE(signal.factor == 0.1); REQUIRE(signal.offset == 0); REQUIRE(signal.min == -3276.8); REQUIRE(signal.max == -3276.7); } SECTION("Evaluating third message") { - const auto signal = parser.get_messages().at(0).getSignals().at(2); + const auto signal = parser.get_messages().at(0).get_signals().at(2); REQUIRE(signal.factor == 10); REQUIRE(signal.offset == 0); REQUIRE(signal.min == -3276.8); REQUIRE(signal.max == -3276.7); } SECTION("Evaluating fourth message") { - const auto signal = parser.get_messages().at(0).getSignals().at(3); + const auto signal = parser.get_messages().at(0).get_signals().at(3); REQUIRE(signal.factor == 1); REQUIRE(signal.offset == -10); REQUIRE(signal.min == 0); diff --git a/test/single_header_testing/test_single_header.cpp b/test/single_header_testing/test_single_header.cpp index d61dac6..e4abc6c 100644 --- a/test/single_header_testing/test_single_header.cpp +++ b/test/single_header_testing/test_single_header.cpp @@ -7,18 +7,18 @@ #include TEST_CASE("Testing dbc file loading", "[fileio]") { - auto parser = std::unique_ptr(new libdbc::DbcParser()); + auto parser = std::unique_ptr(new Libdbc::DbcParser()); SECTION("Loading a single simple dbc file", "[dbc]") { std::vector nodes = {"DBG", "DRIVER", "IO", "MOTOR", "SENSOR"}; - libdbc::Message msg(500, "IO_DEBUG", 4, "IO"); + Libdbc::Message msg(500, "IO_DEBUG", 4, "IO"); std::vector receivers{"DBG"}; - libdbc::Signal sig("IO_DEBUG_test_unsigned", false, 0, 8, false, false, 1, 0, 0, 0, "", receivers); - msg.appendSignal(sig); + Libdbc::Signal sig("IO_DEBUG_test_unsigned", false, 0, 8, false, false, 1, 0, 0, 0, "", receivers); + msg.append_signal(sig); - std::vector msgs = {msg}; + std::vector msgs = {msg}; parser->parse_file(SIMPLE_DBC_FILE); @@ -28,7 +28,7 @@ TEST_CASE("Testing dbc file loading", "[fileio]") { REQUIRE(parser->get_messages() == msgs); - REQUIRE(parser->get_messages().front().getSignals() == msg.getSignals()); + REQUIRE(parser->get_messages().front().get_signals() == msg.get_signals()); } } @@ -38,19 +38,19 @@ TEST_CASE("Testing big endian, little endian") { SG_ Sig2 : 39|16@1- (0.1,0) [-3276.8|-3276.7] "C" Vector__XXX)"; const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); - auto parser = libdbc::DbcParser(); + auto parser = Libdbc::DbcParser(); parser.parse_file(filename.c_str()); REQUIRE(parser.get_messages().size() == 1); REQUIRE(parser.get_messages().at(0).name() == "MSG1"); REQUIRE(parser.get_messages().at(0).size() == 8); - REQUIRE(parser.get_messages().at(0).getSignals().size() == 2); + REQUIRE(parser.get_messages().at(0).get_signals().size() == 2); { - const auto signal = parser.get_messages().at(0).getSignals().at(0); + const auto signal = parser.get_messages().at(0).get_signals().at(0); REQUIRE(signal.is_bigendian == true); } { - const auto signal = parser.get_messages().at(0).getSignals().at(1); + const auto signal = parser.get_messages().at(0).get_signals().at(1); REQUIRE(signal.is_bigendian == false); } } diff --git a/test/test_dbc.cpp b/test/test_dbc.cpp index ff0645f..c539dc5 100644 --- a/test/test_dbc.cpp +++ b/test/test_dbc.cpp @@ -1,3 +1,4 @@ +#include "exceptions/error.hpp" #include "testing_utils/common.hpp" #include "testing_utils/defines.hpp" #include @@ -7,18 +8,18 @@ #include TEST_CASE("Testing dbc file loading error issues", "[fileio][error]") { - auto parser = std::unique_ptr(new libdbc::DbcParser()); + auto parser = std::unique_ptr(new Libdbc::DbcParser()); SECTION("Loading a non dbc file should throw an error", "[error]") { - REQUIRE_THROWS_AS(parser->parse_file(TEXT_FILE), libdbc::validity_error); + REQUIRE_THROWS_AS(parser->parse_file(TEXT_FILE), Libdbc::ValidityError); } SECTION("Loading a dbc with bad headers throws an error", "[error]") { - REQUIRE_THROWS_AS(parser->parse_file(MISSING_VERSION_DBC_FILE), libdbc::validity_error); + REQUIRE_THROWS_AS(parser->parse_file(MISSING_VERSION_DBC_FILE), Libdbc::ValidityError); } SECTION("Loading a dbc without the required bit timing section (BS_:)", "[error]") { - REQUIRE_THROWS_AS(parser->parse_file(MISSING_BIT_TIMING_DBC_FILE), libdbc::validity_error); + REQUIRE_THROWS_AS(parser->parse_file(MISSING_BIT_TIMING_DBC_FILE), Libdbc::ValidityError); } SECTION("Loading a dbc with some missing namespace section tags (NS_ :)", "[error]") { @@ -28,27 +29,27 @@ TEST_CASE("Testing dbc file loading error issues", "[fileio][error]") { } SECTION("Verify that what() method is accessible for all exceptions", "[error]") { - auto generic_error = libdbc::exception(); + auto generic_error = Libdbc::Exception(); REQUIRE(std::string{generic_error.what()} == "libdbc exception occurred"); - auto validity_check = libdbc::validity_error(); + auto validity_check = Libdbc::ValidityError(); REQUIRE(std::string{validity_check.what()} == "Invalid DBC file"); } } TEST_CASE("Testing dbc file loading", "[fileio]") { - auto parser = std::unique_ptr(new libdbc::DbcParser()); + auto parser = std::unique_ptr(new Libdbc::DbcParser()); SECTION("Loading a single simple dbc file", "[dbc]") { std::vector nodes = {"DBG", "DRIVER", "IO", "MOTOR", "SENSOR"}; - libdbc::Message msg(500, "IO_DEBUG", 4, "IO"); + Libdbc::Message msg(500, "IO_DEBUG", 4, "IO"); std::vector receivers{"DBG"}; - libdbc::Signal sig("IO_DEBUG_test_unsigned", false, 0, 8, false, false, 1, 0, 0, 0, "", receivers); - msg.appendSignal(sig); + Libdbc::Signal sig("IO_DEBUG_test_unsigned", false, 0, 8, false, false, 1, 0, 0, 0, "", receivers); + msg.append_signal(sig); - std::vector msgs = {msg}; + std::vector msgs = {msg}; parser->parse_file(SIMPLE_DBC_FILE); @@ -58,72 +59,72 @@ TEST_CASE("Testing dbc file loading", "[fileio]") { REQUIRE(parser->get_messages() == msgs); - REQUIRE(parser->get_messages().front().getSignals() == msg.getSignals()); + REQUIRE(parser->get_messages().front().get_signals() == msg.get_signals()); } } TEST_CASE("Testing big endian, little endian") { - std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 234 MSG1: 8 Vector__XXX - SG_ Sig1 : 55|16@0- (0.1,0) [-3276.8|-3276.7] "C" Vector__XXX + std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 234 MSG1: 8 Vector__XXX + SG_ Sig1 : 55|16@0- (0.1,0) [-3276.8|-3276.7] "C" Vector__XXX SG_ Sig2 : 39|16@1- (0.1,0) [-3276.8|-3276.7] "C" Vector__XXX)"; const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); - auto parser = libdbc::DbcParser(); + auto parser = Libdbc::DbcParser(); parser.parse_file(filename.c_str()); REQUIRE(parser.get_messages().size() == 1); REQUIRE(parser.get_messages().at(0).name() == "MSG1"); REQUIRE(parser.get_messages().at(0).size() == 8); - REQUIRE(parser.get_messages().at(0).getSignals().size() == 2); + REQUIRE(parser.get_messages().at(0).get_signals().size() == 2); { - const auto signal = parser.get_messages().at(0).getSignals().at(0); + const auto signal = parser.get_messages().at(0).get_signals().at(0); REQUIRE(signal.is_bigendian == true); } { - const auto signal = parser.get_messages().at(0).getSignals().at(1); + const auto signal = parser.get_messages().at(0).get_signals().at(1); REQUIRE(signal.is_bigendian == false); } } TEST_CASE("Testing negative values") { - std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 234 MSG1: 58 Vector__XXX - SG_ Sig1 : 55|16@0- (0.1,0) [-3276.8|-3276.7] "C" Vector__XXX - SG_ Sig2 : 39|16@0- (0.1,0) [-3276.8|-3276.7] "C" Vector__XXX - SG_ Sig3 : 23|16@0- (10,0) [-3276.8|-3276.7] "C" Vector__XXX + std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 234 MSG1: 58 Vector__XXX + SG_ Sig1 : 55|16@0- (0.1,0) [-3276.8|-3276.7] "C" Vector__XXX + SG_ Sig2 : 39|16@0- (0.1,0) [-3276.8|-3276.7] "C" Vector__XXX + SG_ Sig3 : 23|16@0- (10,0) [-3276.8|-3276.7] "C" Vector__XXX SG_ Sig4 : 7|16@0- (1,-10) [0|32767] "" Vector__XXX)"; const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); - auto parser = libdbc::DbcParser(); + auto parser = Libdbc::DbcParser(); parser.parse_file(filename.c_str()); REQUIRE(parser.get_messages().size() == 1); REQUIRE(parser.get_messages().at(0).name() == "MSG1"); REQUIRE(parser.get_messages().at(0).size() == 58); - REQUIRE(parser.get_messages().at(0).getSignals().size() == 4); + REQUIRE(parser.get_messages().at(0).get_signals().size() == 4); SECTION("Evaluating first message") { - const auto signal = parser.get_messages().at(0).getSignals().at(0); + const auto signal = parser.get_messages().at(0).get_signals().at(0); REQUIRE(signal.factor == 0.1); REQUIRE(signal.offset == 0); REQUIRE(signal.min == -3276.8); REQUIRE(signal.max == -3276.7); } SECTION("Evaluating second message") { - const auto signal = parser.get_messages().at(0).getSignals().at(1); + const auto signal = parser.get_messages().at(0).get_signals().at(1); REQUIRE(signal.factor == 0.1); REQUIRE(signal.offset == 0); REQUIRE(signal.min == -3276.8); REQUIRE(signal.max == -3276.7); } SECTION("Evaluating third message") { - const auto signal = parser.get_messages().at(0).getSignals().at(2); + const auto signal = parser.get_messages().at(0).get_signals().at(2); REQUIRE(signal.factor == 10); REQUIRE(signal.offset == 0); REQUIRE(signal.min == -3276.8); REQUIRE(signal.max == -3276.7); } SECTION("Evaluating fourth message") { - const auto signal = parser.get_messages().at(0).getSignals().at(3); + const auto signal = parser.get_messages().at(0).get_signals().at(3); REQUIRE(signal.factor == 1); REQUIRE(signal.offset == -10); REQUIRE(signal.min == 0); @@ -132,109 +133,109 @@ TEST_CASE("Testing negative values") { } TEST_CASE("Special characters in unit") { - std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 234 MSG1: 255 Vector__XXX + std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 234 MSG1: 255 Vector__XXX SG_ Speed : 0|8@1+ (1,0) [0|204] "Km/h" DEVICE1,DEVICE2,DEVICE3)"; const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); - auto parser = libdbc::DbcParser(); + auto parser = Libdbc::DbcParser(); parser.parse_file(filename.c_str()); REQUIRE(parser.get_messages().size() == 1); REQUIRE(parser.get_messages().at(0).name() == "MSG1"); REQUIRE(parser.get_messages().at(0).size() == 255); - REQUIRE(parser.get_messages().at(0).getSignals().size() == 1); + REQUIRE(parser.get_messages().at(0).get_signals().size() == 1); SECTION("Checking that signal with special characters as unit is parsed correctly") { - const auto signal = parser.get_messages().at(0).getSignals().at(0); + const auto signal = parser.get_messages().at(0).get_signals().at(0); REQUIRE(signal.unit.compare("Km/h") == 0); } } TEST_CASE("Signal Value Description") { - std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 234 MSG1: 8 Vector__XXX - SG_ State1 : 0|8@1+ (1,0) [0|200] "Km/h" DEVICE1,DEVICE2,DEVICE3 - SG_ State2 : 0|8@1+ (1,0) [0|204] "" DEVICE1,DEVICE2,DEVICE3 + std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 234 MSG1: 8 Vector__XXX + SG_ State1 : 0|8@1+ (1,0) [0|200] "Km/h" DEVICE1,DEVICE2,DEVICE3 + SG_ State2 : 0|8@1+ (1,0) [0|204] "" DEVICE1,DEVICE2,DEVICE3 VAL_ 234 State1 123 "Description 1" 0 "Description 2" 90903489 "Big value and special characters &$§())!" ;)"; const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); - auto parser = libdbc::DbcParser(); + auto parser = Libdbc::DbcParser(); parser.parse_file(filename.c_str()); REQUIRE(parser.get_messages().size() == 1); REQUIRE(parser.get_messages().at(0).name() == "MSG1"); - REQUIRE(parser.get_messages().at(0).getSignals().size() == 2); - - REQUIRE(parser.get_messages().at(0).getSignals().at(0).svDescriptions.size() == 3); - REQUIRE(parser.get_messages().at(0).getSignals().at(1).svDescriptions.size() == 0); - - const auto signal = parser.get_messages().at(0).getSignals().at(0); - REQUIRE(signal.svDescriptions.at(0).value == 123); - REQUIRE(signal.svDescriptions.at(0).description == "Description 1"); - REQUIRE(signal.svDescriptions.at(1).value == 0); - REQUIRE(signal.svDescriptions.at(1).description == "Description 2"); - REQUIRE(signal.svDescriptions.at(2).value == 90903489); - REQUIRE(signal.svDescriptions.at(2).description == "Big value and special characters &$§())!"); + REQUIRE(parser.get_messages().at(0).get_signals().size() == 2); + + REQUIRE(parser.get_messages().at(0).get_signals().at(0).value_descriptions.size() == 3); + REQUIRE(parser.get_messages().at(0).get_signals().at(1).value_descriptions.size() == 0); + + const auto signal = parser.get_messages().at(0).get_signals().at(0); + REQUIRE(signal.value_descriptions.at(0).value == 123); + REQUIRE(signal.value_descriptions.at(0).description == "Description 1"); + REQUIRE(signal.value_descriptions.at(1).value == 0); + REQUIRE(signal.value_descriptions.at(1).description == "Description 2"); + REQUIRE(signal.value_descriptions.at(2).value == 90903489); + REQUIRE(signal.value_descriptions.at(2).description == "Big value and special characters &$§())!"); } TEST_CASE("Signal Value Description Extended CAN id") { - std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 3221225472 MSG1: 8 Vector__XXX - SG_ State1 : 0|8@1+ (1,0) [0|200] "Km/h" DEVICE1,DEVICE2,DEVICE3 - SG_ State2 : 0|8@1+ (1,0) [0|204] "" DEVICE1,DEVICE2,DEVICE3 + std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 3221225472 MSG1: 8 Vector__XXX + SG_ State1 : 0|8@1+ (1,0) [0|200] "Km/h" DEVICE1,DEVICE2,DEVICE3 + SG_ State2 : 0|8@1+ (1,0) [0|204] "" DEVICE1,DEVICE2,DEVICE3 VAL_ 3221225472 State1 123 "Description 1" 0 "Description 2" 4000000000 "Big value and special characters &$§())!" ;)"; const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); - auto parser = libdbc::DbcParser(); + auto parser = Libdbc::DbcParser(); parser.parse_file(filename.c_str()); REQUIRE(parser.get_messages().size() == 1); REQUIRE(parser.get_messages().at(0).name() == "MSG1"); - REQUIRE(parser.get_messages().at(0).getSignals().size() == 2); - - REQUIRE(parser.get_messages().at(0).getSignals().at(0).svDescriptions.size() == 3); - REQUIRE(parser.get_messages().at(0).getSignals().at(1).svDescriptions.size() == 0); - - const auto signal = parser.get_messages().at(0).getSignals().at(0); - REQUIRE(signal.svDescriptions.at(0).value == 123); - REQUIRE(signal.svDescriptions.at(0).description == "Description 1"); - REQUIRE(signal.svDescriptions.at(1).value == 0); - REQUIRE(signal.svDescriptions.at(1).description == "Description 2"); - REQUIRE(signal.svDescriptions.at(2).value == 4000000000); - REQUIRE(signal.svDescriptions.at(2).description == "Big value and special characters &$§())!"); + REQUIRE(parser.get_messages().at(0).get_signals().size() == 2); + + REQUIRE(parser.get_messages().at(0).get_signals().at(0).value_descriptions.size() == 3); + REQUIRE(parser.get_messages().at(0).get_signals().at(1).value_descriptions.size() == 0); + + const auto signal = parser.get_messages().at(0).get_signals().at(0); + REQUIRE(signal.value_descriptions.at(0).value == 123); + REQUIRE(signal.value_descriptions.at(0).description == "Description 1"); + REQUIRE(signal.value_descriptions.at(1).value == 0); + REQUIRE(signal.value_descriptions.at(1).description == "Description 2"); + REQUIRE(signal.value_descriptions.at(2).value == 4000000000); + REQUIRE(signal.value_descriptions.at(2).description == "Big value and special characters &$§())!"); } TEST_CASE("Signal Value Multiple VAL_") { - std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 3221225472 MSG1: 8 Vector__XXX - SG_ State1 : 0|8@1+ (1,0) [0|200] "Km/h" DEVICE1,DEVICE2,DEVICE3 - SG_ State2 : 0|8@1+ (1,0) [0|204] "" DEVICE1,DEVICE2,DEVICE3" -BO_ 123 MSG2: 8 Vector__XXX - SG_ State1 : 0|8@1+ (1,0) [0|200] "Km/h" DEVICE1,DEVICE2,DEVICE3 - SG_ State2 : 0|8@1+ (1,0) [0|204] "" DEVICE1,DEVICE2,DEVICE3 -VAL_ 3221225472 State1 123 "Description 1" 0 "Description 2" ; + std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 3221225472 MSG1: 8 Vector__XXX + SG_ State1 : 0|8@1+ (1,0) [0|200] "Km/h" DEVICE1,DEVICE2,DEVICE3 + SG_ State2 : 0|8@1+ (1,0) [0|204] "" DEVICE1,DEVICE2,DEVICE3" +BO_ 123 MSG2: 8 Vector__XXX + SG_ State1 : 0|8@1+ (1,0) [0|200] "Km/h" DEVICE1,DEVICE2,DEVICE3 + SG_ State2 : 0|8@1+ (1,0) [0|204] "" DEVICE1,DEVICE2,DEVICE3 +VAL_ 3221225472 State1 123 "Description 1" 0 "Description 2" ; VAL_ 123 State1 123 "Description 3" 0 "Description 4" ;)"; const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); - auto parser = libdbc::DbcParser(); + auto parser = Libdbc::DbcParser(); parser.parse_file(filename.c_str()); REQUIRE(parser.get_messages().size() == 2); REQUIRE(parser.get_messages().at(0).name() == "MSG1"); REQUIRE(parser.get_messages().at(1).name() == "MSG2"); - REQUIRE(parser.get_messages().at(0).getSignals().size() == 2); + REQUIRE(parser.get_messages().at(0).get_signals().size() == 2); - REQUIRE(parser.get_messages().at(0).getSignals().at(0).svDescriptions.size() == 2); - REQUIRE(parser.get_messages().at(0).getSignals().at(1).svDescriptions.size() == 0); - REQUIRE(parser.get_messages().at(1).getSignals().at(0).svDescriptions.size() == 2); - REQUIRE(parser.get_messages().at(1).getSignals().at(1).svDescriptions.size() == 0); + REQUIRE(parser.get_messages().at(0).get_signals().at(0).value_descriptions.size() == 2); + REQUIRE(parser.get_messages().at(0).get_signals().at(1).value_descriptions.size() == 0); + REQUIRE(parser.get_messages().at(1).get_signals().at(0).value_descriptions.size() == 2); + REQUIRE(parser.get_messages().at(1).get_signals().at(1).value_descriptions.size() == 0); - const auto signal = parser.get_messages().at(0).getSignals().at(0); - REQUIRE(signal.svDescriptions.at(0).value == 123); - REQUIRE(signal.svDescriptions.at(0).description == "Description 1"); - REQUIRE(signal.svDescriptions.at(1).value == 0); - REQUIRE(signal.svDescriptions.at(1).description == "Description 2"); + const auto signal = parser.get_messages().at(0).get_signals().at(0); + REQUIRE(signal.value_descriptions.at(0).value == 123); + REQUIRE(signal.value_descriptions.at(0).description == "Description 1"); + REQUIRE(signal.value_descriptions.at(1).value == 0); + REQUIRE(signal.value_descriptions.at(1).description == "Description 2"); - const auto signal2 = parser.get_messages().at(1).getSignals().at(0); - REQUIRE(signal2.svDescriptions.at(0).value == 123); - REQUIRE(signal2.svDescriptions.at(0).description == "Description 3"); - REQUIRE(signal2.svDescriptions.at(1).value == 0); - REQUIRE(signal2.svDescriptions.at(1).description == "Description 4"); + const auto signal2 = parser.get_messages().at(1).get_signals().at(0); + REQUIRE(signal2.value_descriptions.at(0).value == 123); + REQUIRE(signal2.value_descriptions.at(0).description == "Description 3"); + REQUIRE(signal2.value_descriptions.at(1).value == 0); + REQUIRE(signal2.value_descriptions.at(1).description == "Description 4"); } diff --git a/test/test_parse_message.cpp b/test/test_parse_message.cpp index 3c3c301..aad3b1c 100644 --- a/test/test_parse_message.cpp +++ b/test/test_parse_message.cpp @@ -19,12 +19,12 @@ BO_ 123 MSG2: 8 Vector__XXX )"; const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); - libdbc::DbcParser parser; + Libdbc::DbcParser parser; parser.parse_file(filename.c_str()); SECTION("Evaluating unknown` message id") { std::vector out_values; - CHECK(parser.parseMessage(578, std::vector({0xFF, 0xA2}), out_values) == libdbc::Message::ParseSignalsStatus::ErrorUnknownID); + CHECK(parser.parse_message(578, std::vector({0xFF, 0xA2}), out_values) == Libdbc::Message::ParseSignalsStatus::ErrorUnknownID); } } @@ -40,12 +40,12 @@ TEST_CASE("Parse Message Big Number not aligned little endian") { )"; const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); - libdbc::DbcParser parser; + Libdbc::DbcParser parser; parser.parse_file(filename); SECTION("Evaluating first message") { std::vector out_values; - CHECK(parser.parseMessage(337, std::vector({0, 4, 252, 19, 0, 0, 0, 0}), out_values) == libdbc::Message::ParseSignalsStatus::Success); + CHECK(parser.parse_message(337, std::vector({0, 4, 252, 19, 0, 0, 0, 0}), out_values) == Libdbc::Message::ParseSignalsStatus::Success); std::vector refData{2, 0, 0, 1, 0, 0, 0}; CHECK(refData.size() == 7); CHECK(out_values.size() == refData.size()); @@ -56,7 +56,7 @@ TEST_CASE("Parse Message Big Number not aligned little endian") { SECTION("Evaluating second message") { std::vector out_values; - CHECK(parser.parseMessage(337, std::vector({47, 4, 60, 29, 0, 0, 0, 0}), out_values) == libdbc::Message::ParseSignalsStatus::Success); + CHECK(parser.parse_message(337, std::vector({47, 4, 60, 29, 0, 0, 0, 0}), out_values) == Libdbc::Message::ParseSignalsStatus::Success); std::vector refData{3, 32, 0, 1, 0, 0, 47}; CHECK(refData.size() == 7); CHECK(out_values.size() == refData.size()); @@ -67,7 +67,7 @@ TEST_CASE("Parse Message Big Number not aligned little endian") { SECTION("Evaluating third message") { std::vector out_values; - CHECK(parser.parseMessage(337, std::vector({57, 4, 250, 29, 0, 0, 0, 0}), out_values) == libdbc::Message::ParseSignalsStatus::Success); + CHECK(parser.parse_message(337, std::vector({57, 4, 250, 29, 0, 0, 0, 0}), out_values) == Libdbc::Message::ParseSignalsStatus::Success); std::vector refData{3, 51, 0, 1, 0, 0, 57}; CHECK(refData.size() == 7); CHECK(out_values.size() == refData.size()); @@ -85,12 +85,12 @@ TEST_CASE("Parse Message little endian") { SG_ SOC : 16|16@1+ (0.01,0) [0|100] "%" DEVICE1)"; const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); - libdbc::DbcParser parser; + Libdbc::DbcParser parser; parser.parse_file(filename); std::vector data{0x08, 0x27, 0xa3, 0x22, 0xe5, 0x1f, 0x45, 0x14}; // little endian std::vector result_values; - REQUIRE(parser.parseMessage(0x21d, data, result_values) == libdbc::Message::ParseSignalsStatus::Success); + REQUIRE(parser.parse_message(0x21d, data, result_values) == Libdbc::Message::ParseSignalsStatus::Success); REQUIRE(result_values.size() == 4); REQUIRE(Catch::Approx(result_values.at(0)) == 11.89); @@ -115,12 +115,12 @@ TEST_CASE("Parse Message big endian signed values") { SG_ Sig12 : 23|16@0+ (0.1,0) [0|6553.5] "A" Vector__XXX)"; const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); - libdbc::DbcParser p; + Libdbc::DbcParser p; p.parse_file(filename.c_str()); std::vector data{13, 177, 0, 216, 251, 180, 0, 31}; // big endian std::vector result_values; - REQUIRE(p.parseMessage(545, data, result_values) == libdbc::Message::ParseSignalsStatus::Success); + REQUIRE(p.parse_message(545, data, result_values) == Libdbc::Message::ParseSignalsStatus::Success); REQUIRE(result_values.size() == 12); REQUIRE(Catch::Approx(result_values.at(0)) == 0); REQUIRE(Catch::Approx(result_values.at(1)) == 0); @@ -144,12 +144,12 @@ TEST_CASE("Parse Message with non byte aligned values") { SG_ Id_Current : 0|10@1- (1,0) [-512|512] "A" Vector__XXX)"; const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); - libdbc::DbcParser p; + Libdbc::DbcParser p; p.parse_file(filename); std::vector data{131, 51, 33, 9, 33, 0, 0, 0}; std::vector result_values; - REQUIRE(p.parseMessage(403, data, result_values) == libdbc::Message::ParseSignalsStatus::Success); + REQUIRE(p.parse_message(403, data, result_values) == Libdbc::Message::ParseSignalsStatus::Success); REQUIRE(result_values.size() == 4); REQUIRE(Catch::Approx(result_values.at(0)) == 26.4); REQUIRE(Catch::Approx(result_values.at(1)) == 146); @@ -163,12 +163,12 @@ TEST_CASE("Parse Message data length < 8 unsigned") { SG_ Msg1Sig2 : 15|8@0+ (1,0) [-3276.8|-3276.7] "km/h" Vector__XXX)"; const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); - libdbc::DbcParser p; + Libdbc::DbcParser p; p.parse_file(filename); std::vector data{0x1, 0x2}; std::vector result_values; - REQUIRE(p.parseMessage(234, data, result_values) == libdbc::Message::ParseSignalsStatus::Success); + REQUIRE(p.parse_message(234, data, result_values) == Libdbc::Message::ParseSignalsStatus::Success); REQUIRE(result_values.size() == 2); REQUIRE(Catch::Approx(result_values.at(0)) == 0x1); REQUIRE(Catch::Approx(result_values.at(1)) == 0x2); diff --git a/test/test_utils.cpp b/test/test_utils.cpp index fe7a064..c03dcd7 100644 --- a/test/test_utils.cpp +++ b/test/test_utils.cpp @@ -4,7 +4,7 @@ #include -using namespace utils; +namespace Utils { TEST_CASE("Basic file input with safe get_line that is non line ending specific", "") { SECTION("Verify various line ending input files") { @@ -32,15 +32,15 @@ TEST_CASE("Basic file input with safe get_line that is non line ending specific" TEST_CASE("Test line finding utility functions", "") { std::string line; std::string test_string = - "hello\n\ - \n\ - \n\ - \n\ -this is not blank\n\ -maybe not this one either\n\ -\n\ -Someone wrote something....\n\ - b\n\ + "hello\n\ + \n\ + \n\ + \n\ +this is not blank\n\ +maybe not this one either\n\ +\n\ +Someone wrote something....\n\ + b\n\ end"; std::istringstream stream(test_string); @@ -91,3 +91,5 @@ TEST_CASE("Test string split feature", "[string]") { REQUIRE(v == vs); } + +} // Utils From 120927ae7e6fbb4bbc8c47c31668b19c323a023b Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sat, 16 Mar 2024 18:34:49 -0400 Subject: [PATCH 108/131] fix: Adding include checks in clang-tidy and fixing all the issues --- .clang-tidy | 2 +- include/libdbc/dbc.hpp | 10 +++++----- include/libdbc/message.hpp | 2 +- include/libdbc/utils/utils.hpp | 3 --- src/dbc.cpp | 6 +++++- src/message.cpp | 7 ++++++- src/signal.cpp | 4 ++++ src/utils.cpp | 6 +++--- test/test_utils.cpp | 2 +- 9 files changed, 26 insertions(+), 16 deletions(-) diff --git a/.clang-tidy b/.clang-tidy index 2b65fe4..3f85e19 100644 --- a/.clang-tidy +++ b/.clang-tidy @@ -1,5 +1,5 @@ --- -Checks: 'clang-diagnostic-*,clang-analyzer-*,-*,clang-analyzer-*,clang-analyzer-cplusplus*,cert-*,cppcoreguidelines-*,portability-*,readability-*,clang-diagnostic-*' +Checks: 'clang-diagnostic-*,clang-analyzer-*,-*,clang-analyzer-*,clang-analyzer-cplusplus*,cert-*,cppcoreguidelines-*,portability-*,readability-*,clang-diagnostic-*,misc-include-cleaner' WarningsAsErrors: '' HeaderFilterRegex: '' AnalyzeTemporaryDtors: false diff --git a/include/libdbc/dbc.hpp b/include/libdbc/dbc.hpp index 060e9f7..d58c8c0 100644 --- a/include/libdbc/dbc.hpp +++ b/include/libdbc/dbc.hpp @@ -1,12 +1,12 @@ #ifndef DBC_HPP #define DBC_HPP -#include -#include -#include -#include - +#include #include +#include +#include +#include +#include namespace Libdbc { diff --git a/include/libdbc/message.hpp b/include/libdbc/message.hpp index 9ef29a5..edfd7c1 100644 --- a/include/libdbc/message.hpp +++ b/include/libdbc/message.hpp @@ -1,11 +1,11 @@ #ifndef MESSAGE_HPP #define MESSAGE_HPP -#include #include #include #include #include +#include namespace Libdbc { struct Message { diff --git a/include/libdbc/utils/utils.hpp b/include/libdbc/utils/utils.hpp index d626d83..fd2fba2 100644 --- a/include/libdbc/utils/utils.hpp +++ b/include/libdbc/utils/utils.hpp @@ -2,10 +2,7 @@ #ifndef UTILS_HPP #define UTILS_HPP -#include -#include #include -#include #include #include diff --git a/src/dbc.cpp b/src/dbc.cpp index 75e607d..360f05c 100644 --- a/src/dbc.cpp +++ b/src/dbc.cpp @@ -1,9 +1,13 @@ #include +#include +#include #include #include +#include +#include #include - #include +#include #include namespace Libdbc { diff --git a/src/message.cpp b/src/message.cpp index 6bfdd23..ffe4526 100644 --- a/src/message.cpp +++ b/src/message.cpp @@ -1,5 +1,10 @@ +#include #include #include +#include +#include +#include +#include namespace Libdbc { @@ -29,7 +34,7 @@ Message::ParseSignalsStatus Message::parse_signals(const std::vector& d uint64_t data_little_endian = 0; uint64_t data_big_endian = 0; - for (size_t i = 0; i < size; i++) { + for (std::size_t i = 0; i < size; i++) { data_little_endian |= ((uint64_t)data[i]) << i * ONE_BYTE; data_big_endian = (data_big_endian << ONE_BYTE) | (uint64_t)data[i]; } diff --git a/src/signal.cpp b/src/signal.cpp index e75c457..d40bf2f 100644 --- a/src/signal.cpp +++ b/src/signal.cpp @@ -1,4 +1,8 @@ +#include #include +#include +#include +#include namespace Libdbc { Signal::Signal(std::string name, diff --git a/src/utils.cpp b/src/utils.cpp index 0519541..eed3134 100644 --- a/src/utils.cpp +++ b/src/utils.cpp @@ -1,9 +1,9 @@ -#include -#include +#include #include +#include #include - #include +#include namespace Utils { diff --git a/test/test_utils.cpp b/test/test_utils.cpp index c03dcd7..af4929c 100644 --- a/test/test_utils.cpp +++ b/test/test_utils.cpp @@ -1,7 +1,7 @@ #include "testing_utils/defines.hpp" #include +#include #include - #include namespace Utils { From caa15c85f5a1ce52682433d34492b46d23fa2651 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sat, 16 Mar 2024 18:38:40 -0400 Subject: [PATCH 109/131] fix(format): Formatting after adding / fixing includes --- include/libdbc/dbc.hpp | 4 ++-- include/libdbc/message.hpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/include/libdbc/dbc.hpp b/include/libdbc/dbc.hpp index d58c8c0..68e9789 100644 --- a/include/libdbc/dbc.hpp +++ b/include/libdbc/dbc.hpp @@ -2,11 +2,11 @@ #define DBC_HPP #include +#include +#include #include #include #include -#include -#include namespace Libdbc { diff --git a/include/libdbc/message.hpp b/include/libdbc/message.hpp index edfd7c1..438dc7f 100644 --- a/include/libdbc/message.hpp +++ b/include/libdbc/message.hpp @@ -1,11 +1,11 @@ #ifndef MESSAGE_HPP #define MESSAGE_HPP +#include #include #include #include #include -#include namespace Libdbc { struct Message { From cc1ec260d5e4979385f208d90fe669f8be1a1c25 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sat, 16 Mar 2024 18:45:24 -0400 Subject: [PATCH 110/131] feat(ci): adding ubuntu 20.04 cmake test --- .github/workflows/pipeline.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index d63a1e1..7ab424b 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -202,3 +202,18 @@ jobs: - name: Run clang-tidy check run: cmake --build build --target clang-tidy-check + check-against-minimum-cmake: + runs-on: ubuntu-20.04 + + steps: + - uses: actions/checkout@v4 + + - name: Cmake version + run: cmake --version + + - name: Make build directory + run: cmake -Bbuild -H$GITHUB_WORKSPACE + + - name: Run clang-tidy check + run: cmake --build build + From e670522158f738b40fc1636bea2aff2b38f3c8e3 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sat, 16 Mar 2024 18:52:04 -0400 Subject: [PATCH 111/131] fix(ci): install the specific cmake version of 16 --- .github/workflows/pipeline.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 7ab424b..71f9766 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -203,13 +203,17 @@ jobs: run: cmake --build build --target clang-tidy-check check-against-minimum-cmake: - runs-on: ubuntu-20.04 + runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - name: Cmake version - run: cmake --version + - name: Cmake install + run: | + wget https://github.com/Kitware/CMake/releases/download/v3.16.9/cmake-3.16.9-linux-x86_64.sh + chmod +x cmake-3.16.9-linux-x86_64.sh + sudo ./cmake-3.16.9-linux-x86_64.sh --skip-license --prefix=/usr/local + cmake --version - name: Make build directory run: cmake -Bbuild -H$GITHUB_WORKSPACE From 8b366fe4c50c1759471c41a39e9b6aca79998a41 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sat, 16 Mar 2024 18:54:50 -0400 Subject: [PATCH 112/131] fix(build): Removing incompatibilities of 3.16 cmake --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 539e72b..a53d602 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,7 +85,7 @@ target_include_directories(${PROJECT_NAME} PUBLIC ) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) -target_sources(${PROJECT_NAME} INTERFACE FILE_SET HEADERS +target_sources(${PROJECT_NAME} INTERFACE HEADERS TYPE HEADERS BASE_DIRS ${PROJECT_SOURCE_DIR}/include/libdbc FILES ${HEADER_FILES} From 2d4c42c2fd7eec69accf6808dcff731b09568f9e Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sat, 16 Mar 2024 18:59:09 -0400 Subject: [PATCH 113/131] fix(build): Fix the target_sources after removing FILE_SET --- CMakeLists.txt | 6 +----- test/test_dbc.cpp | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index a53d602..079dc86 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -85,11 +85,7 @@ target_include_directories(${PROJECT_NAME} PUBLIC ) target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_11) -target_sources(${PROJECT_NAME} INTERFACE HEADERS - TYPE HEADERS - BASE_DIRS ${PROJECT_SOURCE_DIR}/include/libdbc - FILES ${HEADER_FILES} -) +target_sources(${PROJECT_NAME} INTERFACE ${HEADER_FILES}) if(DBC_GENERATE_SINGLE_HEADER) add_custom_target(single_header ALL diff --git a/test/test_dbc.cpp b/test/test_dbc.cpp index c539dc5..5fd2515 100644 --- a/test/test_dbc.cpp +++ b/test/test_dbc.cpp @@ -1,10 +1,10 @@ -#include "exceptions/error.hpp" #include "testing_utils/common.hpp" #include "testing_utils/defines.hpp" #include #include #include #include +#include #include TEST_CASE("Testing dbc file loading error issues", "[fileio][error]") { From 00df6ba442b28adbf333d700729cf310cfcf80e8 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sat, 16 Mar 2024 19:09:34 -0400 Subject: [PATCH 114/131] feat: Bump version to 0.3.0 for release --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 079dc86..2d4fb58 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.16) # Keep this on one line for release checking -project(dbc VERSION 0.2.0 DESCRIPTION "C++ DBC Parser") +project(dbc VERSION 0.3.0 DESCRIPTION "C++ DBC Parser") # -- PROJECT OPTIONS -- # option(DBC_ENABLE_TESTS "Enable Unittests" ON) From 9d421415285222ee0cdbf7bd586a56cc58d7ecaf Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sat, 16 Mar 2024 19:48:08 -0400 Subject: [PATCH 115/131] feat: Allow empty BU_: nodes --- .github/workflows/pipeline.yml | 2 +- src/dbc.cpp | 2 +- test/test_dbc.cpp | 27 +++++++++++++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 71f9766..49c3b6e 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -218,6 +218,6 @@ jobs: - name: Make build directory run: cmake -Bbuild -H$GITHUB_WORKSPACE - - name: Run clang-tidy check + - name: Run build run: cmake --build build diff --git a/src/dbc.cpp b/src/dbc.cpp index 360f05c..bfbc177 100644 --- a/src/dbc.cpp +++ b/src/dbc.cpp @@ -59,7 +59,7 @@ DbcParser::DbcParser() : version_re("^(VERSION)\\s\"(.*)\"") , bit_timing_re("^(BS_:)") , name_space_re("^(NS_)\\s\\:") - , node_re("^(BU_:)\\s((?:[\\w]+?\\s?)*)") + , node_re("^(BU_:)\\s?((?:[\\w]+?\\s?)*)?") , message_re("^(BO_)\\s(\\d+)\\s(\\w+)\\:\\s(\\d+)\\s(\\w+|Vector__XXX)") , value_re("^(VAL_)\\s(\\d+)\\s(\\w+)((?:\\s(\\d+)\\s\"([^\"]*)\")+)\\s;$") , diff --git a/test/test_dbc.cpp b/test/test_dbc.cpp index 5fd2515..19e6b5e 100644 --- a/test/test_dbc.cpp +++ b/test/test_dbc.cpp @@ -239,3 +239,30 @@ VAL_ 123 State1 123 "Description 3" 0 "Description 4" ;)"; REQUIRE(signal2.value_descriptions.at(1).value == 0); REQUIRE(signal2.value_descriptions.at(1).description == "Description 4"); } + +TEST_CASE("Should parse DBC with empty BU_") { + std::string contents = R"(VERSION "" + + +NS_ : + +BS_: + +BU_: + + +BO_ 293 Msg1: 2 Vector__XXX + SG_ Wert7 : 0|16@1- (1,0) [0|0] "" Vector__XXX + +BO_ 292 Msg2: 8 Vector__XXX + SG_ Wert8 : 56|8@1- (1,0) [0|0] "" Vector__XXX +)"; + const auto filename = create_temporary_dbc_with(contents.c_str()); + + auto parser = Libdbc::DbcParser(); + parser.parse_file(filename.c_str()); + + REQUIRE(parser.get_messages().size() == 2); + REQUIRE(parser.get_messages().at(0).name() == "Msg1"); + REQUIRE(parser.get_messages().at(1).name() == "Msg2"); +} From 58669c99551f5be1831a1157b1bd562bf5d4932c Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Tue, 19 Mar 2024 16:22:51 -0400 Subject: [PATCH 116/131] Exception error cleanup (#24) * feat(error): Adding non dbc file format error (extension based), Missing version header error added Fixed the tests so that they now make .dbc files since we are checking the extensions. * feat(error): Adding a missing bit timing error class * feat(error): Adding lines we attempted to parse and more error messaging for the Exceptions * test: Updating tests names to be more clear at what is being validated. * feat(parsing): Adding a way to push and read all of the unused lines since we don't error out on unused * fix(format): Running code format * fix: Fixing clang-tidy warnings --- include/libdbc/dbc.hpp | 6 +++ include/libdbc/exceptions/error.hpp | 44 ++++++++++++++++++ src/dbc.cpp | 32 ++++++++++--- test/dbcs/MissingVersion.dbc | 72 ++++++++++++++--------------- test/test_dbc.cpp | 59 +++++++++++++++++++---- test/testing_utils/common.cpp | 2 +- 6 files changed, 164 insertions(+), 51 deletions(-) diff --git a/include/libdbc/dbc.hpp b/include/libdbc/dbc.hpp index 68e9789..2dfe7bf 100644 --- a/include/libdbc/dbc.hpp +++ b/include/libdbc/dbc.hpp @@ -31,6 +31,8 @@ class DbcParser : public Parser { Message::ParseSignalsStatus parse_message(uint32_t message_id, const std::vector& data, std::vector& out_values); + std::vector unused_lines() const; + private: std::string version; std::vector nodes; @@ -44,9 +46,13 @@ class DbcParser : public Parser { std::regex value_re; std::regex signal_re; + std::vector 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& lines); + + static std::string get_extension(const std::string& file_name); }; } diff --git a/include/libdbc/exceptions/error.hpp b/include/libdbc/exceptions/error.hpp index 27e2fa4..03fd5a0 100644 --- a/include/libdbc/exceptions/error.hpp +++ b/include/libdbc/exceptions/error.hpp @@ -2,6 +2,7 @@ #define ERROR_HPP #include +#include namespace Libdbc { @@ -19,6 +20,49 @@ class ValidityError : public Exception { } }; +class NonDbcFileFormatError : public ValidityError { +public: + NonDbcFileFormatError(const std::string& path, const std::string& extension) { + error_msg = {"File is not of DBC format. Expected a .dbc extension. Cannot read this type of file (" + path + "). Found the extension (" + extension + + ")."}; + } + + const char* what() const throw() override { + return error_msg.c_str(); + } + +private: + std::string error_msg; +}; + +class DbcFileIsMissingVersion : public ValidityError { +public: + DbcFileIsMissingVersion(const std::string& line) { + error_msg = {"Invalid dbc file. Missing the required version header. Attempting to read line: (" + line + ")."}; + } + + const char* what() const throw() override { + return error_msg.c_str(); + } + +private: + std::string error_msg; +}; + +class DbcFileIsMissingBitTiming : public ValidityError { +public: + DbcFileIsMissingBitTiming(const std::string& line) { + error_msg = {"Invalid dbc file. Missing required bit timing in the header. Attempting to read line: (" + line + ")."}; + } + + const char* what() const throw() override { + return error_msg.c_str(); + } + +private: + std::string error_msg; +}; + } // libdbc #endif // ERROR_HPP diff --git a/src/dbc.cpp b/src/dbc.cpp index bfbc177..108ab7e 100644 --- a/src/dbc.cpp +++ b/src/dbc.cpp @@ -1,4 +1,5 @@ #include +#include #include #include #include @@ -76,8 +77,12 @@ void DbcParser::parse_file(const std::string& file) { messages.clear(); - parse_dbc_header(stream); + auto extension = get_extension(file); + if (extension != ".dbc") { + throw NonDbcFileFormatError(file, extension); + } + parse_dbc_header(stream); parse_dbc_nodes(stream); while (!stream.eof()) { @@ -88,6 +93,15 @@ void DbcParser::parse_file(const std::string& file) { parse_dbc_messages(lines); } +std::string DbcParser::get_extension(const std::string& file_name) { + std::size_t dot = file_name.find_last_of("."); + if (dot != std::string::npos) { + return file_name.substr(dot, file_name.size() - dot); + } + + return ""; +} + std::string DbcParser::get_version() const { return version; } @@ -116,7 +130,7 @@ void DbcParser::parse_dbc_header(std::istream& file_stream) { Utils::StreamHandler::get_line(file_stream, line); if (!std::regex_search(line, match, version_re)) { - throw ValidityError(); + throw DbcFileIsMissingVersion(line); } version = match.str(2); @@ -126,7 +140,7 @@ void DbcParser::parse_dbc_header(std::istream& file_stream) { Utils::StreamHandler::get_next_non_blank_line(file_stream, line); if (!std::regex_search(line, match, bit_timing_re)) { - throw ValidityError(); + throw DbcFileIsMissingBitTiming(line); } } @@ -136,9 +150,7 @@ void DbcParser::parse_dbc_nodes(std::istream& file_stream) { Utils::StreamHandler::get_next_non_blank_line(file_stream, line); - if (!std::regex_search(line, match, node_re)) { - throw ValidityError(); - } + std::regex_search(line, match, node_re); if (match.length() > 2) { std::string node = match.str(2); @@ -213,6 +225,10 @@ void DbcParser::parse_dbc_messages(const std::vector& lines) { signal_value.push_back(val); continue; } + + if (line.length() > 0) { + missed_lines.push_back(line); + } } for (const auto& signal : signal_value) { @@ -225,4 +241,8 @@ void DbcParser::parse_dbc_messages(const std::vector& lines) { } } +std::vector DbcParser::unused_lines() const { + return missed_lines; +} + } diff --git a/test/dbcs/MissingVersion.dbc b/test/dbcs/MissingVersion.dbc index 0db087a..40d5967 100644 --- a/test/dbcs/MissingVersion.dbc +++ b/test/dbcs/MissingVersion.dbc @@ -1,36 +1,36 @@ -NS_ : - BA_ - BA_DEF_ - BA_DEF_DEF_ - BA_DEF_DEF_REL_ - BA_DEF_REL_ - BA_DEF_SGTYPE_ - BA_REL_ - BA_SGTYPE_ - BO_TX_BU_ - BU_BO_REL_ - BU_EV_REL_ - BU_SG_REL_ - CAT_ - CAT_DEF_ - CM_ - ENVVAR_DATA_ - EV_DATA_ - FILTER - NS_DESC_ - SGTYPE_ - SGTYPE_VAL_ - SG_MUL_VAL_ - SIGTYPE_VALTYPE_ - SIG_GROUP_ - SIG_TYPE_REF_ - SIG_VALTYPE_ - VAL_ - VAL_TABLE_ - -BS_: - -BU_: DBG DRIVER IO MOTOR SENSOR - -BO_ 500 IO_DEBUG: 4 IO - SG_ IO_DEBUG_test_unsigned : 0|8@1+ (1,0) [0|0] "" DBG \ No newline at end of file +NS_ : + BA_ + BA_DEF_ + BA_DEF_DEF_ + BA_DEF_DEF_REL_ + BA_DEF_REL_ + BA_DEF_SGTYPE_ + BA_REL_ + BA_SGTYPE_ + BO_TX_BU_ + BU_BO_REL_ + BU_EV_REL_ + BU_SG_REL_ + CAT_ + CAT_DEF_ + CM_ + ENVVAR_DATA_ + EV_DATA_ + FILTER + NS_DESC_ + SGTYPE_ + SGTYPE_VAL_ + SG_MUL_VAL_ + SIGTYPE_VALTYPE_ + SIG_GROUP_ + SIG_TYPE_REF_ + SIG_VALTYPE_ + VAL_ + VAL_TABLE_ + +BS_: + +BU_: DBG DRIVER IO MOTOR SENSOR + +BO_ 500 IO_DEBUG: 4 IO + SG_ IO_DEBUG_test_unsigned : 0|8@1+ (1,0) [0|0] "" DBG diff --git a/test/test_dbc.cpp b/test/test_dbc.cpp index 19e6b5e..8ae1b54 100644 --- a/test/test_dbc.cpp +++ b/test/test_dbc.cpp @@ -3,29 +3,35 @@ #include #include #include +#include #include #include #include +using Catch::Matchers::ContainsSubstring; + TEST_CASE("Testing dbc file loading error issues", "[fileio][error]") { auto parser = std::unique_ptr(new Libdbc::DbcParser()); SECTION("Loading a non dbc file should throw an error", "[error]") { - REQUIRE_THROWS_AS(parser->parse_file(TEXT_FILE), Libdbc::ValidityError); + REQUIRE_THROWS_AS(parser->parse_file(TEXT_FILE), Libdbc::NonDbcFileFormatError); + REQUIRE_THROWS_WITH(parser->parse_file(TEXT_FILE), ContainsSubstring("TextFile.txt")); } - SECTION("Loading a dbc with bad headers throws an error", "[error]") { - REQUIRE_THROWS_AS(parser->parse_file(MISSING_VERSION_DBC_FILE), Libdbc::ValidityError); + SECTION("Loading a dbc with missing version header throws an error (VERSION)", "[error]") { + REQUIRE_THROWS_AS(parser->parse_file(MISSING_VERSION_DBC_FILE), Libdbc::DbcFileIsMissingVersion); + REQUIRE_THROWS_WITH(parser->parse_file(MISSING_VERSION_DBC_FILE), ContainsSubstring("line: (NS_ :)")); } SECTION("Loading a dbc without the required bit timing section (BS_:)", "[error]") { - REQUIRE_THROWS_AS(parser->parse_file(MISSING_BIT_TIMING_DBC_FILE), Libdbc::ValidityError); + REQUIRE_THROWS_AS(parser->parse_file(MISSING_BIT_TIMING_DBC_FILE), Libdbc::DbcFileIsMissingBitTiming); + REQUIRE_THROWS_WITH(parser->parse_file(MISSING_BIT_TIMING_DBC_FILE), ContainsSubstring("BU_: DBG DRIVER IO MOTOR SENSOR")); } SECTION("Loading a dbc with some missing namespace section tags (NS_ :)", "[error]") { // Confusion about this type of error. it appears that the header isn't // very well standardized for now we ignore this type of error. - CHECK_NOTHROW(parser->parse_file(MISSING_NEW_SYMBOLS_DBC_FILE)); + REQUIRE_NOTHROW(parser->parse_file(MISSING_NEW_SYMBOLS_DBC_FILE)); } SECTION("Verify that what() method is accessible for all exceptions", "[error]") { @@ -240,7 +246,7 @@ VAL_ 123 State1 123 "Description 3" 0 "Description 4" ;)"; REQUIRE(signal2.value_descriptions.at(1).description == "Description 4"); } -TEST_CASE("Should parse DBC with empty BU_") { +TEST_CASE("Should parse DBC with empty BU_", "[error][optional]") { std::string contents = R"(VERSION "" @@ -254,15 +260,52 @@ NS_ : BO_ 293 Msg1: 2 Vector__XXX SG_ Wert7 : 0|16@1- (1,0) [0|0] "" Vector__XXX -BO_ 292 Msg2: 8 Vector__XXX +BO_ 292 Msg2: 1 Vector__XXX SG_ Wert8 : 56|8@1- (1,0) [0|0] "" Vector__XXX )"; const auto filename = create_temporary_dbc_with(contents.c_str()); auto parser = Libdbc::DbcParser(); - parser.parse_file(filename.c_str()); + REQUIRE_NOTHROW(parser.parse_file(filename.c_str())); REQUIRE(parser.get_messages().size() == 2); REQUIRE(parser.get_messages().at(0).name() == "Msg1"); REQUIRE(parser.get_messages().at(1).name() == "Msg2"); } + +TEST_CASE("Should report unused lines since we don't have tracing.", "[parsing]") { + std::string contents = R"(VERSION "" + +NS_ : + +BS_: + +BU_: + + +BO_ 293 Msg1: 2 Vector__XXX + SG_ Whitespace: | 0|16@1- (1,0) [0|0] "" Vector__XXX + SG_ Wert7 : 0|16@1- (1,0) [0|0] "" Vector__XXX + SG_ Wert8 : 0|16@1- (1,0) [0|0] "" Vector__XXX + +BO_ 292 Msg2: 1 Vector__XXX + SG_ Wert8 : 56|8@1- (1,0) [0|0] "" Vector__XXX + SB_ not a correct line + +BO_ have a issue here: +)"; + + const auto filename = create_temporary_dbc_with(contents.c_str()); + + auto parser = Libdbc::DbcParser(); + REQUIRE_NOTHROW(parser.parse_file(filename.c_str())); + + REQUIRE(parser.get_messages().size() == 2); + REQUIRE(parser.get_messages()[0].size() == 2); + REQUIRE(parser.get_messages()[1].size() == 1); + + auto unused = parser.unused_lines(); + + // We could match them all here but i think just a check that the size is sufficent. + REQUIRE(unused.size() == 3); +} diff --git a/test/testing_utils/common.cpp b/test/testing_utils/common.cpp index e058054..4c3ef54 100644 --- a/test/testing_utils/common.cpp +++ b/test/testing_utils/common.cpp @@ -23,7 +23,7 @@ std::string generate_unique_filename() { int random_num = dis(gen); // Concatenate time and random number to create a unique filename - return "temp_file_" + std::to_string(milliseconds) + "_" + std::to_string(random_num) + ".txt"; + return "temp_file_" + std::to_string(milliseconds) + "_" + std::to_string(random_num) + ".dbc"; } std::string create_temporary_dbc_with(const char* contents) { From cc4e80c7b6e1f7a13cc47b45f226756f823888e2 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Tue, 19 Mar 2024 16:35:07 -0400 Subject: [PATCH 117/131] feat: Bump to version 0.4.0 for release --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2d4fb58..cbf2d37 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.16) # Keep this on one line for release checking -project(dbc VERSION 0.3.0 DESCRIPTION "C++ DBC Parser") +project(dbc VERSION 0.4.0 DESCRIPTION "C++ DBC Parser") # -- PROJECT OPTIONS -- # option(DBC_ENABLE_TESTS "Enable Unittests" ON) From 57da1f7aa29c09828a9835c02f4d9f8f69dcd3ad Mon Sep 17 00:00:00 2001 From: Stefan Gerlach Date: Fri, 10 May 2024 00:08:14 +0200 Subject: [PATCH 118/131] Update CMakeLists.txt (#26) Fix CMake error "install DIRECTORY given no DESTINATION!" --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index cbf2d37..ea27c35 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -95,6 +95,7 @@ if(DBC_GENERATE_SINGLE_HEADER) endif() ## Installation +include(GNUInstallDirs) # install lib install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) From f08e688e6162fa227f0367d591ce9e15d99e7ee4 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Tue, 21 May 2024 17:32:38 -0400 Subject: [PATCH 119/131] fix: Set the ubuntu runner to 22.04 to keep the same compiler version Probably should setup the job to setup the gcc version instead but for now this works. --- .github/workflows/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 49c3b6e..bb94b75 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -9,7 +9,7 @@ env: jobs: linux-builds: name: linux ${{matrix.cxx}}, C++${{matrix.std}}, ${{matrix.build_type}} - runs-on: ubuntu-latest + runs-on: ubuntu-22.04 strategy: fail-fast: false matrix: From eea0184f4d919d364bec5b9b27e9d42f6121ec9c Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Tue, 21 May 2024 17:40:13 -0400 Subject: [PATCH 120/131] fix(CI): Bump gcc to 14, add debug print, and set the mac os to 12 --- .github/workflows/pipeline.yml | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index bb94b75..29e1951 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -14,13 +14,13 @@ jobs: fail-fast: false matrix: cxx: - - g++-13 + - g++-14 - clang++-16 build_type: [Debug, Release] std: [11] include: - - cxx: g++-13 - cc: gcc-13 + - cxx: g++-14 + cc: gcc-14 - cxx: clang++-16 cc: clang-16 llvm_version: 16 @@ -48,6 +48,11 @@ jobs: curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y source "$HOME/.cargo/env" + - name: Print gcc version + run: | + which gcc + gcc --version + - name: Configure build env: CC: ${{matrix.cc}} @@ -114,7 +119,7 @@ jobs: macos-builds: name: macos ${{matrix.cxx}}, C++${{matrix.std}}, ${{matrix.build_type}} - runs-on: macos-latest + runs-on: macos-12 strategy: fail-fast: false matrix: From c79a284ccf68947818130f467c50d02716244b24 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Tue, 21 May 2024 17:41:56 -0400 Subject: [PATCH 121/131] fix(CI): Change gcc to 11 which is default installed on ubuntu 22 --- .github/workflows/pipeline.yml | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 29e1951..cc0cf9e 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -14,13 +14,13 @@ jobs: fail-fast: false matrix: cxx: - - g++-14 + - g++-11 - clang++-16 build_type: [Debug, Release] std: [11] include: - - cxx: g++-14 - cc: gcc-14 + - cxx: g++-11 + cc: gcc-11 - cxx: clang++-16 cc: clang-16 llvm_version: 16 @@ -49,9 +49,7 @@ jobs: source "$HOME/.cargo/env" - name: Print gcc version - run: | - which gcc - gcc --version + run: gcc --version - name: Configure build env: From a58f04c0448ba71d9b725fb3a2119df0f35d425b Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Tue, 21 May 2024 17:49:33 -0400 Subject: [PATCH 122/131] feat(CI): Run cmake install for all OS --- .github/workflows/pipeline.yml | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index cc0cf9e..881138c 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -73,6 +73,10 @@ jobs: CTEST_OUTPUT_ON_FAILURE: 1 run: ctest --output-on-failure --test-dir build -j `nproc` + - name: Run install + run: cmake --install . + + windows-build: name: ${{matrix.os}}, ${{matrix.std}}, ${{matrix.build_type}}, ${{matrix.platform}} runs-on: ${{matrix.os}} @@ -115,6 +119,9 @@ jobs: run: ctest --output-on-failure --test-dir build -j %NUMBER_OF_PROCESSORS% shell: cmd + - name: Run install + run: cmake --install . + macos-builds: name: macos ${{matrix.cxx}}, C++${{matrix.std}}, ${{matrix.build_type}} runs-on: macos-12 @@ -162,6 +169,9 @@ jobs: working-directory: ${{runner.workspace}} run: ctest --output-on-failure --test-dir build -j `sysctl -n hw.ncpu` -V + - name: Run install + run: cmake --install . + format-check: runs-on: ubuntu-latest From 2e974178f598e615f65a6ad1a00f7d926823deb2 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Tue, 21 May 2024 17:53:50 -0400 Subject: [PATCH 123/131] fix(CI): fix the cmake build path for the install command --- .github/workflows/pipeline.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 881138c..15f21e4 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -74,7 +74,7 @@ jobs: run: ctest --output-on-failure --test-dir build -j `nproc` - name: Run install - run: cmake --install . + run: cmake --install build windows-build: @@ -120,7 +120,7 @@ jobs: shell: cmd - name: Run install - run: cmake --install . + run: cmake --install build macos-builds: name: macos ${{matrix.cxx}}, C++${{matrix.std}}, ${{matrix.build_type}} @@ -170,7 +170,7 @@ jobs: run: ctest --output-on-failure --test-dir build -j `sysctl -n hw.ncpu` -V - name: Run install - run: cmake --install . + run: cmake --install build format-check: runs-on: ubuntu-latest From 6d6288550fb0226c8b9c65a69c6421b25f4ab42f Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Tue, 21 May 2024 17:58:04 -0400 Subject: [PATCH 124/131] fix(CI): In the pipeline we only can install on linux and need to pass the prefix to avoid permission issues --- .github/workflows/pipeline.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 15f21e4..f36b26d 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -74,7 +74,7 @@ jobs: run: ctest --output-on-failure --test-dir build -j `nproc` - name: Run install - run: cmake --install build + run: cmake --install build --prefix . windows-build: @@ -119,9 +119,6 @@ jobs: run: ctest --output-on-failure --test-dir build -j %NUMBER_OF_PROCESSORS% shell: cmd - - name: Run install - run: cmake --install build - macos-builds: name: macos ${{matrix.cxx}}, C++${{matrix.std}}, ${{matrix.build_type}} runs-on: macos-12 @@ -169,9 +166,6 @@ jobs: working-directory: ${{runner.workspace}} run: ctest --output-on-failure --test-dir build -j `sysctl -n hw.ncpu` -V - - name: Run install - run: cmake --install build - format-check: runs-on: ubuntu-latest From 0dbe4541e99b81049ef7109d1670e37a67b41a8a Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 26 May 2024 16:38:42 -0400 Subject: [PATCH 125/131] feat: Parse dbc with istream (#30) * feat: Add an istream interface to the avoid the ifstream creation given a file name * fix: formatting the code base to fix checks and clang-tidy errors --- include/libdbc/dbc.hpp | 4 +++- src/dbc.cpp | 19 +++++++++------ .../test_single_header.cpp | 24 +++++++++++++++++++ 3 files changed, 39 insertions(+), 8 deletions(-) diff --git a/include/libdbc/dbc.hpp b/include/libdbc/dbc.hpp index 2dfe7bf..5e0e9e4 100644 --- a/include/libdbc/dbc.hpp +++ b/include/libdbc/dbc.hpp @@ -15,6 +15,7 @@ class Parser { virtual ~Parser() = default; virtual void parse_file(const std::string& file) = 0; + virtual void parse_file(std::istream& file) = 0; protected: }; @@ -23,7 +24,8 @@ class DbcParser : public Parser { public: DbcParser(); - void parse_file(const std::string& file) override; + void parse_file(const std::string& file_name) override; + void parse_file(std::istream& stream) override; std::string get_version() const; std::vector get_nodes() const; diff --git a/src/dbc.cpp b/src/dbc.cpp index 108ab7e..c6baae5 100644 --- a/src/dbc.cpp +++ b/src/dbc.cpp @@ -70,18 +70,12 @@ DbcParser::DbcParser() + whiteSpace + receiverPattern) { } -void DbcParser::parse_file(const std::string& file) { - std::ifstream stream(file.c_str()); +void DbcParser::parse_file(std::istream& stream) { std::string line; std::vector lines; messages.clear(); - auto extension = get_extension(file); - if (extension != ".dbc") { - throw NonDbcFileFormatError(file, extension); - } - parse_dbc_header(stream); parse_dbc_nodes(stream); @@ -93,6 +87,17 @@ void DbcParser::parse_file(const std::string& file) { parse_dbc_messages(lines); } +void DbcParser::parse_file(const std::string& file_name) { + auto extension = get_extension(file_name); + if (extension != ".dbc") { + throw NonDbcFileFormatError(file_name, extension); + } + + std::ifstream stream(file_name.c_str()); + + parse_file(stream); +} + std::string DbcParser::get_extension(const std::string& file_name) { std::size_t dot = file_name.find_last_of("."); if (dot != std::string::npos) { diff --git a/test/single_header_testing/test_single_header.cpp b/test/single_header_testing/test_single_header.cpp index e4abc6c..c512d35 100644 --- a/test/single_header_testing/test_single_header.cpp +++ b/test/single_header_testing/test_single_header.cpp @@ -54,3 +54,27 @@ TEST_CASE("Testing big endian, little endian") { REQUIRE(signal.is_bigendian == false); } } + +TEST_CASE("Testing file stream mirrors the filename interface") { + std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 234 MSG1: 8 Vector__XXX + SG_ Sig1 : 55|16@0- (0.1,0) [-3276.8|-3276.7] "C" Vector__XXX + SG_ Sig2 : 39|16@1- (0.1,0) [-3276.8|-3276.7] "C" Vector__XXX)"; + const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); + std::ifstream file(filename.c_str()); + + auto parser = Libdbc::DbcParser(); + parser.parse_file(file); + + REQUIRE(parser.get_messages().size() == 1); + REQUIRE(parser.get_messages().at(0).name() == "MSG1"); + REQUIRE(parser.get_messages().at(0).size() == 8); + REQUIRE(parser.get_messages().at(0).get_signals().size() == 2); + { + const auto signal = parser.get_messages().at(0).get_signals().at(0); + REQUIRE(signal.is_bigendian == true); + } + { + const auto signal = parser.get_messages().at(0).get_signals().at(1); + REQUIRE(signal.is_bigendian == false); + } +} From 1bfead321ec4f10a5dd371c8d05769da6a0a78a2 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Sun, 26 May 2024 16:45:59 -0400 Subject: [PATCH 126/131] fix: Crashed when BO_ and the message content were on different lines --- src/dbc.cpp | 4 ++-- test/test_parse_message.cpp | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/src/dbc.cpp b/src/dbc.cpp index 108ab7e..f19fe25 100644 --- a/src/dbc.cpp +++ b/src/dbc.cpp @@ -176,7 +176,7 @@ void DbcParser::parse_dbc_messages(const std::vector& lines) { continue; } - if (std::regex_search(line, match, signal_re)) { + if (std::regex_search(line, match, signal_re) && messages.size() > 0) { std::string name = match.str(SIGNAL_NAME_GROUP); bool is_multiplexed = false; // No support yet uint32_t start_bit = static_cast(std::stoul(match.str(SIGNAL_START_BIT_GROUP))); @@ -199,7 +199,7 @@ void DbcParser::parse_dbc_messages(const std::vector& lines) { continue; } - if (std::regex_search(line, match, value_re)) { + if (std::regex_search(line, match, value_re) && messages.size() > 0) { uint32_t message_id = static_cast(std::stoul(match.str(2))); std::string signal_name = match.str(3); diff --git a/test/test_parse_message.cpp b/test/test_parse_message.cpp index aad3b1c..08d68f3 100644 --- a/test/test_parse_message.cpp +++ b/test/test_parse_message.cpp @@ -173,3 +173,39 @@ TEST_CASE("Parse Message data length < 8 unsigned") { REQUIRE(Catch::Approx(result_values.at(0)) == 0x1); REQUIRE(Catch::Approx(result_values.at(1)) == 0x2); } + +TEST_CASE("Parse message with BO_ on single line should fail.") { + std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ +234 MSG1: 8 Vector__XXX + SG_ State1 : 0|8@1+ (1,0) [0|200] "Km/h" DEVICE1,DEVICE2,DEVICE3 + SG_ State2 : 0|8@1+ (1,0) [0|204] "" DEVICE1,DEVICE2,DEVICE3 +VAL_ 234 State1 123 "Description 1" 0 "Description 2" 90903489 "Big value and special characters &$§())!")"; + const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); + + Libdbc::DbcParser p; + p.parse_file(filename); + + std::vector data{0x1, 0x2}; + std::vector result_values; + REQUIRE(p.get_messages().size() == 0); + REQUIRE(p.parse_message(234, data, result_values) == Libdbc::Message::ParseSignalsStatus::ErrorUnknownID); +} + +TEST_CASE("Parse signal with SG_ on single line should fail.") { + std::string dbc_contents = PRIMITIVE_DBC + R"(BO_ 234 MSG1: 8 Vector__XXX + SG_ +State1 : 0|8@1+ (1,0) [0|200] "Km/h" DEVICE1,DEVICE2,DEVICE3 + SG_ State2 : 0|8@1+ (1,0) [0|204] "" DEVICE1,DEVICE2,DEVICE3 +VAL_ 234 State1 123 "Description 1" 0 "Description 2" 90903489 "Big value and special characters &$§())!")"; + const auto filename = create_temporary_dbc_with(dbc_contents.c_str()); + + Libdbc::DbcParser p; + p.parse_file(filename); + + std::vector data{0x1, 0x2}; + std::vector result_values; + REQUIRE(p.get_messages().size() == 1); + REQUIRE(p.parse_message(234, data, result_values) == Libdbc::Message::ParseSignalsStatus::Success); + REQUIRE(result_values.size() == 1); + REQUIRE(Catch::Approx(result_values.at(0)) == 0x1); +} From ceeef752101dccfa045106592f17dedaf64c9656 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Thu, 27 Jun 2024 18:17:25 -0400 Subject: [PATCH 127/131] fix(checks): Fixing clang warnings about size comparison on the vector. Should have been just a empty check. --- src/dbc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/dbc.cpp b/src/dbc.cpp index 2d999da..89e8c24 100644 --- a/src/dbc.cpp +++ b/src/dbc.cpp @@ -181,7 +181,7 @@ void DbcParser::parse_dbc_messages(const std::vector& lines) { continue; } - if (std::regex_search(line, match, signal_re) && messages.size() > 0) { + if (std::regex_search(line, match, signal_re) && !messages.empty()) { std::string name = match.str(SIGNAL_NAME_GROUP); bool is_multiplexed = false; // No support yet uint32_t start_bit = static_cast(std::stoul(match.str(SIGNAL_START_BIT_GROUP))); @@ -204,7 +204,7 @@ void DbcParser::parse_dbc_messages(const std::vector& lines) { continue; } - if (std::regex_search(line, match, value_re) && messages.size() > 0) { + if (std::regex_search(line, match, value_re) && !messages.empty()) { uint32_t message_id = static_cast(std::stoul(match.str(2))); std::string signal_name = match.str(3); From 887d779fbf416032f539675f74360a5a43a93f86 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Thu, 27 Jun 2024 18:19:17 -0400 Subject: [PATCH 128/131] chore(version): Version bump to v0.5.0 --- CMakeLists.txt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ea27c35..551af92 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,7 +1,7 @@ cmake_minimum_required(VERSION 3.16) # Keep this on one line for release checking -project(dbc VERSION 0.4.0 DESCRIPTION "C++ DBC Parser") +project(dbc VERSION 0.5.0 DESCRIPTION "C++ DBC Parser") # -- PROJECT OPTIONS -- # option(DBC_ENABLE_TESTS "Enable Unittests" ON) @@ -95,7 +95,6 @@ if(DBC_GENERATE_SINGLE_HEADER) endif() ## Installation -include(GNUInstallDirs) # install lib install(TARGETS ${PROJECT_NAME} DESTINATION ${CMAKE_INSTALL_LIBDIR}) From 17b3e3dd121f3dc13f07a3cc0d9a19ce7b138ece Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Wed, 10 Sep 2025 21:52:33 -0400 Subject: [PATCH 129/131] Add manual workflow dispatch to CI pipeline --- .github/workflows/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index f36b26d..0947cd6 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -1,6 +1,6 @@ name: Libdbc Pipeline -on: [push, workflow_call] +on: [push, workflow_call, workflow_dispatch] env: # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) From 316686831a1a064fedebdd77f8fd4e6d9b183db3 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Wed, 10 Sep 2025 21:54:48 -0400 Subject: [PATCH 130/131] Enable pull_request to trigger CI pipeline --- .github/workflows/pipeline.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index 0947cd6..d24e09a 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -1,6 +1,6 @@ name: Libdbc Pipeline -on: [push, workflow_call, workflow_dispatch] +on: [push, pull_request, workflow_call, workflow_dispatch] env: # Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.) From 2c8acdbd2d1ea33545f99f9a0d23e10b7f8e0852 Mon Sep 17 00:00:00 2001 From: Devon Adair Date: Fri, 12 Sep 2025 10:29:36 -0400 Subject: [PATCH 131/131] Update windows runner to 2025 and mac runners to 15 (#35) --- .github/workflows/pipeline.yml | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/.github/workflows/pipeline.yml b/.github/workflows/pipeline.yml index d24e09a..3f96f40 100644 --- a/.github/workflows/pipeline.yml +++ b/.github/workflows/pipeline.yml @@ -83,7 +83,7 @@ jobs: strategy: fail-fast: false matrix: - os: [windows-2019, windows-2022] + os: [windows-2025, windows-2022] platform: [Win32, x64] build_type: [Debug, Release] std: [11] @@ -120,11 +120,12 @@ jobs: shell: cmd macos-builds: - name: macos ${{matrix.cxx}}, C++${{matrix.std}}, ${{matrix.build_type}} - runs-on: macos-12 + name: ${{matrix.os}}, ${{matrix.cxx}}, C++${{matrix.std}}, ${{matrix.build_type}} + runs-on: ${{matrix.os}} strategy: fail-fast: false matrix: + os: [macos-15-large] cxx: - g++ - clang++