Skip to content

Commit

Permalink
Enable Filter Regex Replacement also for exporting into DLT format.
Browse files Browse the repository at this point in the history
Signed-off-by: Alexander Wenzel <[email protected]>
  • Loading branch information
alexmucde committed Oct 9, 2024
1 parent 5058ad8 commit c63c391
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 0 deletions.
8 changes: 8 additions & 0 deletions qdlt/qdltexporter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,14 @@ void QDltExporter::exportMessages(QDltFile *from, QFile *to, QDltPluginManager *
}
}

// apply Regex if needed
if(exportFormat == QDltExporter::FormatDlt || exportFormat == QDltExporter::FormatDltDecoded)
{
msg.setNumberOfArguments(msg.sizeArguments());
if(from) from->applyRegExStringMsg(msg);
msg.getMsg(buf,true);
}

// export message
if(!exportMsg(starting,msg,buf))
{
Expand Down
5 changes: 5 additions & 0 deletions qdlt/qdltfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -759,3 +759,8 @@ bool QDltFile::applyRegExString(QString &text)
{
return filterList.applyRegExString(text);
}

bool QDltFile::applyRegExStringMsg(QDltMsg &msg)
{
return filterList.applyRegExStringMsg(msg);
}
5 changes: 5 additions & 0 deletions qdlt/qdltfile.h
Original file line number Diff line number Diff line change
Expand Up @@ -304,6 +304,11 @@ class QDLT_EXPORT QDltFile : public QDlt
*/
bool applyRegExString(QString &text);

//! Apply RegEx Replace to the arguments of a message, if any active in the filters
/*!
*/
bool applyRegExStringMsg(QDltMsg &msg);

protected:

private:
Expand Down
31 changes: 31 additions & 0 deletions qdlt/qdltfilterlist.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,37 @@ bool QDltFilterList::applyRegExString(QString &text)
return result;
}

bool QDltFilterList::applyRegExStringMsg(QDltMsg &msg)
{
QDltFilter *filter;
bool result = false;

for(int numfilter=0;numfilter<pfilters.size();numfilter++)
{
filter = pfilters[numfilter];

if(filter->enableFilter && filter->enableRegexSearchReplace)
{
for(int num=0;num<msg.getNumberOfArguments();num++)
{
QDltArgument arg;
msg.getArgument(num,arg);
if(arg.getTypeInfo()==QDltArgument::DltTypeInfoStrg || arg.getTypeInfo()==QDltArgument::DltTypeInfoUtf8)
{
QString text = arg.getValue().toString();
text.replace(QRegularExpression(filter->regex_search), filter->regex_replace);
arg.setValue(text);
msg.removeArgument(num);
msg.addArgument(arg,num);
}
}

result = true;
}
}
return result;
}

bool QDltFilterList::checkFilter(QDltMsg &msg)
{
QDltFilter *filter;
Expand Down
5 changes: 5 additions & 0 deletions qdlt/qdltfilterlist.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,11 @@ class QDLT_EXPORT QDltFilterList
*/
bool applyRegExString(QString &text);

//! Apply RegEx Replace to the argumnets of a message, if any active in the filters.
/*!
*/
bool applyRegExStringMsg(QDltMsg &msg);

protected:
private:

Expand Down

0 comments on commit c63c391

Please sign in to comment.