Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit961c15b

Browse files
committed
Added more specific value tables handling.
1 parentcb9137e commit961c15b

File tree

6 files changed

+33
-4
lines changed

6 files changed

+33
-4
lines changed

‎src/parser/dbclineparser.cpp‎

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
#include"dbclineparser.h"
2+
#include<helpers/formatter.h>
3+
#include<stdlib.h>
24
#include<clocale>
35
#include<regex>
46
#include<math.h>
@@ -515,7 +517,7 @@ bool DbcLineParser::ParseAttributeLine(AttributeDescriptor_t* attr, const std::s
515517
return ret;
516518
}
517519

518-
boolDbcLineParser::ParseValTableLine(Comment_t* comm,const std::string& line)
520+
boolDbcLineParser::ParseValTableLine(Comment_t* comm,const std::string& line, ValTable_t& vtab)
519521
{
520522
bool ret =false;
521523

@@ -546,10 +548,17 @@ bool DbcLineParser::ParseValTableLine(Comment_t* comm, const std::string& line)
546548
comm->Text ="";
547549
comm->ca_target = CommentTarget::Signal;
548550

551+
// prepare value table container
552+
vtab.SigName = items[2];
553+
vtab.vpairs.clear();
554+
549555
for (size_t valpair =3; valpair < (items.size() -1); valpair +=2)
550556
{
551557
comm->Text +="" + items[valpair +0] +" :";
552558
comm->Text += items[valpair +1] +'\n';
559+
560+
auto valdef =make_c_name(items[valpair +1]);
561+
vtab.vpairs.push_back({valdef, (uint32_t)atoll((items[valpair +0]).c_str())});
553562
}
554563

555564
if (comm->Text.size() >0)

‎src/parser/dbclineparser.h‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,8 +65,9 @@ class DbcLineParser {
6565
boolParseCommentLine(Comment_t* cm,const std::string& line);
6666

6767
// tries to parse value table string in line
68-
// and load result to attr ValueStr, return true if parsed ok
69-
boolParseValTableLine(Comment_t* cm,const std::string& line);
68+
// saves result as comment text in @cm object, and as
69+
// pairs of items (definition / value) in @vtab
70+
boolParseValTableLine(Comment_t* cm,const std::string& line, ValTable_t& vtab);
7071

7172
/**
7273
* @brief tries to find string with information about frame which has

‎src/parser/dbcscanner.cpp‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ void DbcScanner::ParseOtherInfo(istream& readstrm)
154154

155155
Comment_t cmmnt;
156156

157+
ValTable_t vals;
158+
157159
AttributeDescriptor_t attr;
158160

159161
while (!readstrm.eof())
@@ -229,7 +231,7 @@ void DbcScanner::ParseOtherInfo(istream& readstrm)
229231
}
230232
}
231233

232-
if (lparser.ParseValTableLine(&cmmnt, sline))
234+
if (lparser.ParseValTableLine(&cmmnt, sline, vals))
233235
{
234236
// update message comment field
235237
auto msg =find_message(dblist.msgs, cmmnt.MsgId);
@@ -250,6 +252,8 @@ void DbcScanner::ParseOtherInfo(istream& readstrm)
250252
{
251253
// signal has been found, update commnet text
252254
msg->Signals[i].ValueText = cmmnt.Text;
255+
// save collected value table's definitions to signal
256+
msg->Signals[i].ValDefs = vals;
253257
}
254258
}
255259
}

‎src/parser/dbcscanner.h‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,7 @@ class DbcScanner {
3131

3232
DbcLineParser lparser;
3333

34+
// this variable is used for gathering value table signal's information
35+
std::pair<std::string,uint32_t> vpairs;
36+
3437
};

‎src/types/comment.h‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
#include<stdint.h>
44
#include<string>
5+
#include<vector>
56

67
enumclassCommentTarget
78
{
@@ -27,3 +28,12 @@ typedef struct
2728
std::string Text;
2829

2930
} Comment_t;
31+
32+
33+
typedefstruct
34+
{
35+
std::string SigName;
36+
37+
std::vector<std::pair<std::string,uint32_t>> vpairs{};
38+
39+
} ValTable_t;

‎src/types/message.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ typedef struct
8383

8484
std::vector<std::string> RecS;
8585

86+
ValTable_t ValDefs;
87+
8688
std::string CommentText;
8789

8890
std::string ValueText;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp