You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
AppFlow/FITK_Component/FITKOFDictWriter/FITKDictValue.h

220 lines
6.2 KiB
C

/**
* @file FITKDictValue.h
* @brief
* @author liuzhonghua (liuzhonghuaszch@163.com)
* @date 2024-07-15
*/
#ifndef _FITKDICTVALUE_H__
#define _FITKDICTVALUE_H__
#include "FITKOFDictWriterAPI.h"
#include "FITKAbstractDict.h"
#include <QStringList>
namespace DICT
{
class FITKDictArray;
class FITKDictGroup;
class FITKDictVector;
class FITKDictObject;
/**
* @brief
* @author liuzhonghua (liuzhonghuaszch@163.com)
* @date 2024-07-15
*/
class FITKOFDictWriterAPI FITKDictValue
{
friend class FITKDictObject;
friend class FITKDictArray;
friend class FITKDictGroup;
friend class FITKDictVector;
public:
/**
* @brief create a new FITKDictValue
* @param type
* @author liuzhonghua (liuzhonghuaszch@163.com)
* @date 2024-07-16
*/
FITKDictValue(FITKAbstractDict::DictType type);
FITKDictValue(bool b);
FITKDictValue(double n);
FITKDictValue(int n);
FITKDictValue(const QString &s);
FITKDictValue(const char *s);
FITKDictValue(const QStringList &s);
FITKDictValue(FITKAbstractDict* s);
/**
* @brief delete a FITKDictValue
* @author liuzhonghua (liuzhonghuaszch@163.com)
* @date 2024-07-25
*/
~FITKDictValue();
/**
* @brief
* @param other
* @author liuzhonghua (liuzhonghuaszch@163.com)
* @date 2024-07-16
*/
FITKDictValue(const FITKDictValue &other);
FITKDictValue &operator=(const FITKDictValue &other);
/**
* @brief
* @return
* @author liuzhonghua (liuzhonghuaszch@163.com)
* @date 2024-07-16
*/
FITKAbstractDict::DictType getDictType();
/**
* @brief key
* @param[i] key
* @author liuzhonghua (liuzhonghuaszch@163.com)
* @date 2024-07-16
*/
void setKey(const QString key);
/**
* @brief key
* @return
* @author liuzhonghua (liuzhonghuaszch@163.com)
* @date 2024-07-16
*/
QString getKey() const;
/**
* @brief bool
* @param[o] ok
* @return bool
* @author liuzhonghua (liuzhonghuaszch@163.com)
* @date 2024-07-16
*/
bool toBool(bool& ok) const;
/**
* @brief double
* @param[o] ok
* @return double
* @author liuzhonghua (liuzhonghuaszch@163.com)
* @date 2024-07-16
*/
double toDouble(bool& ok) const;
/**
* @brief int
* @param[i] ok
* @return int
* @author liuzhonghua (liuzhonghuaszch@163.com)
* @date 2024-07-16
*/
int toInt(bool& ok) const;
/**
* @brief QString
* @param[i] ok
* @return QString
* @author liuzhonghua (liuzhonghuaszch@163.com)
* @date 2024-07-16
*/
QString toString(bool& ok) const;
/**
* @brief QStringList
* @param[i] ok
* @return QStringList
* @author liuzhonghua (liuzhonghuaszch@163.com)
* @date 2024-07-25
*/
QStringList tiStringList(bool& ok) const;
/**
* @brief FITKDictArray*
* @param[i] ok
* @return FITKDictArray*
* @author liuzhonghua (liuzhonghuaszch@163.com)
* @date 2024-07-16
*/
FITKDictArray* toArray(bool& ok) const;
/**
* @brief FITKDictModule*
* @param[i] ok
* @return FITKDictModule*
* @author liuzhonghua (liuzhonghuaszch@163.com)
* @date 2024-07-16
*/
FITKDictGroup* toGroup(bool& ok) const;
/**
* @brief FITKDictVector*
* @param[i] ok
* @return FITKDictVector*
* @author liuzhonghua (liuzhonghuaszch@163.com)
* @date 2024-07-16
*/
FITKDictVector* toVector(bool& ok) const;
/**
* @brief
* @return
* @author liuzhonghua (liuzhonghuaszch@163.com)
* @date 2024-07-16
*/
bool isNull() const;
/**
* @brief
* @return
* @author liuzhonghua (liuzhonghuaszch@163.com)
* @date 2024-07-16
*/
bool isSimpleType() const;
/**
* @brief key
* @return QString
* @author liuzhonghua (liuzhonghuaszch@163.com)
* @date 2024-07-16
*/
QString getDataKeyEmpty();
/**
* @brief double
* @param[i] v
* @return QString
* @author liuzhonghua (liuzhonghuaszch@163.com)
* @date 2024-08-28
*/
QString doubleAdaptationTool(double v);
protected:
/**
* @brief
* @param stream
* @param lineStart
* @author liuzhonghua (liuzhonghuaszch@163.com)
* @date 2024-07-16
*/
void writeDict(QTextStream* stream, QString lineStart);
private:
/**
* @brief value
* @author liuzhonghua (liuzhonghuaszch@163.com)
* @date 2024-07-25
*/
union
{
int m_value_Int;
bool m_value_Bool;
double m_value_Double;
QString* m_value_String;
QStringList* m_value_StrList;
FITKAbstractDict* m_value_Data;
};
/**
* @brief key
* @author liuzhonghua (liuzhonghuaszch@163.com)
* @date 2024-07-25
*/
QString m_key{};
/**
* @brief
* @author liuzhonghua (liuzhonghuaszch@163.com)
* @date 2024-07-25
*/
FITKAbstractDict::DictType m_type{ FITKAbstractDict::DictType::DictNone };
};
}
#endif