File tree Expand file tree Collapse file tree 9 files changed +89
-15
lines changed
Expand file tree Collapse file tree 9 files changed +89
-15
lines changed Original file line number Diff line number Diff line change 11cmake_minimum_required (VERSION 3.10)
22
3- project (DBC )
3+ project (dbc )
44
55# specify the C++ standard
66set (CMAKE_CXX_STANDARD 11)
77set (CMAKE_CXX_STANDARD_REQUIRED True )
88
9- # Add in the debug flag
9+ # Add in the debug flag0.
1010set (GCC_COVERAGE_COMPILE_FLAGS "-g" )
1111set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${GCC_COVERAGE_COMPILE_FLAGS} " )
1212
@@ -19,3 +19,4 @@ include_directories(include)
1919add_subdirectory (test )
2020add_subdirectory (doc )
2121
22+ add_library (${PROJECT_NAME} STATIC ${SOURCE} )
Original file line number Diff line number Diff line change 1- # C++ DBC Header Only File Parser
1+ # C++ DBC Parser
22
33This is to provide a library header only file to read in DBC files. I was looking around and couldn't
44find a simple library that didn't have dependencies. So here we are making one. I got some inspiration
Original file line number Diff line number Diff line change 1+ #include " exceptions/error.hpp"
12
2- namespace dbc {
3+ namespace libdbc {
34
4- class parser {
5+ class Parser {
6+ public:
7+ virtual ~Parser () = default ;
58
6- };
9+ virtual void parse_file (const std::string& file) = 0;
10+ };
11+
12+ class DbcParser : public Parser {
13+ public:
14+ virtual ~DbcParser () = default ;
15+
16+ virtual void parse_file (const std::string& file) final override {
17+ throw validity_error ();
18+ }
19+
20+ };
721
822}
Original file line number Diff line number Diff line change 1+
2+ namespace libdbc {
3+
4+ class exception : public std ::exception {
5+ const char * what () const throw() {
6+ return " libdbc exception occurred" ;
7+ }
8+ };
9+
10+ class validity_error : public exception {
11+ const char * what () const throw() {
12+ return " invalid file issue" ;
13+ }
14+ };
15+
16+ } // libdbc
Original file line number Diff line number Diff line change 11project (tests VERSION 0.1.0)
22
33list (APPEND TEST_SOURCES main.cpp
4- test_file_loading .cpp
4+ test_dbc .cpp
55 test_utils.cpp)
66
77include_directories (SYSTEM ${PROJECT_SOURCE_DIR} /third_party/Catch2/single_include)
Original file line number Diff line number Diff line change 1+ VERSION ""
2+
3+ NS_ :
4+ BA_
5+ BA_DEF_
6+ BA_DEF_DEF_
7+ BA_DEF_DEF_REL_
8+ BA_DEF_REL_
9+ BA_DEF_SGTYPE_
10+ BA_REL_
11+ BA_SGTYPE_
12+ BO_TX_BU_
13+ BU_BO_REL_
14+ BU_EV_REL_
15+ BU_SG_REL_
16+ CAT_
17+ CAT_DEF_
18+ CM_
19+ ENVVAR_DATA_
20+ EV_DATA_
21+ FILTER
22+ NS_DESC_
23+ SGTYPE_
24+ SGTYPE_VAL_
25+ SG_MUL_VAL_
26+ SIGTYPE_VALTYPE_
27+ SIG_GROUP_
28+ SIG_TYPE_REF_
29+ SIG_VALTYPE_
30+ VAL_
31+ VAL_TABLE_
32+
33+ BS_:
34+
35+ BU_: DBG DRIVER IO MOTOR SENSOR
36+
37+ BO_ 500 IO_DEBUG: 4 IO
38+ SG_ IO_DEBUG_test_unsigned : 0|8@1+ (1,0) [0|0] "" DBG
Original file line number Diff line number Diff line change 11#include < string>
22
3- static const std::string TEXT_FILE = " ./dbcs/TextFile.txt" ;
3+ static const std::string TEXT_FILE = " ./dbcs/TextFile.txt" ;
4+ static const std::string DBC_FILE_1 = " ./dbcs/Sample1.dbc" ;
5+ static const std::string DBC_FILE_2 = " ./dbcs/Sample2.dbc" ;
Original file line number Diff line number Diff line change 1+ #include < catch2/catch.hpp>
2+ #include " defines.hpp"
3+ #include " dbc.hpp"
4+
5+ TEST_CASE (" Load a simple 1 line message dbc" , " [fileio]" ) {
6+ auto parser = std::unique_ptr<libdbc::DbcParser>(new libdbc::DbcParser ());
7+
8+ REQUIRE_THROWS_AS (parser->parse_file (DBC_FILE_2), libdbc::validity_error);
9+
10+ }
Load Diff This file was deleted.
You can’t perform that action at this time.
0 commit comments