Initial commit
This commit is contained in:
commit
b7d90b9afe
16245 files changed
+3396666
No files matched your search
@@ -0,0 +1,274 @@
|
||||
// **************************************************************************
|
||||
//
|
||||
// (C) Copyright 2009 Swiss SIMTEC AG
|
||||
//
|
||||
// **************************************************************************
|
||||
//
|
||||
// $HeadURL$
|
||||
// $LastChangedBy$
|
||||
// $LastChangedDate$
|
||||
// $LastChangedRevision$
|
||||
//
|
||||
// **************************************************************************
|
||||
|
||||
#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;
|
||||
|
||||
/**
|
||||
* @author alois.wismer
|
||||
* @version 1.0
|
||||
* @created 05-Feb-2010 10:46:58
|
||||
*/
|
||||
class LogViewXdrParser : public N_SST::IntegerCalculator
|
||||
{
|
||||
public:
|
||||
|
||||
/**
|
||||
* Defines in which structure the parser is parsing now
|
||||
*
|
||||
* @author alois.wismer
|
||||
* @version 1.0
|
||||
* @created 08-Feb-2010 17:44:52
|
||||
*/
|
||||
enum E_ParseState
|
||||
{
|
||||
e_ParseMain,
|
||||
e_ParseStruct,
|
||||
e_ParseEnum,
|
||||
e_ParseUnion
|
||||
};
|
||||
|
||||
|
||||
LogViewXdrParser();
|
||||
~LogViewXdrParser();
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param a_fileName
|
||||
*/
|
||||
void parseX_File(const QString& a_fileName);
|
||||
|
||||
/**
|
||||
* This function delivers the name of the telegram.
|
||||
* The telegram will be defined with a_telegramId.
|
||||
* The name will be delivered as return-parameter.
|
||||
* If the telegram was not found, error-texts instead names will be returned.
|
||||
*
|
||||
* @param a_telegramId
|
||||
*/
|
||||
QString getTelegramName(int a_telegramId) const;
|
||||
|
||||
/**
|
||||
* This function delivers the structure name of the telegram.
|
||||
* The telegram will be defined with a_telegramId.
|
||||
* The structure name will be delivered as return-parameter
|
||||
* If the telegram was not found, error-texts instead names will be returned.
|
||||
*
|
||||
* @param a_telegramId
|
||||
*/
|
||||
QString getStructName(int a_telegramId) const;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param a_name
|
||||
* @param a_value
|
||||
*/
|
||||
bool getDefine(const QString& a_name, int64_t& a_value) const;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param a_name
|
||||
*/
|
||||
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;
|
||||
/**
|
||||
* This will be used to suppress an error-message when parsing the overall
|
||||
* telegram structure.
|
||||
*/
|
||||
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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param a_name
|
||||
* @param a_dataSize
|
||||
* @param a_realSize
|
||||
* @param a_kind
|
||||
* @param a_dynArraySizeMethod
|
||||
* @param a_byteOrder
|
||||
*/
|
||||
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);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param a_line
|
||||
*/
|
||||
QString removeComments(const QString& a_line);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param a_line
|
||||
*/
|
||||
void parseTypedef(const QString &a_line);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param a_line
|
||||
*/
|
||||
void parseDefine(const QString &a_line);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param a_line
|
||||
* @param a_enumSize The size in bytes of an enum-value
|
||||
*/
|
||||
void parseEnum(const QString &a_line, const uint16_t a_enumSize = 4);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param a_line
|
||||
*/
|
||||
void parseStruct(const QString &a_line);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param a_line
|
||||
*/
|
||||
void parseUnion(const QString& a_line);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param a_line
|
||||
* @param a_name
|
||||
* @param a_value
|
||||
*/
|
||||
bool parseEnumLine(const QString& a_line, QString& a_name, QString& a_value) const;
|
||||
|
||||
/**
|
||||
* Shows an error-message containing the line-nbr, the line itself and an
|
||||
* additional error-text
|
||||
*
|
||||
* @param a_errorText
|
||||
*/
|
||||
void showErrorMessage(const QString& a_errorText) const;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param a_calcText
|
||||
* @param a_isOk
|
||||
*/
|
||||
int64_t calcValue(const QString& a_calcText, bool& a_isOk);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param a_variableName
|
||||
* @param a_value
|
||||
*/
|
||||
bool getVariableValue(const std::string& a_variableName, int64_t& a_value) const override;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param a_name
|
||||
* @param a_dynArrayMsgOffset This offset will be used for the dyn-array-method
|
||||
* e_DynArrayMsgLength. Here the value in <x> will be subtracted from the message-
|
||||
* length to get the size of the dynamic array.
|
||||
*/
|
||||
uint16_t parseArray(QString& a_name, uint16_t& a_dynArrayMsgOffset) const;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param a_word
|
||||
* @param a_doIncrement
|
||||
*/
|
||||
bool isNextWord(const char *a_word, const bool a_doIncrement = true);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param a_line
|
||||
*/
|
||||
void fillWordList(const QString& a_line);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param a_errorText
|
||||
*/
|
||||
QString getNextWord(const char *a_errorText = nullptr);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param a_ok
|
||||
*/
|
||||
QString getNextType(bool& a_ok);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param a_enumStruct
|
||||
*/
|
||||
QString getNextEnum(const LogViewXdrStruct*& a_enumStruct);
|
||||
|
||||
/**
|
||||
*
|
||||
* @param a_fieldText
|
||||
* @param a_firstBit
|
||||
* @param a_lastBit
|
||||
*/
|
||||
bool parseBitfield(const QString& a_fieldText, int16_t& a_firstBit, int16_t& a_lastBit) const;
|
||||
|
||||
/**
|
||||
* 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.
|
||||
*
|
||||
* @param a_name
|
||||
* @param a_element
|
||||
*/
|
||||
bool addToElementMap(const QString& a_name, LogViewXdrElement* a_element);
|
||||
|
||||
private:
|
||||
/**
|
||||
* The logger object
|
||||
*/
|
||||
NGL::INGLLogger &m_logger;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user