yhkylin-backup-tools/backup-daemon/parsebackuplist.h

86 lines
2.1 KiB
C
Raw Normal View History

2021-08-17 10:07:35 +08:00
#ifndef PARSEBACKUPLIST_H
#define PARSEBACKUPLIST_H
#include <QString>
#include <QDomDocument>
#include <QDomElement>
#include "../common/mydefine.h"
class ParseBackupList {
public:
enum ParseResult {
// xml解析错误
XML_PARSE_ERR,
// 失败
FAIL,
// 成功
SUCCESS,
};
struct BackupPoint {
// 备份或还原指定的UUID
QString m_uuid;
// 备份名称用来替换m_comment
QString m_backupName;
// 备份时间
QString m_time;
// 本地备份还是U盘备份: 0-本地备份1-移动设备备份
int m_iPosition = -1;
// 操作类型,如:系统备份, 系统还原
int m_type = -1;
// 备份大小
QString m_size;
// 备份状态,如是否完成
QString m_state;
bool isNull() { return m_uuid.isEmpty(); }
};
ParseBackupList(const QString& xmlPath);
/**
* @brief backuplist.xml
* @param factoryBackupUuiduuid
* @return ParseResult枚举类型
* @author zhaominyong
* @since 2021/06/27
*/
ParseResult updateForFactoryRestore(const QString &factoryBackupUuid);
/**
* @brief comment查找uuid
* @param comment
* @return uuid
*/
QString findUuidByComment(const QString& comment);
/**
* @brief Uuid查找备份点信息
* @param Uuid
* @return
*/
BackupPoint findBackupPointByUuid(const QString& Uuid);
/**
* @brief
* @return
*/
BackupPoint getLastSysBackupPoint();
inline QString getXmlPath() { return m_xmlPath; }
private:
bool InitXml();
bool isXmlCorrect();
bool Doc_setContent(QDomDocument& doc);
void elementNodeToBackupPoint(const QDomElement& eleNode, BackupPoint& backupPoint);
void backupPointToElementNode(const BackupPoint& backupPoint, QDomElement& eleNode);
QDomElement createTextElement(const QString& tagName, const QString& text);
private:
QString m_xmlPath;
};
#endif // PARSEBACKUPLIST_H