184 lines
3.1 KiB
C++
184 lines
3.1 KiB
C++
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
#include <QString>
|
|
#include <QStringList>
|
|
|
|
#include "IntegerCalculator.hpp"
|
|
#include "logger.h"
|
|
#include "LogViewXdrStandardType.hpp"
|
|
|
|
namespace N_LogView
|
|
{
|
|
class LogViewXdrElement;
|
|
class LogViewXdrStruct;
|
|
class LogViewField;
|
|
class LogViewXdrValue;
|
|
class LogViewXdrType;
|
|
|
|
|
|
|
|
class LogViewXdrParser : public N_SST::IntegerCalculator
|
|
{
|
|
public:
|
|
|
|
|
|
|
|
enum E_ParseState
|
|
{
|
|
e_ParseMain,
|
|
e_ParseStruct,
|
|
e_ParseEnum,
|
|
e_ParseUnion
|
|
};
|
|
|
|
|
|
LogViewXdrParser();
|
|
~LogViewXdrParser();
|
|
|
|
|
|
|
|
|
|
void parseX_File(const QString& a_fileName);
|
|
|
|
|
|
|
|
QString getTelegramName(int a_telegramId) const;
|
|
|
|
|
|
|
|
QString getStructName(int a_telegramId) const;
|
|
|
|
|
|
|
|
bool getDefine(const QString& a_name, int64_t& a_value) const;
|
|
|
|
|
|
|
|
const LogViewXdrElement* getElement(const QString& a_name) const;
|
|
|
|
protected:
|
|
|
|
QString m_MessageBoxTitle;
|
|
bool m_WithinComment;
|
|
QString m_Line;
|
|
uint32_t m_LineNbr;
|
|
QString m_Filename;
|
|
bool m_DoReadUntilSemicolon;
|
|
QStringList m_WordList;
|
|
int m_WordListIndex;
|
|
|
|
|
|
QString m_UnionType;
|
|
std::map<QString, LogViewXdrElement*> m_ElementMap;
|
|
|
|
LogViewXdrStruct *m_ActElement;
|
|
|
|
E_ParseState m_State;
|
|
|
|
std::map<QString, LogViewXdrValue> m_DefinesMap;
|
|
|
|
std::map<int, LogViewXdrType> m_TelegramMap;
|
|
|
|
|
|
|
|
void 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 = LogViewXdrStandardType::e_DynArrayMsgLength,
|
|
const LogViewXdrStandardType::E_ByteOrder a_byteOrder = LogViewXdrStandardType::e_ByteOrderBigEndian);
|
|
|
|
|
|
|
|
QString removeComments(const QString& a_line);
|
|
|
|
|
|
|
|
void parseTypedef(const QString &a_line);
|
|
|
|
|
|
|
|
void parseDefine(const QString &a_line);
|
|
|
|
|
|
|
|
void parseEnum(const QString &a_line, const uint16_t a_enumSize = 4);
|
|
|
|
|
|
|
|
void parseStruct(const QString &a_line);
|
|
|
|
|
|
|
|
void parseUnion(const QString& a_line);
|
|
|
|
|
|
|
|
bool parseEnumLine(const QString& a_line, QString& a_name, QString& a_value) const;
|
|
|
|
|
|
|
|
void showErrorMessage(const QString& a_errorText) const;
|
|
|
|
|
|
|
|
int64_t calcValue(const QString& a_calcText, bool& a_isOk);
|
|
|
|
|
|
|
|
bool getVariableValue(const std::string& a_variableName, int64_t& a_value) const override;
|
|
|
|
|
|
|
|
uint16_t parseArray(QString& a_name, uint16_t& a_dynArrayMsgOffset) const;
|
|
|
|
|
|
|
|
bool isNextWord(const char *a_word, const bool a_doIncrement = true);
|
|
|
|
|
|
|
|
void fillWordList(const QString& a_line);
|
|
|
|
|
|
|
|
QString getNextWord(const char *a_errorText = nullptr);
|
|
|
|
|
|
|
|
QString getNextType(bool& a_ok);
|
|
|
|
|
|
|
|
QString getNextEnum(const LogViewXdrStruct*& a_enumStruct);
|
|
|
|
|
|
|
|
bool parseBitfield(const QString& a_fieldText, int16_t& a_firstBit, int16_t& a_lastBit) const;
|
|
|
|
|
|
|
|
bool addToElementMap(const QString& a_name, LogViewXdrElement* a_element);
|
|
|
|
private:
|
|
|
|
|
|
NGL::INGLLogger &m_logger;
|
|
|
|
};
|
|
|
|
}
|