DAWorkbench 0.0.1
DAWorkbench API
载入中...
搜索中...
未找到
DA::DAAbstractArchive类 参考abstract

持久化的基类 更多...

#include <DAAbstractArchive.h>

类 DA::DAAbstractArchive 继承关系图:
DA::DAZipArchive

class  PrivateData
 

Public 类型

enum  ResultCode { SaveSuccess , SaveFailed , LoadSuccess , LoadFailed }
 结果号
 

Public 槽

virtual void saveAll (const QString &filePath)=0
 
virtual void loadAll (const QString &filePath)=0
 

信号

void taskProgress (std::shared_ptr< DA::DAAbstractArchiveTask > task, int mode)
 当前进度信号 对于读取操作,这个函数会携带读取的结果
 
void taskFinished (int resultCode)
 任务完成
 

Public 成员函数

 DAAbstractArchive (QObject *par=nullptr)
 
virtual bool setBaseFilePath (const QString &path)
 设置基础路径
 
QString getBaseFilePath () const
 
virtual bool write (const QString &relatePath, const QByteArray &byte)=0
 写数据
 
virtual QByteArray read (const QString &relatePath)=0
 读取数据
 
virtual bool remove (const QString &relatePath)=0
 删除文件
 
void appendTask (const std::shared_ptr< DAAbstractArchiveTask > &task)
 
int getTaskCount () const
 
bool isTaskQueueEmpty () const
 

静态 Public 成员函数

static QString toTemporaryPath (const QString &path)
 转换为临时路径
 
static bool replaceFile (const QString &file, const QString &beReplaceFile)
 替换文件
 

Protected 成员函数

std::shared_ptr< DAAbstractArchiveTasktakeTask ()
 从顶部提取一个任务
 

详细描述

持久化的基类

这个类设计中包含了一个任务队列,任务队列可以实现多线程执行批量写和读

成员函数说明

◆ read()

virtual QByteArray DA::DAAbstractArchive::read ( const QString &  relatePath)
pure virtual

读取数据

参数
relatePath相对位置此位置相对BaseFilePath相对位置此位置相对BaseFilePath
返回
读取失败返回一个空QByteArray

DA::DAZipArchive 内被实现.

◆ remove()

virtual bool DA::DAAbstractArchive::remove ( const QString &  relatePath)
pure virtual

删除文件

参数
relatePath
返回

DA::DAZipArchive 内被实现.

◆ replaceFile()

bool DA::DAAbstractArchive::replaceFile ( const QString &  file,
const QString &  beReplaceFile 
)
static

替换文件

参数
file要被替换的文件路径,此函数执行完成后,这个文件将消失
beReplaceFile用于替换的文件路径,这个路径文件可以不存在
返回
成功返回 true,失败返回 false

将 beReplaceFile 重命名为 file,如果beReplaceFile已经存在,QFile::copy(file, beReplaceFile)这个函数会返回false, 因此,beReplaceFile如果存在,先要删除beReplaceFile

◆ setBaseFilePath()

bool DA::DAAbstractArchive::setBaseFilePath ( const QString &  path)
virtual

设置基础路径

对于文件来说,基础路径就是要保存的目录,所有文件的写入都基于此目录,对应zip来说,这个路径就是zip文件路径

注解
对于一些单文件类操作,例如zip文件,设置路径后需要打开文件的,应该继承此函数,把打开的操作也叫上,例如:
参数
path基础路径

DA::DAZipArchive 重载.

◆ takeTask()

std::shared_ptr< DA::DAAbstractArchiveTask > DA::DAAbstractArchive::takeTask ( )
protected

从顶部提取一个任务

返回

◆ taskProgress

void DA::DAAbstractArchive::taskProgress ( std::shared_ptr< DA::DAAbstractArchiveTask task,
int  mode 
)
signal

当前进度信号 对于读取操作,这个函数会携带读取的结果

参数
task任务
mode模式,具体为DAAbstractArchiveTask::Mode

◆ toTemporaryPath()

QString DA::DAAbstractArchive::toTemporaryPath ( const QString &  path)
static

转换为临时路径

返回

◆ write()

virtual bool DA::DAAbstractArchive::write ( const QString &  relatePath,
const QByteArray &  byte 
)
pure virtual

写数据

参数
relatePath相对位置此位置相对BaseFilePath
byte
返回

DA::DAZipArchive 内被实现.


该类的文档由以下文件生成: