Reinserts original comments
This commit is contained in:
112 files changed
+7113
-5131
No files matched your search
@@ -1,21 +1,21 @@
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// **************************************************************************
|
||||
//
|
||||
// (C) Copyright 2009 Swiss SIMTEC AG
|
||||
//
|
||||
// **************************************************************************
|
||||
//
|
||||
// $HeadURL$
|
||||
// $LastChangedBy$
|
||||
// $LastChangedDate$
|
||||
// $LastChangedRevision$
|
||||
//
|
||||
// **************************************************************************
|
||||
|
||||
|
||||
// manual class headers
|
||||
#include "LogViewXdrParser.hpp"
|
||||
#include <utility>
|
||||
|
||||
|
||||
// from cpp_includes
|
||||
#include "LogViewXdrElement.hpp"
|
||||
#include <QtWidgets/QMessageBox>
|
||||
#include "LogViewXdrStruct.hpp"
|
||||
@@ -46,7 +46,7 @@ LogViewXdrParser::~LogViewXdrParser()
|
||||
delete elem.second;
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
void LogViewXdrParser::addStandardType(const QString& a_name, const uint16_t a_dataSize, const uint16_t a_realSize, const LogViewXdrStandardType::E_ValueKind a_kind, const LogViewXdrStandardType::E_DynArraySizeMethod a_dynArraySizeMethod, const LogViewXdrStandardType::E_ByteOrder a_byteOrder)
|
||||
{
|
||||
QString name = a_name.trimmed();
|
||||
@@ -59,7 +59,7 @@ void LogViewXdrParser::addStandardType(const QString& a_name, const uint16_t a_d
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
void LogViewXdrParser::parseX_File(const QString& a_fileName)
|
||||
{
|
||||
for (const auto &elem : m_ElementMap)
|
||||
@@ -73,7 +73,7 @@ void LogViewXdrParser::parseX_File(const QString& a_fileName)
|
||||
m_ActElement = nullptr;
|
||||
m_State = e_ParseMain;
|
||||
|
||||
|
||||
// define some (XDR-)standard-types
|
||||
addStandardType(QLatin1String("unsigned short"), 4, 2, LogViewXdrStandardType::e_Unsigned);
|
||||
addStandardType(QLatin1String("unsigned int"), 4, 4, LogViewXdrStandardType::e_Unsigned);
|
||||
addStandardType(QLatin1String("short"), 4, 2, LogViewXdrStandardType::e_Signed);
|
||||
@@ -89,7 +89,7 @@ void LogViewXdrParser::parseX_File(const QString& a_fileName)
|
||||
addStandardType(QLatin1String("opaque"), 1, 1, LogViewXdrStandardType::e_Data);
|
||||
addStandardType(QLatin1String("string"), 1, 1, LogViewXdrStandardType::e_Character);
|
||||
|
||||
|
||||
// for tetra-telegrams
|
||||
addStandardType(QLatin1String("alpha"), 1, 1, LogViewXdrStandardType::e_Character);
|
||||
addStandardType(QLatin1String("UInt8"), 1, 1, LogViewXdrStandardType::e_Unsigned);
|
||||
addStandardType(QLatin1String("UInt16"), 2, 2, LogViewXdrStandardType::e_Unsigned);
|
||||
@@ -97,20 +97,20 @@ void LogViewXdrParser::parseX_File(const QString& a_fileName)
|
||||
addStandardType(QLatin1String("SInt8"), 1, 1, LogViewXdrStandardType::e_Signed);
|
||||
addStandardType(QLatin1String("SInt16"), 2, 2, LogViewXdrStandardType::e_Signed);
|
||||
addStandardType(QLatin1String("SInt24"), 3, 3, LogViewXdrStandardType::e_Signed);
|
||||
|
||||
// little-endian values (for TETRA-header)
|
||||
addStandardType(QLatin1String("UInt16LE"), 2, 2, LogViewXdrStandardType::e_Unsigned, LogViewXdrStandardType::e_DynArrayMsgLength, LogViewXdrStandardType::e_ByteOrderLittleEndian);
|
||||
addStandardType(QLatin1String("UInt32LE"), 4, 4, LogViewXdrStandardType::e_Unsigned, LogViewXdrStandardType::e_DynArrayMsgLength, LogViewXdrStandardType::e_ByteOrderLittleEndian);
|
||||
|
||||
// index for next dyn. array (only for TETRA)
|
||||
addStandardType(QLatin1String("UInt8Idx"), 1, 1, LogViewXdrStandardType::e_Unsigned, LogViewXdrStandardType::e_DynArrayIndex);
|
||||
addStandardType(QLatin1String("UInt16Idx"), 2, 2, LogViewXdrStandardType::e_Unsigned, LogViewXdrStandardType::e_DynArrayIndex);
|
||||
addStandardType(QLatin1String("UInt16LEIdx"), 2, 2, LogViewXdrStandardType::e_Unsigned, LogViewXdrStandardType::e_DynArrayIndex, LogViewXdrStandardType::e_ByteOrderLittleEndian);
|
||||
|
||||
// index (div 8) for next dyn. array (only for TETRA)
|
||||
addStandardType(QLatin1String("UInt8IdxDiv8"), 1, 1, LogViewXdrStandardType::e_Unsigned, LogViewXdrStandardType::e_DynArrayIndexDiv8);
|
||||
addStandardType(QLatin1String("UInt16IdxDiv8"), 2, 2, LogViewXdrStandardType::e_Unsigned, LogViewXdrStandardType::e_DynArrayIndexDiv8);
|
||||
|
||||
const auto DEFINE_NAME = QLatin1String("%#define");
|
||||
|
||||
|
||||
// parse the file
|
||||
m_Filename = a_fileName;
|
||||
m_State = e_ParseMain;
|
||||
QFile xFile(a_fileName);
|
||||
@@ -124,25 +124,25 @@ void LogViewXdrParser::parseX_File(const QString& a_fileName)
|
||||
m_Line = lastLines + QLatin1Char(' ') + in.readLine();
|
||||
m_Line = m_Line.simplified();
|
||||
m_LineNbr++;
|
||||
// INFO_LOG(m_logger) << m_LineNbr << ": " << m_Line.toStdString();
|
||||
|
||||
|
||||
|
||||
// ignore lines with %
|
||||
if (m_Line.startsWith(QLatin1Char('%')) && !m_Line.startsWith(DEFINE_NAME))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
// remove comments (sourounded with /* */)
|
||||
const QString cleanLine = removeComments(m_Line).simplified();
|
||||
|
||||
|
||||
// ignore empty lines
|
||||
if (cleanLine.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// INFO_LOG(m_logger) << "w/o comment: \'" << cleanLine.toStdString() << "\'";
|
||||
// read in whole construct
|
||||
if (m_DoReadUntilSemicolon && !cleanLine.endsWith(QLatin1Char(';')))
|
||||
{
|
||||
lastLines = cleanLine;
|
||||
@@ -153,7 +153,7 @@ void LogViewXdrParser::parseX_File(const QString& a_fileName)
|
||||
|
||||
lastLines.clear();
|
||||
|
||||
|
||||
// check whether it is the begin of a construct
|
||||
if (e_ParseMain == m_State)
|
||||
{
|
||||
if (cleanLine.startsWith(QLatin1String("union ")))
|
||||
@@ -166,7 +166,7 @@ void LogViewXdrParser::parseX_File(const QString& a_fileName)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// parse the line when we are within
|
||||
switch (m_State)
|
||||
{
|
||||
case e_ParseUnion:
|
||||
@@ -208,7 +208,7 @@ void LogViewXdrParser::parseX_File(const QString& a_fileName)
|
||||
}
|
||||
}
|
||||
xFile.close();
|
||||
|
||||
// erase all parsing-values (otherwise errormessages will have wrong informations)
|
||||
m_LineNbr = 0;
|
||||
m_Line.clear();
|
||||
}
|
||||
@@ -219,12 +219,12 @@ void LogViewXdrParser::parseX_File(const QString& a_fileName)
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
QString LogViewXdrParser::removeComments(const QString& a_line)
|
||||
{
|
||||
static const QChar slash(QLatin1Char('/'));
|
||||
static const QChar asterik(QLatin1Char('*'));
|
||||
|
||||
// remove comments (sourounded with /* */)
|
||||
QString cleanLine; cleanLine.reserve(a_line.size());
|
||||
QString::const_iterator iter = a_line.begin();
|
||||
QString::const_iterator end = a_line.end();
|
||||
@@ -232,38 +232,38 @@ QString LogViewXdrParser::removeComments(const QString& a_line)
|
||||
{
|
||||
if (!m_WithinComment)
|
||||
{
|
||||
|
||||
// does comment begin?
|
||||
if (slash == *iter)
|
||||
{
|
||||
if (++iter != end)
|
||||
{
|
||||
if (asterik == *iter)
|
||||
{
|
||||
|
||||
// yes, comment begins
|
||||
m_WithinComment = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// no comment begin
|
||||
cleanLine.append(slash);
|
||||
cleanLine.append(*iter);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// end of line
|
||||
cleanLine.append(slash);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// no
|
||||
cleanLine.append(*iter);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// does comment end?
|
||||
if (asterik == *iter)
|
||||
{
|
||||
if (++iter != end)
|
||||
@@ -282,26 +282,26 @@ QString LogViewXdrParser::removeComments(const QString& a_line)
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
void LogViewXdrParser::parseTypedef(const QString &a_line)
|
||||
{
|
||||
fillWordList(a_line);
|
||||
|
||||
|
||||
|
||||
|
||||
// typedef: "typedef telegramm_id_int_et telegramm_id_et;"
|
||||
// -------
|
||||
// keyword 'typedef'
|
||||
if (isNextWord("typedef"))
|
||||
{
|
||||
|
||||
// get type
|
||||
bool ok;
|
||||
QString type = getNextType(ok);
|
||||
|
||||
getElement(type);
|
||||
|
||||
// fixme: make boolean for structure wrong and gray out telegrams with wrong struct
|
||||
getElement(type); // do not abort when type does not exist, otherwise we will never get an error, when we try to show a telegram with a wrong structure
|
||||
// get name
|
||||
QString name = getNextWord("Name");
|
||||
if (name.isEmpty()) return;
|
||||
if (!isNextWord(";")) return;
|
||||
|
||||
// all ok
|
||||
uint16_t dynArrayOffset;
|
||||
uint16_t arraySize = parseArray(name, dynArrayOffset);
|
||||
LogViewXdrType* typedefElement = new LogViewXdrType(name, type, arraySize, dynArrayOffset, LogViewXdrElement::e_KindTypedef);
|
||||
@@ -311,7 +311,7 @@ void LogViewXdrParser::parseTypedef(const QString &a_line)
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
void LogViewXdrParser::parseDefine(const QString &a_line)
|
||||
{
|
||||
const QString line = a_line.trimmed();
|
||||
@@ -324,12 +324,12 @@ void LogViewXdrParser::parseDefine(const QString &a_line)
|
||||
if (sepPos >= 0)
|
||||
substitution = substitution.left(sepPos).trimmed();
|
||||
|
||||
|
||||
// convert to number
|
||||
bool ok = false;
|
||||
const int64_t value = calcValue(substitution.toString(), ok);
|
||||
if (ok)
|
||||
{
|
||||
|
||||
//INFO_LOG(m_logger) << "Define: name=" << name.toStdString() << " subst=" << substitution.toStdString() << " value=" << value;
|
||||
m_DefinesMap.insert(std::make_pair(name, LogViewXdrValue(name, value, LogViewXdrElement::e_KindDefine)));
|
||||
}
|
||||
}
|
||||
@@ -340,7 +340,7 @@ void LogViewXdrParser::parseDefine(const QString &a_line)
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
void LogViewXdrParser::parseEnum(const QString &a_line, const uint16_t a_enumSize)
|
||||
{
|
||||
if (QLatin1String("};") != a_line)
|
||||
@@ -348,8 +348,8 @@ void LogViewXdrParser::parseEnum(const QString &a_line, const uint16_t a_enumSiz
|
||||
switch(m_State)
|
||||
{
|
||||
default:
|
||||
|
||||
|
||||
// first line of enum containing the name
|
||||
// i.e.: "enum telegramm_id_int_et {"
|
||||
if (a_line.endsWith(QLatin1String(" {")))
|
||||
{
|
||||
m_State = e_ParseEnum;
|
||||
@@ -370,20 +370,20 @@ void LogViewXdrParser::parseEnum(const QString &a_line, const uint16_t a_enumSiz
|
||||
|
||||
case e_ParseEnum:
|
||||
{
|
||||
|
||||
|
||||
// middle lines of struct containing the elements
|
||||
// i.e.: "MANIPULATIONSMELDUNG = 2,"
|
||||
QString name;
|
||||
QString valueText;
|
||||
if (parseEnumLine(a_line, name, valueText))
|
||||
{
|
||||
|
||||
// is the valueText a previous enum-element?
|
||||
bool error = true;
|
||||
uint32_t enumValue = m_ActElement->getChildValue(valueText, &error);
|
||||
if (!error)
|
||||
{
|
||||
valueText = QString::number(enumValue);
|
||||
}
|
||||
|
||||
// calculate
|
||||
bool ok;
|
||||
int64_t value = calcValue(valueText, ok);
|
||||
if (ok)
|
||||
@@ -397,30 +397,30 @@ void LogViewXdrParser::parseEnum(const QString &a_line, const uint16_t a_enumSiz
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// end of struct
|
||||
m_State = e_ParseMain;
|
||||
|
||||
|
||||
//INFO_LOG(m_logger) << "CheckEnum " << m_ActElement->getName().toStdString();
|
||||
// check(*m_ActElement);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
void LogViewXdrParser::parseStruct(const QString &a_line)
|
||||
{
|
||||
fillWordList(a_line);
|
||||
if (!m_DoReadUntilSemicolon)
|
||||
{
|
||||
|
||||
|
||||
|
||||
// first line of struct: "struct gef_wirkfeld_flaechendeckendes_feuer_meldung_rt {"
|
||||
// --------------------
|
||||
// keyword 'union'
|
||||
if (isNextWord("struct"))
|
||||
{
|
||||
|
||||
// union name
|
||||
QString structName = getNextWord("Struktur-Name");
|
||||
if (structName.isEmpty()) return;
|
||||
if (!isNextWord("{")) return;
|
||||
|
||||
// all ok => proceed parsing union
|
||||
m_ActElement = new LogViewXdrStruct(structName, LogViewXdrElement::e_KindStruct);
|
||||
if (!addToElementMap(structName, m_ActElement))
|
||||
{
|
||||
@@ -436,15 +436,15 @@ void LogViewXdrParser::parseStruct(const QString &a_line)
|
||||
{
|
||||
if (!isNextWord("}", false))
|
||||
{
|
||||
|
||||
|
||||
|
||||
// next lines of struct: "gef_header_rt:3..6 header;"
|
||||
// --------------------
|
||||
// get type
|
||||
bool ok;
|
||||
QString type = getNextType(ok);
|
||||
if (!ok) return;
|
||||
|
||||
if (m_UnionType != type) getElement(type);
|
||||
|
||||
// fixme: make boolean for structure wrong and gray out telegrams with wrong struct
|
||||
if (m_UnionType != type) getElement(type); // do not abort when type does not exist, otherwise we will never get an error, when we try to show a telegram with a wrong structure
|
||||
// get bitfield (if any) ":2..5"
|
||||
int16_t firstBit = -1;
|
||||
int16_t lastBit = -1;
|
||||
bool isLast = true;
|
||||
@@ -454,11 +454,11 @@ void LogViewXdrParser::parseStruct(const QString &a_line)
|
||||
QString bitfield = getNextWord("Bitfield");
|
||||
isLast = parseBitfield(bitfield, firstBit, lastBit);
|
||||
}
|
||||
|
||||
// get name
|
||||
QString name = getNextWord("Name");
|
||||
if (name.isEmpty()) return;
|
||||
if (!isNextWord(";")) return;
|
||||
|
||||
// all ok
|
||||
uint16_t dynArrayOffset;
|
||||
uint16_t arraySize = parseArray(name, dynArrayOffset);
|
||||
if(firstBit >= 0)
|
||||
@@ -471,51 +471,51 @@ void LogViewXdrParser::parseStruct(const QString &a_line)
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// end of struct "};"
|
||||
if (!isNextWord("}")) return;
|
||||
if (!isNextWord(";")) return;
|
||||
m_State = e_ParseMain;
|
||||
m_DoReadUntilSemicolon = false;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// INFO_LOG(m_logger) << "CheckStruct \'" << m_ActElement->getName().toStdString() << "\'";
|
||||
// if (m_ActElement->getName() != "intern_tele") // fixme: remove this structure from element-map
|
||||
// {
|
||||
// check(*m_ActElement);
|
||||
// }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
void LogViewXdrParser::parseUnion(const QString& a_line)
|
||||
{
|
||||
|
||||
|
||||
// we can not really parse the union, we expect that only 1 union exists, and this
|
||||
// union holds all the telegrams, which we insert into a telegram-list
|
||||
static const LogViewXdrStruct* telegramIdType = nullptr;
|
||||
|
||||
fillWordList(a_line);
|
||||
if (!m_DoReadUntilSemicolon)
|
||||
{
|
||||
|
||||
|
||||
|
||||
// first line of union "union gef_tg_nd_ switch (gef_telegramm_id_et telegramm_id) {"
|
||||
// -------------------
|
||||
// keyword 'union'
|
||||
if (isNextWord("union"))
|
||||
{
|
||||
|
||||
// union name
|
||||
m_UnionType = getNextWord("Union-Typ");
|
||||
if (m_UnionType.isEmpty()) return;
|
||||
|
||||
// keyword 'switch'
|
||||
if (!isNextWord("switch")) return;
|
||||
if (!isNextWord("(")) return;
|
||||
|
||||
// telegram-id-type
|
||||
getNextEnum(telegramIdType);
|
||||
if (telegramIdType == nullptr) return;
|
||||
|
||||
// telegram-id-name
|
||||
QString name = getNextWord("Parameter-Name");
|
||||
if (name.isEmpty()) return;
|
||||
if (!isNextWord(")")) return;
|
||||
if (!isNextWord("{")) return;
|
||||
|
||||
// all ok => proceed parsing union
|
||||
m_State = e_ParseUnion;
|
||||
m_DoReadUntilSemicolon = true;
|
||||
}
|
||||
@@ -527,29 +527,29 @@ void LogViewXdrParser::parseUnion(const QString& a_line)
|
||||
QString keyword = getNextWord();
|
||||
if (keyword == QLatin1String("case"))
|
||||
{
|
||||
|
||||
|
||||
// next lines of union "case GEF_INIT: gef_init_meldung_rt init_meldung;"
|
||||
// -------------------
|
||||
QStringList constExprList;
|
||||
QString type;
|
||||
do
|
||||
{
|
||||
|
||||
// get constant-expression
|
||||
QString constExpression = getNextWord("Konstanten-Ausdruck");
|
||||
if (constExpression.isEmpty()) return;
|
||||
constExprList << constExpression;
|
||||
|
||||
// check double-point
|
||||
if (!isNextWord(":")) return;
|
||||
|
||||
// get type or another case
|
||||
type = getNextWord("Typ");
|
||||
if (type.isEmpty()) return;
|
||||
}
|
||||
while (type == QLatin1String("case"));
|
||||
|
||||
getElement(type);
|
||||
|
||||
// fixme: make boolean for structure wrong and gray out telegrams with wrong struct
|
||||
getElement(type); // do not abort when type does not exist, otherwise we will never get an error, when we try to show a telegram with a wrong structure
|
||||
// get name
|
||||
QString name = getNextWord("Name");
|
||||
if (name.isEmpty()) return;
|
||||
|
||||
// check semicolon
|
||||
if (!isNextWord(";")) return;
|
||||
|
||||
for (const QString &constExpr : std::as_const(constExprList))
|
||||
@@ -558,7 +558,7 @@ void LogViewXdrParser::parseUnion(const QString& a_line)
|
||||
int32_t telegramId = static_cast<int>(telegramIdType->getChildValue(constExpr, &error));
|
||||
if (!error)
|
||||
{
|
||||
m_TelegramMap.insert(std::make_pair(telegramId, LogViewXdrType(constExpr, type, 1, 0, LogViewXdrElement::e_KindEnumElement)));
|
||||
m_TelegramMap.insert(std::make_pair(telegramId, LogViewXdrType(constExpr, type, 1, 0, LogViewXdrElement::e_KindEnumElement))); // fixme: e_KindCaseElement und 1 entfernen
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -568,14 +568,14 @@ void LogViewXdrParser::parseUnion(const QString& a_line)
|
||||
}
|
||||
else if (keyword == QLatin1String("default"))
|
||||
{
|
||||
|
||||
// check double-point
|
||||
if (isNextWord(":"))
|
||||
{
|
||||
QString defaultDefinition = getNextWord();
|
||||
if (defaultDefinition == QLatin1String("void"))
|
||||
{
|
||||
isNextWord(";");
|
||||
|
||||
// all ok
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -590,18 +590,18 @@ void LogViewXdrParser::parseUnion(const QString& a_line)
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// end of union "};"
|
||||
if (!isNextWord("}")) return;
|
||||
if (!isNextWord(";")) return;
|
||||
m_State = e_ParseMain;
|
||||
m_DoReadUntilSemicolon = false;
|
||||
|
||||
//check(*m_ActElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
bool LogViewXdrParser::parseEnumLine(const QString& a_line, QString& a_name, QString& a_value) const
|
||||
{
|
||||
QString line;
|
||||
@@ -626,14 +626,14 @@ bool LogViewXdrParser::parseEnumLine(const QString& a_line, QString& a_name, QSt
|
||||
{
|
||||
showErrorMessage(QObject::tr("konnte Trennzeichen <b>\'=\'</b> zwischen Name und Wert nicht finden!"));
|
||||
}
|
||||
return false;
|
||||
return false; // failure happenend
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// Shows an error-message containing the line-nbr, the line
|
||||
// itself and an additional error-text
|
||||
// ---------------------------------------------------------------
|
||||
void LogViewXdrParser::showErrorMessage(const QString& a_errorText) const
|
||||
{
|
||||
const auto tlws = QApplication::topLevelWidgets();
|
||||
@@ -643,10 +643,10 @@ void LogViewXdrParser::showErrorMessage(const QString& a_errorText) const
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
int64_t LogViewXdrParser::calcValue(const QString& a_calcText, bool& a_isOk)
|
||||
{
|
||||
|
||||
// ignore strings
|
||||
a_isOk = false;
|
||||
int64_t value = 0;
|
||||
if (!a_calcText.startsWith(QLatin1Char('\"')))
|
||||
@@ -655,7 +655,7 @@ int64_t LogViewXdrParser::calcValue(const QString& a_calcText, bool& a_isOk)
|
||||
std::string errorText;
|
||||
value = calc(a_calcText.toStdString(), error, &errorText);
|
||||
|
||||
|
||||
// show error if one happend
|
||||
if (error != N_SST::IntegerCalculator::e_Ok)
|
||||
{
|
||||
switch (error)
|
||||
@@ -695,21 +695,21 @@ int64_t LogViewXdrParser::calcValue(const QString& a_calcText, bool& a_isOk)
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
bool LogViewXdrParser::getVariableValue(const std::string& a_variableName, int64_t& a_value) const
|
||||
{
|
||||
return getDefine(QString::fromStdString(a_variableName), a_value);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// This function delivers the name of the telegram and the
|
||||
// name of its structure. The telegram will be defined with
|
||||
// a_telegramId.
|
||||
// The name will be delivered as return-parameter; the
|
||||
// structure-name as out parameter a_structName.
|
||||
// If the telegram was not found, error-texts instead names
|
||||
// will be returned.
|
||||
// ---------------------------------------------------------------
|
||||
QString LogViewXdrParser::getTelegramName(int a_telegramId) const
|
||||
{
|
||||
const auto iter = m_TelegramMap.find(a_telegramId);
|
||||
@@ -719,7 +719,7 @@ QString LogViewXdrParser::getTelegramName(int a_telegramId) const
|
||||
return QObject::tr("<telegramId \'%1\' not found!>").arg(a_telegramId);
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
QString LogViewXdrParser::getStructName(int a_telegramId) const
|
||||
{
|
||||
const auto iter = m_TelegramMap.find(a_telegramId);
|
||||
@@ -729,7 +729,7 @@ QString LogViewXdrParser::getStructName(int a_telegramId) const
|
||||
return QObject::tr("<telegramId \'%1\' not found!>").arg(a_telegramId);
|
||||
}
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
bool LogViewXdrParser::getDefine(const QString& a_name, int64_t& a_value) const
|
||||
{
|
||||
const auto iter = m_DefinesMap.find(a_name);
|
||||
@@ -742,7 +742,7 @@ bool LogViewXdrParser::getDefine(const QString& a_name, int64_t& a_value) const
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
const LogViewXdrElement* LogViewXdrParser::getElement(const QString& a_name) const
|
||||
{
|
||||
const auto iter = m_ElementMap.find(a_name);
|
||||
@@ -754,27 +754,27 @@ const LogViewXdrElement* LogViewXdrParser::getElement(const QString& a_name) con
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
uint16_t LogViewXdrParser::parseArray(QString& a_name, uint16_t& a_dynArrayMsgOffset) const
|
||||
{
|
||||
a_dynArrayMsgOffset = 0;
|
||||
QString oldName = a_name;
|
||||
|
||||
|
||||
|
||||
// is it a static array []?
|
||||
// ------------------------
|
||||
int pos = a_name.indexOf(QLatin1Char('['));
|
||||
if (pos >= 0)
|
||||
{
|
||||
int endPos = a_name.indexOf(QLatin1Char(']'));
|
||||
if (endPos > pos)
|
||||
{
|
||||
|
||||
// get the array-size
|
||||
QString arraySizeText = a_name.mid(pos+1, endPos-pos-1);
|
||||
|
||||
// set new name
|
||||
a_name = a_name.left(pos);
|
||||
|
||||
// INFO_LOG(m_logger) << "new a_name=" << a_name.toStdString() << " arraySizeText=" << arraySizeText.toStdString();
|
||||
int64_t arraySizeValue = 1;
|
||||
|
||||
// check whether it is a define
|
||||
if (!getDefine(arraySizeText, arraySizeValue))
|
||||
{
|
||||
bool ok = false;
|
||||
@@ -784,7 +784,7 @@ uint16_t LogViewXdrParser::parseArray(QString& a_name, uint16_t& a_dynArrayMsgOf
|
||||
showErrorMessage(QObject::tr("%1: <b>[%2]</b> is not a number").arg(oldName, arraySizeText));
|
||||
}
|
||||
}
|
||||
|
||||
// INFO_LOG(m_logger) << "ArraySize=" << arraySizeValue;
|
||||
return arraySizeValue;
|
||||
}
|
||||
else
|
||||
@@ -795,22 +795,22 @@ uint16_t LogViewXdrParser::parseArray(QString& a_name, uint16_t& a_dynArrayMsgOf
|
||||
else
|
||||
{
|
||||
|
||||
|
||||
|
||||
|
||||
// is it an dynamic array <>?
|
||||
// --------------------------
|
||||
//INFO_LOG(m_logger) << "check for <";
|
||||
pos = a_name.indexOf(QLatin1Char('<'));
|
||||
if (pos >= 0)
|
||||
{
|
||||
int endPos = a_name.indexOf(QLatin1Char('>'));
|
||||
if (endPos > pos)
|
||||
{
|
||||
|
||||
// get the array-size
|
||||
QString arraySizeText = a_name.mid(pos+1, endPos-pos-1);
|
||||
|
||||
|
||||
//INFO_LOG(m_logger) << "pos=" << pos << " endPos=" << endPos << " => " << arraySizeText.toStdString();
|
||||
// set new name
|
||||
a_name = a_name.left(pos);
|
||||
|
||||
|
||||
// INFO_LOG(m_logger) << "new a_name=" << a_name.toStdString() << " arraySizeText=" << arraySizeText.toStdString();
|
||||
// check whether it is a define
|
||||
int64_t arraySizeValue = 1;
|
||||
if (!getDefine(arraySizeText, arraySizeValue))
|
||||
{
|
||||
@@ -822,11 +822,11 @@ uint16_t LogViewXdrParser::parseArray(QString& a_name, uint16_t& a_dynArrayMsgOf
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
// INFO_LOG(m_logger) << "a_name=" << a_name.toStdString() << " a_dynArrayMsgOffset=" << a_dynArrayMsgOffset;
|
||||
}
|
||||
}
|
||||
a_dynArrayMsgOffset = arraySizeValue;
|
||||
|
||||
// INFO_LOG(m_logger) << a_name.toStdString() << " is a dynamic array with size=" << arraySizeValue;
|
||||
return 0;
|
||||
}
|
||||
else
|
||||
@@ -839,14 +839,14 @@ uint16_t LogViewXdrParser::parseArray(QString& a_name, uint16_t& a_dynArrayMsgOf
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
bool LogViewXdrParser::isNextWord(const char *a_word, const bool a_doIncrement)
|
||||
{
|
||||
const QString word = QString::fromUtf8(a_word);
|
||||
bool ok = (m_WordListIndex < m_WordList.size() &&
|
||||
m_WordList.at(m_WordListIndex) == word);
|
||||
|
||||
|
||||
// show error-message
|
||||
if (!ok && a_doIncrement)
|
||||
{
|
||||
if (m_WordListIndex > 0)
|
||||
@@ -861,7 +861,7 @@ bool LogViewXdrParser::isNextWord(const char *a_word, const bool a_doIncrement)
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
void LogViewXdrParser::fillWordList(const QString& a_line)
|
||||
{
|
||||
QString line = a_line;
|
||||
@@ -873,15 +873,15 @@ void LogViewXdrParser::fillWordList(const QString& a_line)
|
||||
line.replace(QLatin1Char(';'), QLatin1String(" ; "));
|
||||
m_WordList = line.split(QLatin1Char(' '), Qt::SkipEmptyParts);
|
||||
m_WordListIndex = 0;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ----------------------
|
||||
// for debugging only
|
||||
// foreach (const QString &str, qAsConst(m_WordList))
|
||||
// INFO_LOG(m_logger) << "word=" << str.toStdString();
|
||||
// ----------------------
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
QString LogViewXdrParser::getNextWord(const char *a_errorText)
|
||||
{
|
||||
QString word;
|
||||
@@ -901,7 +901,7 @@ QString LogViewXdrParser::getNextWord(const char *a_errorText)
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
QString LogViewXdrParser::getNextType(bool& a_ok)
|
||||
{
|
||||
a_ok = true;
|
||||
@@ -918,7 +918,7 @@ QString LogViewXdrParser::getNextType(bool& a_ok)
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
QString LogViewXdrParser::getNextEnum(const LogViewXdrStruct*& a_enumStruct)
|
||||
{
|
||||
QString type;
|
||||
@@ -943,15 +943,15 @@ QString LogViewXdrParser::getNextEnum(const LogViewXdrStruct*& a_enumStruct)
|
||||
}
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
bool LogViewXdrParser::parseBitfield(const QString& a_fieldText, int16_t& a_firstBit, int16_t& a_lastBit) const
|
||||
{
|
||||
|
||||
|
||||
// INFO_LOG(m_logger) << "a_fieldText=" << a_fieldText.toStdString();
|
||||
// bitfield-definition: "0..2"
|
||||
a_firstBit = -1;
|
||||
a_lastBit = -1;
|
||||
bool isLast = true;
|
||||
|
||||
// first bit
|
||||
int doublePointPos = a_fieldText.indexOf(QLatin1String(".."));
|
||||
if (doublePointPos != -1)
|
||||
{
|
||||
@@ -960,9 +960,9 @@ bool LogViewXdrParser::parseBitfield(const QString& a_fieldText, int16_t& a_firs
|
||||
a_firstBit = bitText.toInt(&ok);
|
||||
if (ok)
|
||||
{
|
||||
|
||||
// last bit
|
||||
bitText = a_fieldText.mid(doublePointPos+2);
|
||||
|
||||
// is it the last bitfield of this data-value (indicated by !)
|
||||
if (bitText.endsWith(QLatin1Char('!')))
|
||||
{
|
||||
isLast = true;
|
||||
@@ -975,8 +975,8 @@ bool LogViewXdrParser::parseBitfield(const QString& a_fieldText, int16_t& a_firs
|
||||
a_lastBit = bitText.toInt(&ok);
|
||||
if (ok)
|
||||
{
|
||||
|
||||
|
||||
// remove bitfield-stuff
|
||||
// a_line = a_line.remove(bitfieldPos, endPos-bitfieldPos);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -996,12 +996,12 @@ bool LogViewXdrParser::parseBitfield(const QString& a_fieldText, int16_t& a_firs
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
// ---------------------------------------------------------------
|
||||
// adds an element to the element-map if it does not already
|
||||
// exist within this map.
|
||||
// If it exists, an error-message will be raised instead and
|
||||
// false will be returned.
|
||||
// ---------------------------------------------------------------
|
||||
bool LogViewXdrParser::addToElementMap(const QString& a_name, LogViewXdrElement* a_element)
|
||||
{
|
||||
if (m_ElementMap.find(a_name) == m_ElementMap.end())
|
||||
@@ -1013,5 +1013,5 @@ bool LogViewXdrParser::addToElementMap(const QString& a_name, LogViewXdrElement*
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace N_LogView
|
||||
|
||||
Reference in new issue
Block a user