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/iXmlUtilBase.h

58 lines
2.5 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 <QStringList>
#include <QtXml/QDomDocument>
#include "iXmlBase_global.h"
// xml文件解析基类
class I_XML_BASE_EXPORT iXmlUtilBase
{
public:
/// @brief 解密并解析xml文件
/// @param (out) doc 明文xml载体
/// @param (in) sFile文件路径
/// @param (in) bAdvanceMode,高级模式 自动进行加密解密处理如果为false则直接xml文件
/// @note 关于sFile路径说明
/// 格式可以是xml也可以是dat格式当 bAutoEncMode = true 时,
/// 后台会自动换为dat格式逻辑如下
/// 路径为 $/Bin/Config/WTAI/BtnCmds.xml
/// 如果不存在,则从$/Bin/Config/Common中查找BtnCmds.dat
/// 即:模块本身如果配置,则走模块本身,否则走通用
static bool openAndLoadXml(QDomDocument& doc, \
QString& sFile, \
bool bAdvanceMode = true);
/// @brief 把Xml按照规范的属性顺序进行重新组织该函数只在属性提取时调用其它暂无调用
/// @param (in) sFileSrc,源xml文件
/// @param (in) sFileDest,目标xml文件
/// @param (in) listOrderedAttributes,按照哪些属性进行排序
/// @param (in) backUpMode,是否备份原先
/// @note Qt Xml写起来方便而且可以灵活遍历但不支持属性顺序
/// QtXmlWriter支持顺序但写的时候只能流模式
/// 故采用本函数进行一次转换
static bool reOrderXml(QString sFileSrc, QString sFileDest, \
QStringList listOrderedAttributes, \
bool backUpMode = true);
protected:
/// @note 关于sDat路径说明后台会自动换为dat格式
/// 路径为 $/Bin/Config/WTAI/BtnCmds.dat
/// 如果不存在,则从$/Bin/Config/Common中查找BtnCmds.dat
/// 即:模块本身如果配置,则走模块本身,否则走通用
static bool verifyDatFilePath(QString& sDat);
private:
// 内部排序转换函数reOrderXml中进行调用
static void orderXmlNode(const QDomNode* pNode, \
QXmlStreamWriter& writer, \
QStringList& listOrderedAttributes);
static void orderXmlAttribute(const QDomElement* pNode, \
QXmlStreamWriter& writer, \
QStringList& listOrderedAttributes);
};