File tree Expand file tree Collapse file tree 2 files changed +18
-28
lines changed Expand file tree Collapse file tree 2 files changed +18
-28
lines changed Original file line number Diff line number Diff line change 22#include " util/utils.hpp"
33
44#include < regex>
5+ #include < iostream>
56
67namespace libdbc {
78
@@ -19,7 +20,7 @@ namespace libdbc {
1920 class DbcParser : public Parser {
2021 public:
2122 DbcParser () : version(" " ), version_re(" ^(VERSION)\\ s\" (.*)\" " ),
22- bit_timing_re (" ^(BS_:)" ), name_space_re(" ^(_NS )\\ s \\ :" ) {
23+ bit_timing_re (" ^(BS_:)" ), name_space_re(" ^(NS_ )\\ s\\ :" ) {
2324
2425 }
2526
@@ -50,38 +51,13 @@ namespace libdbc {
5051 const std::regex name_space_re;
5152
5253 void parse_dbc_header (std::istream& file_stream) {
54+ std::vector<std::string> lines;
55+
5356 std::string line;
5457 std::smatch match;
5558 bool is_blank = true ;
5659 bool not_blank = true ;
5760
58- std::vector<std::string> symbols = {" CM_" ,
59- " BA_DEF_" ,
60- " BA_" ,
61- " VAL" ,
62- " CAT_DEF_" ,
63- " CAT_" ,
64- " FILTER" ,
65- " BA_DEF_DEF_" ,
66- " EV_DATA_" ,
67- " ENVVAR_DATA_" ,
68- " SGTYPE_" ,
69- " SGTYPE_VALTYPE_" ,
70- " BA_DEF_SGTYPE_" ,
71- " BA_SGTYPE_" ,
72- " SIG_TYPE_REF_" ,
73- " VAL_TABLE_" ,
74- " SIG_GROUP_" ,
75- " SIG_VALTYPE_" ,
76- " SIGTYPE_VALTYPE_" ,
77- " BO_TX_BU_" ,
78- " BA_DEF_REL_" ,
79- " BA_REL_" ,
80- " BA_DEF_DEF_REL_" ,
81- " BU_SG_REL_" ,
82- " BU_EV_REL_" ,
83- " BU_BO_REL_" };
84-
8561 utils::StreamHandler::get_line (file_stream, line);
8662
8763 if (!std::regex_search (line, match, version_re)) {
@@ -100,9 +76,17 @@ namespace libdbc {
10076 throw validity_error ();
10177
10278 }
79+ std::string trim (const std::string& line)
80+ {
81+ const char * WhiteSpace = " \t\v\r\n " ;
82+ std::size_t start = line.find_first_not_of (WhiteSpace);
83+ std::size_t end = line.find_last_not_of (WhiteSpace);
84+ return start == end ? std::string () : line.substr (start, end - start + 1 );
85+ }
10386
10487 };
10588
89+
10690 struct Message {
10791
10892 };
Original file line number Diff line number Diff line change @@ -16,6 +16,12 @@ TEST_CASE("Testing dbc file loading error issues", "[fileio][error]") {
1616 SECTION (" Loading a dbc without the required bit timing section (BS_:)" , " [error]" ) {
1717 REQUIRE_THROWS_AS (parser->parse_file (MISSING_BIT_TIMING_DBC_FILE), libdbc::validity_error);
1818 }
19+
20+ SECTION (" Loading a dbc with some missing namespace section tags (_NS :)" , " [error]" ) {
21+ // Confusion about this type of error. it appears that the header isn't
22+ // very well standardized for now we ignore this type of error.
23+ CHECK_NOTHROW (parser->parse_file (MISSING_NEW_SYMBOLS_DBC_FILE));
24+ }
1925}
2026
2127TEST_CASE (" Testing dbc file loading" , " [fileio]" ) {
You can’t perform that action at this time.
0 commit comments