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.
nmWATI/Include/iBase/iXmlBase/iXmlItemBase.h

100 lines
2.2 KiB
C++

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

#pragma once
#include <QObject>
#include "Defines.h"
#include "IxSerDes.h"
#include "iXmlBase_global.h"
class QDomNode;
class QDomElement;
class QDomDocument;
class ZxSerializer;
// 单一节点
class I_XML_BASE_EXPORT iXmlItemBase : public QObject, \
virtual public IxSerDes
{
Q_OBJECT
public:
iXmlItemBase();
~iXmlItemBase();
protected:
// 初始化Tag
virtual void initXmlTags();
public:
// 解析xml节点到List
virtual void parseInfo(const QDomElement& e);
// 把List分配到成员变量
// 输入开始的m_listValues中index并且返回下一个index
virtual int allocateInfo(int nIndex);
// 备份恢复
virtual bool saveBk();
virtual bool restoreBk();
// 序列化
virtual void onSerialize(ZxSerializer* ser);
virtual void onDeserialize(ZxSerializer* ser);
// 写入xml
virtual void writeInfo(QDomElement& e, QDomDocument &doc);
// 初始化孩子节点,对于组(父级)需要实现该函数
virtual iXmlItemBase* createChild();
// 节点层级关系
virtual void appenChild(iXmlItemBase* p);
iXmlItemBase* getChildAt(int n);
int getChildrenCount();
QStringList childrenNames();
int childIndex(QString sName);
void setParent(iXmlItemBase* p);
iXmlItemBase* getParent();
// clear
virtual void clear();
protected:
//主要检查是否数据
void checkStrToDigit(QString s, double& f);
void checkStrToDigit(QString s, int& n);
public:
QString m_sID; //ID
QString m_sName; //字段
QString m_sAlias; //别名
QString m_sTips; //说明/备注
QString m_sWhatThis;//辅助信息,可以是任意信息
protected:
// XML标签,需与成员变量严格对应
QStringList m_listTags;
// XML标签对应的数据,需与成员变量严格对应
QStringList m_listValues;
// 备份XML标签对应的数据,需与成员变量严格对应
QStringList m_listValuesBk;
// 对于父子关系的处理
QVector<iXmlItemBase*> m_vecChildren;
iXmlItemBase* m_pParent;
// 临时,固定
QString m_sChildTag; //写入XML时孩子节点标签
};
typedef QVector<iXmlItemBase*> vecXmlItemsPtr;