├── user.cpp ├── user.h ├── main.cpp ├── widget.h ├── cglobal.cpp ├── cglobal.h ├── mainwindow.h ├── memory_monitor.h ├── data_define.cpp ├── systemwindow.ui ├── dialog_gen_data.h ├── folder_manager.h ├── memory_monitor.ui ├── disk_monitor.h ├── dialog_delete_data.h ├── gendatathread.h ├── disk_manager.h ├── window_exe_data.h ├── gendatathread.cpp ├── cereal ├── external │ ├── rapidjson │ │ ├── internal │ │ │ ├── swap.h │ │ │ ├── strfunc.h │ │ │ ├── ieee754.h │ │ │ └── pow10.h │ │ ├── cursorstreamwrapper.h │ │ ├── ostreamwrapper.h │ │ ├── memorybuffer.h │ │ ├── memorystream.h │ │ ├── filereadstream.h │ │ ├── filewritestream.h │ │ ├── error │ │ │ └── en.h │ │ ├── stringbuffer.h │ │ ├── istreamwrapper.h │ │ └── fwd.h │ ├── rapidxml │ │ ├── license.txt │ │ ├── rapidxml_utils.hpp │ │ └── rapidxml_iterators.hpp │ └── base64.hpp ├── types │ ├── map.hpp │ ├── unordered_map.hpp │ ├── functional.hpp │ ├── utility.hpp │ ├── atomic.hpp │ ├── complex.hpp │ ├── list.hpp │ ├── deque.hpp │ ├── optional.hpp │ ├── forward_list.hpp │ ├── string.hpp │ ├── chrono.hpp │ ├── stack.hpp │ ├── concepts │ │ └── pair_associative_container.hpp │ ├── array.hpp │ ├── set.hpp │ ├── unordered_set.hpp │ ├── valarray.hpp │ ├── variant.hpp │ ├── tuple.hpp │ ├── vector.hpp │ ├── queue.hpp │ └── common.hpp ├── version.hpp └── details │ ├── polymorphic_impl_fwd.hpp │ ├── util.hpp │ └── static_object.hpp ├── README.md ├── memory_manager.h ├── systemwindow.h ├── OperatingSystem.pro ├── memory_monitor.cpp ├── dialog_delete_data.cpp ├── mainwindow.cpp ├── dialog_delete_data.ui ├── dialog_gen_data.cpp ├── folder_manager.cpp ├── disk_monitor.cpp ├── mainwindow.ui ├── window_exe_data.cpp └── dialog_gen_data.ui /user.cpp: -------------------------------------------------------------------------------- 1 | #include "user.h" 2 | 3 | User::User() 4 | { 5 | 6 | } 7 | 8 | std::string User::userName = "未命名"; 9 | -------------------------------------------------------------------------------- /user.h: -------------------------------------------------------------------------------- 1 | #ifndef USER_H 2 | #define USER_H 3 | 4 | #include 5 | 6 | class User 7 | { 8 | public: 9 | User(); 10 | // 用户名 11 | static std::string userName; 12 | }; 13 | 14 | #endif // USER_H 15 | -------------------------------------------------------------------------------- /main.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | #include 3 | 4 | int main(int argc, char *argv[]) 5 | { 6 | QApplication a(argc, argv); 7 | MainWindow w; 8 | w.show(); 9 | 10 | return a.exec(); 11 | } 12 | -------------------------------------------------------------------------------- /widget.h: -------------------------------------------------------------------------------- 1 | #ifndef WIDGET_H 2 | #define WIDGET_H 3 | 4 | #include 5 | #include "main_form.h" 6 | 7 | namespace Ui{ 8 | class Widget; 9 | } 10 | 11 | class Widget : public QWidget 12 | { 13 | public: 14 | explicit Widget(QWidget * parent = nullptr); 15 | 16 | private: 17 | Ui::Widget *ui; 18 | main_form * mform; 19 | }; 20 | 21 | #endif // WIDGET_H 22 | -------------------------------------------------------------------------------- /cglobal.cpp: -------------------------------------------------------------------------------- 1 | #include "cglobal.h" 2 | 3 | 4 | CGlobal::CGlobal() 5 | { 6 | 7 | } 8 | 9 | // 初始化内存互斥信号量 10 | QSemaphore* CGlobal::mSem = new QSemaphore(1); 11 | QSemaphore* CGlobal::delThreadSem = new QSemaphore(1); 12 | QSemaphore* CGlobal::genThreadSem = new QSemaphore(1); 13 | // 初始化管理器 14 | DiskManager* CGlobal::dManager = new DiskManager(); 15 | FolderManager* CGlobal::fManager = new FolderManager(CGlobal::dManager); 16 | MemoryManager* CGlobal::mManager = new MemoryManager(CGlobal::dManager); 17 | -------------------------------------------------------------------------------- /cglobal.h: -------------------------------------------------------------------------------- 1 | #ifndef CGLOBAL_H 2 | #define CGLOBAL_H 3 | 4 | #include "disk_manager.h" 5 | #include "folder_manager.h" 6 | #include "memory_manager.h" 7 | #include 8 | #include 9 | 10 | class CGlobal 11 | { 12 | public: 13 | CGlobal(); 14 | 15 | // 磁盘管理 16 | static DiskManager* dManager; 17 | static FolderManager* fManager; 18 | 19 | static QSemaphore* mSem; 20 | // 内存管理器,其内存为互斥量 21 | static MemoryManager* mManager; 22 | 23 | // 公有变量 24 | static QSemaphore* genThreadSem; 25 | static QSemaphore* delThreadSem; 26 | 27 | 28 | }; 29 | 30 | 31 | #endif // CGLOBAL_H 32 | -------------------------------------------------------------------------------- /mainwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef MAINWINDOW_H 2 | #define MAINWINDOW_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "systemwindow.h" 9 | namespace Ui { 10 | class MainWindow; 11 | } 12 | 13 | class MainWindow : public QMainWindow 14 | { 15 | Q_OBJECT 16 | 17 | public: 18 | explicit MainWindow(QWidget *parent = nullptr); 19 | ~MainWindow(); 20 | 21 | 22 | private slots: 23 | void on_pushButton_clicked(); 24 | // 25 | void showDialog(QDialog * dialog); 26 | 27 | private: 28 | Ui::MainWindow *ui; 29 | SystemWindow sysWin; 30 | CGlobal* cglobal; 31 | 32 | //表格属性 33 | QStandardItemModel * model; 34 | 35 | }; 36 | 37 | #endif // MAINWINDOW_H 38 | -------------------------------------------------------------------------------- /memory_monitor.h: -------------------------------------------------------------------------------- 1 | #ifndef MEMORY_MONITOR_H 2 | #define MEMORY_MONITOR_H 3 | 4 | #include 5 | #include 6 | #include "cglobal.h" 7 | #include 8 | #include 9 | 10 | namespace Ui { 11 | class MemoryMonitor; 12 | } 13 | 14 | class MemoryMonitor : public QMainWindow 15 | { 16 | Q_OBJECT 17 | 18 | public: 19 | explicit MemoryMonitor(QWidget *parent = nullptr); 20 | ~MemoryMonitor(); 21 | 22 | // 表格属性 23 | QTableView *tv_memory; 24 | QStandardItemModel * model; 25 | 26 | signals: 27 | // 通知主线程更新线程 28 | void needUpdate(); 29 | 30 | public slots: 31 | // 刷新内存 32 | void updateMemoryUI(); 33 | 34 | 35 | private: 36 | Ui::MemoryMonitor *ui; 37 | }; 38 | 39 | #endif // MEMORY_MONITOR_H 40 | -------------------------------------------------------------------------------- /data_define.cpp: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Zhang Boyu on 2019/12/28. 3 | // 4 | 5 | #include "data_define.h" 6 | 7 | void outputStr(string s){ 8 | // 先用cout进行输出,后续使用QString进行输出 9 | std::cout< 2 | 3 | SystemWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 640 10 | 240 11 | 12 | 13 | 14 | MainWindow 15 | 16 | 17 | 18 | 19 | 20 | 0 21 | 0 22 | 640 23 | 22 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 32 | -------------------------------------------------------------------------------- /dialog_gen_data.h: -------------------------------------------------------------------------------- 1 | #ifndef DIALOG_GEN_DATA_H 2 | #define DIALOG_GEN_DATA_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "cglobal.h" 9 | 10 | namespace Ui { 11 | class dialog_gen_data; 12 | } 13 | 14 | class dialog_gen_data : public QDialog 15 | { 16 | Q_OBJECT 17 | 18 | public: 19 | explicit dialog_gen_data(QWidget *parent = nullptr); 20 | ~dialog_gen_data(); 21 | 22 | signals: 23 | // 数据更新了 24 | void dataUpdated(); 25 | 26 | private: 27 | Ui::dialog_gen_data *ui; 28 | // 编辑框 29 | QLineEdit* edit_fileName; 30 | QLineEdit* edit_fileContent; 31 | 32 | // QWidget interface 33 | protected: 34 | void closeEvent(QCloseEvent *event); 35 | private slots: 36 | void on_btn_submit_clicked(); 37 | void on_message_btn_ok(); 38 | void changeInputCount(const QString &text); 39 | }; 40 | 41 | #endif // DIALOG_GEN_DATA_H 42 | -------------------------------------------------------------------------------- /folder_manager.h: -------------------------------------------------------------------------------- 1 | #ifndef FOLDERMANAGER_H 2 | #define FOLDERMANAGER_H 3 | #include "disk_manager.h" 4 | #include "data_define.h" 5 | #include 6 | #include "user.h" 7 | 8 | class FolderManager 9 | { 10 | public: 11 | // 暂存磁盘管理的指针变量 12 | DiskManager * dManager; 13 | //FCN保存的 14 | FCB fileTable[128]; 15 | bool fileLocks[128]; 16 | //初始化 17 | FolderManager(DiskManager * dManager); 18 | // 添加目录项,注意:添加时记得往element里面填写tm时间数据 19 | int generateData(string data,string fileName); 20 | // 按照指针指向的FolderElement删除目录项 21 | int deleteData(FCB* element); 22 | // 读取数据 23 | string getData(FCB* element); 24 | // 输出信息:获取所有文件 25 | queue getFiles(); 26 | //上锁 27 | int lockFile(FCB * fcb); 28 | //不上锁 29 | int unlockFile(FCB * fcb); 30 | 31 | // 序列化函数 32 | template 33 | void serialize(Archive & ar){ 34 | ar(CEREAL_NVP(fileTable),CEREAL_NVP(fileLocks)); 35 | } 36 | 37 | }; 38 | 39 | #endif // FOLDERMANAGER_H 40 | -------------------------------------------------------------------------------- /memory_monitor.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MemoryMonitor 4 | 5 | 6 | 7 | 0 8 | 0 9 | 640 10 | 615 11 | 12 | 13 | 14 | MainWindow 15 | 16 | 17 | 18 | 19 | 20 | 30 21 | 10 22 | 581 23 | 551 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | 0 32 | 0 33 | 640 34 | 22 35 | 36 | 37 | 38 | 39 | 40 | 41 | 42 | 43 | -------------------------------------------------------------------------------- /disk_monitor.h: -------------------------------------------------------------------------------- 1 | #ifndef DISK_MONITOR_H 2 | #define DISK_MONITOR_H 3 | 4 | #include "data_define.h" 5 | #include "cglobal.h" 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | namespace Ui { 15 | class DiskMonitor; 16 | } 17 | 18 | class DiskMonitor : public QMainWindow 19 | { 20 | Q_OBJECT 21 | 22 | public: 23 | explicit DiskMonitor(QWidget *parent = nullptr); 24 | ~DiskMonitor(); 25 | 26 | 27 | QTableView* tv_disk; 28 | QStandardItemModel* model; 29 | 30 | QStandardItemModel* notFreeModel; 31 | QLabel *ll_data; 32 | QLabel *ll_status; 33 | QLabel *ll_pos; 34 | QLabel *ll_page; 35 | QLabel *ll_totoal_free; 36 | 37 | 38 | private: 39 | Ui::DiskMonitor *ui; 40 | 41 | queue qMapTemp; 42 | BitMapItem bMItem[32][32]; 43 | 44 | signals: 45 | // 通知主线程更新线程 46 | void needUpdate(); 47 | 48 | public slots: 49 | // 刷新内存 50 | void updateDiskUI(); 51 | // 点击表格事件 52 | void onTableClicked(const QModelIndex & mIndex); 53 | }; 54 | 55 | #endif // DISK_MONITOR_H 56 | -------------------------------------------------------------------------------- /dialog_delete_data.h: -------------------------------------------------------------------------------- 1 | #ifndef DIALOG_DELETE_DATA_H 2 | #define DIALOG_DELETE_DATA_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include "cglobal.h" 13 | 14 | namespace Ui { 15 | class dialog_delete_data; 16 | } 17 | 18 | class dialog_delete_data : public QDialog 19 | { 20 | Q_OBJECT 21 | 22 | public: 23 | explicit dialog_delete_data(QWidget *parent = nullptr); 24 | ~dialog_delete_data(); 25 | 26 | private: 27 | Ui::dialog_delete_data *ui; 28 | QListView *lv_fileLists; 29 | QQueue tmpFCB; 30 | QStandardItemModel * model; 31 | 32 | // 选中的行数 33 | int row_selected; 34 | 35 | // QWidget interface 36 | QLabel* ll_owner; 37 | QLabel* ll_fileSize; 38 | protected: 39 | void closeEvent(QCloseEvent *event); 40 | void getFileList(); 41 | signals: 42 | void dataUpdated(); 43 | 44 | 45 | public slots: 46 | void on_pushButton_clicked(); 47 | // 点击文件 48 | void showClick(QModelIndex index); 49 | // 刷新文件列表 50 | void refresh(); 51 | 52 | }; 53 | 54 | #endif // DIALOG_DELETE_DATA_H 55 | -------------------------------------------------------------------------------- /gendatathread.h: -------------------------------------------------------------------------------- 1 | #ifndef GENDATATHREAD_H 2 | #define GENDATATHREAD_H 3 | 4 | #include 5 | #include "data_define.h" 6 | #include "cglobal.h" 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | 13 | // 执行线程互斥访问信号量 14 | 15 | class GenDataThread : public QThread 16 | { 17 | Q_OBJECT 18 | public: 19 | QString id = "生成数据线程"; 20 | GenDataThread(); 21 | 22 | 23 | protected: 24 | void run(); 25 | 26 | signals: 27 | void showMessage(QString str); 28 | void openUI(); 29 | 30 | }; 31 | 32 | 33 | 34 | class DelDataThread : public QThread 35 | { 36 | Q_OBJECT 37 | public: 38 | QString id = "删除线程"; 39 | DelDataThread(); 40 | 41 | 42 | protected: 43 | void run(); 44 | 45 | signals: 46 | void showMessage(QString str); 47 | void openUI(); 48 | 49 | 50 | }; 51 | 52 | 53 | class ExeDataThread : public QThread 54 | { 55 | Q_OBJECT 56 | public: 57 | QString id = "执行线程"; 58 | ExeDataThread(); 59 | 60 | protected: 61 | void run(); 62 | 63 | signals: 64 | void openUI(TCB* tcb); 65 | // 通知内存有变动 66 | void notify(); 67 | void showMessage(QString str); 68 | 69 | public slots: 70 | 71 | }; 72 | 73 | #endif // GENDATATHREAD_H 74 | -------------------------------------------------------------------------------- /disk_manager.h: -------------------------------------------------------------------------------- 1 | #ifndef DISKMANAGER_H 2 | #define DISKMANAGER_H 3 | #define BLOCK_SIZE 4 4 | #include 5 | #include "data_define.h" 6 | // 序列化存盘 7 | #include "cereal/archives/json.hpp" 8 | #include "cereal/types/unordered_map.hpp" 9 | #include "cereal/types/memory.hpp" 10 | #include "cereal/types/string.hpp" 11 | 12 | class DiskManager 13 | { 14 | public: 15 | //磁盘空间 16 | string disk[1024]; 17 | 18 | //位示图 19 | BitMapItem Map[1024]; 20 | 21 | // 构造函数 22 | DiskManager(); 23 | 24 | //删除对换区数据 25 | int deleteBlock(FCB *e); 26 | 27 | //磁盘分配 28 | int changeBlock(FCB *e,string dt,int number); 29 | 30 | //释放盘块 31 | int ReleaseBlock(FCB *e); 32 | 33 | // 从内存接收对换数据 换入数据 34 | int receiveM(FCB * e,int pageNumber,string data); 35 | 36 | //对内存输出对换数据 换出数据 37 | string returnM(FCB* e,int number); 38 | 39 | // 目录管理申请删除 40 | int receiveF_delete(FCB * e); 41 | 42 | // 目录管理申请添加 43 | int receiveF_add(FCB *e,string data); 44 | 45 | // 目录管理申请读取 46 | string receiveF_read(FCB* e); 47 | 48 | // 输出接口,输出位示图,注意:输出当前位示图中的每一个元素,用queue传值 49 | queue getCurrentBitMap(); 50 | 51 | //根据文件大小分配混合索引的盘块号 52 | Index_File indexFile(int filesize); 53 | 54 | // 序列化函数 55 | template 56 | void serialize(Archive & ar){ 57 | ar(CEREAL_NVP(disk),CEREAL_NVP(Map)); 58 | } 59 | 60 | }; 61 | 62 | 63 | 64 | #endif // DISKMANAGER_H 65 | -------------------------------------------------------------------------------- /window_exe_data.h: -------------------------------------------------------------------------------- 1 | #ifndef EXE_FORM_H 2 | #define EXE_FORM_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | #include 14 | #include 15 | #include 16 | 17 | #include "data_define.h" 18 | #include "cglobal.h" 19 | 20 | namespace Ui { 21 | class window_exe_data; 22 | } 23 | 24 | class window_exe_data : public QWidget 25 | { 26 | Q_OBJECT 27 | 28 | public: 29 | explicit window_exe_data(QWidget *parent = nullptr,TCB* tcb=nullptr); 30 | ~window_exe_data(); 31 | 32 | 33 | 34 | 35 | private: 36 | Ui::window_exe_data *ui; 37 | QPushButton *btnRead; 38 | 39 | QListView* lv_fileList; 40 | QLabel * ll_createTime; 41 | QLabel * ll_owner; 42 | QLabel * ll_fileSize; 43 | QLabel * ll_fileName; 44 | QLabel * ll_loadFile; 45 | QStandardItemModel * model; 46 | QSpinBox * nb_pageNumber; 47 | QTextBrowser * tb_outputBuffer; 48 | 49 | QQueue tmpFCB; 50 | TCB* tcb; 51 | FCB* fileSelected; 52 | bool isInUse; 53 | 54 | signals: 55 | // 做一次操作后,通知主线程更新 56 | void notifyUpdate(); 57 | 58 | public slots: 59 | void on_pushButton_clicked(); 60 | // 更新文件列表 61 | void updateFiles(); 62 | 63 | void on_btn_load_clicked(); 64 | // 选择了文件 65 | void showClick(QModelIndex index); 66 | 67 | // QWidget interface 68 | protected: 69 | void closeEvent(QCloseEvent *event); 70 | }; 71 | 72 | #endif // EXE_FORM_H 73 | -------------------------------------------------------------------------------- /gendatathread.cpp: -------------------------------------------------------------------------------- 1 | #include "gendatathread.h" 2 | #include 3 | 4 | // 构造函数 5 | GenDataThread::GenDataThread() 6 | { 7 | // 备用 8 | } 9 | 10 | ExeDataThread::ExeDataThread() 11 | { 12 | // 备用 13 | } 14 | 15 | DelDataThread::DelDataThread() 16 | { 17 | // 备用 18 | } 19 | 20 | // 多线程 21 | void GenDataThread::run() 22 | { 23 | qDebug()<<"开始运行数据生成线程"; 24 | //等待对话框 25 | bool status = CGlobal::genThreadSem->tryAcquire(); 26 | if (status == false){ 27 | emit showMessage("线程正在运行,但需要等待*数据生成线程*结束..."); 28 | CGlobal::genThreadSem->acquire(); 29 | } 30 | qDebug()<<"开始运行"; 31 | // 显示等待加载框 32 | // 打开MainWindow 33 | emit openUI(); 34 | qDebug()<<"运行结束"; 35 | this->exec(); 36 | } 37 | 38 | 39 | void DelDataThread::run() 40 | { 41 | qDebug()<<"开始运行数据删除线程"; 42 | //等待对话框 43 | bool status = CGlobal::delThreadSem->tryAcquire(); 44 | if (status == false){ 45 | emit showMessage("线程正在运行,但需要等待*数据删除线程*结束..."); 46 | CGlobal::delThreadSem->acquire(); 47 | } 48 | qDebug()<<"开始运行"; 49 | // 通知主线程打开UI 50 | emit openUI(); 51 | qDebug()<<"运行结束"; 52 | this->exec(); 53 | } 54 | 55 | // 执行进程,互斥访问内存 56 | void ExeDataThread::run() 57 | { 58 | TCB* tcb = new TCB(); 59 | // 线程向内存管理器申请内存 60 | // int status = CGlobal::mManager->allocMemory(tcb); 61 | int status = STATUS_OK; 62 | // 先申请4块内容 63 | if (status == STATUS_OK){ 64 | // 通知主线程打开UI,调用tcb 65 | emit openUI(tcb); 66 | } else { 67 | emit showMessage("内存不足,无法打开更多的执行线程,请关闭一些执行线程再重试"); 68 | } 69 | emit notify(); 70 | this->exec(); 71 | } 72 | 73 | 74 | -------------------------------------------------------------------------------- /cereal/external/rapidjson/internal/swap.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef CEREAL_RAPIDJSON_INTERNAL_SWAP_H_ 16 | #define CEREAL_RAPIDJSON_INTERNAL_SWAP_H_ 17 | 18 | #include "../rapidjson.h" 19 | 20 | #if defined(__clang__) 21 | CEREAL_RAPIDJSON_DIAG_PUSH 22 | CEREAL_RAPIDJSON_DIAG_OFF(c++98-compat) 23 | #endif 24 | 25 | CEREAL_RAPIDJSON_NAMESPACE_BEGIN 26 | namespace internal { 27 | 28 | //! Custom swap() to avoid dependency on C++ header 29 | /*! \tparam T Type of the arguments to swap, should be instantiated with primitive C++ types only. 30 | \note This has the same semantics as std::swap(). 31 | */ 32 | template 33 | inline void Swap(T& a, T& b) CEREAL_RAPIDJSON_NOEXCEPT { 34 | T tmp = a; 35 | a = b; 36 | b = tmp; 37 | } 38 | 39 | } // namespace internal 40 | CEREAL_RAPIDJSON_NAMESPACE_END 41 | 42 | #if defined(__clang__) 43 | CEREAL_RAPIDJSON_DIAG_POP 44 | #endif 45 | 46 | #endif // CEREAL_RAPIDJSON_INTERNAL_SWAP_H_ 47 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | #### 1、磁盘管理 2 | 3 | 建立一个4KB大小的文件模拟磁盘,按逻辑将其划分为1024块,每块大小4B.其中900块用于存放普通数据,124块用于存储兑换数据.存储管理需要支持: 4 | 5 | (1)数据组织:对需要存放的文件数据加以组织管理,可以采用连续组织方式、显式连接(FAT)方式、单级索引组织方式、二级索引组织方式、混合索引方式(每组要求不同,具体见“课程设计分组”部分,下同). 6 | 7 | (2)空闲块管理:能够查询并返回当前剩余的空闲块,对空闲块管理可以采用位示图法、空闲盘块表法、空闲盘块连法、成组连接法. 8 | 9 | (3)兑换区管理:能够写入、读出兑换区数据. 10 | 11 | #### 2、目录管理 12 | 13 | 为写入模拟磁盘的数据文件建立目录,目录可以是单级文件目录、双级文件目录、树形结构目录.在目录中选择某个文件可以将其数据读入模拟内存.目录中包含文件名、文件所有者、创建时间、文件结构、在磁盘中存放的地址等信息.目录管理需要支持: 14 | 15 | (1)新建目录:在目录中新建空目录 16 | 17 | (2)删除目录:删除空目录 18 | 19 | (3)为文件建立目录项:一个文件被创建后,为该文件创建目录项,并将文件相关信息写入目录中. 20 | 21 | (4)删除文件:删除目录中某个文件,删除其在磁盘中的数据,并删除目录项.如果被删除文件已经读入内存应该阻止删除,完成基本的文件保护. 22 | 23 | #### 3、内存管理 24 | 25 | 申请一块64字节的内存空间模拟内存,按逻辑划分为16块,每块4B.将目录中选中的文件读入内存,显示文件中信息.内存可以同时显示多个文件信息,每个文件固定分配4个内存块,如果4个内存块不能显示文件全部信息,采用页面置换策略,将已显示完的页换出内存,可以选择的置换策略有,全局置换、局部置换、FIFO、LRU.内存管理需要支持: 26 | 27 | (1)分配内存块:为线程分配内存块,每个线程默认分配4块. 28 | 29 | (2)回收内存:线程结束后回收其内存. 30 | 31 | (3)空闲内存块管理:为进入内存的数据寻找空闲内存块.没有空闲内存时,应给出提示. 32 | 33 | (4)块时间管理:提供数据块进入模拟内存的时间、访问时间的记录和查询功能,为页面置换算法提供支持,当某个内存块被选中时,更新其访问时间. 34 | 35 | #### 3、线程管理 36 | 37 | 本虚拟系统以线程为基本运行单位,线程本身采用编程语言提供的线程机制,不模拟.系统主要包括的线程有: 38 | 39 | (1)数据生成线程:该线程负责生成外存数据,给定数据大小(按字节计算)、数据信息(英文字母)、存储目录、文件名后,该线程调用磁盘管理中空闲磁盘管理功能,申请所需大小的外存块,如果盘块不够给出提示.按照要求的数据组织方式,将数据存入磁盘块(按块分配磁盘),并调用目录管理功能为其在目录中建立目录项,更改空闲盘块信息. 40 | 41 | (2)删除数据线程:该线程调用删除目录管理中文件删除功能删除数据(内存中文件不能删除).并回收外存空间,更新空闲盘块信息. 42 | 43 | (3)执行线程:选择目录中的文件,执行线程将文件数据从外存调入内存,为此,首先需要调用内存管理的空闲空间管理功能,为该进程申请4块空闲内存,如果没有足够内存则给出提示,然后根据目录中文件存储信息将文件数据从外存读入内存,此间如果4块内存不够存放文件信息,需要进行换页(选择的换页策略见分组要求),欢出的页面存放到磁盘兑换区.允许同时运行多个执行线程.文件数据在内存块的分布通过线程的页表(模拟)进行记录. 44 | 45 | (4)线程互斥:对于64B的内存,线程需要互斥访问,避免产生死锁.不能访问内存的线程阻塞,等待被唤醒. 46 | 47 | #### 4、用户接口 48 | 49 | 对内存块、外存块、目录信息进行可视化显示,并能够动态刷新.文件调入内存过程、以及换页过程在块与块之间加入延时,以便观察. 50 | 51 | -------------------------------------------------------------------------------- /memory_manager.h: -------------------------------------------------------------------------------- 1 | #ifndef MEMORYMANAGER_H 2 | #define MEMORYMANAGER_H 3 | 4 | #include 5 | #include 6 | #include "data_define.h" 7 | #include "disk_manager.h" 8 | 9 | typedef struct MemoryBlock{ 10 | //内存块链表 11 | int free_length = 0; //空闲块的数量 12 | MemoryBlockItem block_item; 13 | MemoryBlock* next; 14 | }MemoryBlock, *MemoryBlockList; 15 | 16 | typedef struct BlockPage{ 17 | //线程的页块对应 18 | int block_id; //每个线程页对应的内存块号,-1为不在内存中 19 | int page_id; //线程页号 20 | string page_data; //每页数据 21 | }BlockPage; 22 | 23 | typedef struct PageTable{ 24 | //存放内存页号-TCB-文件页号-数据页表的链 25 | TCB *tcb; //线程标识 26 | vector table; //线程的页表中的数据结构 27 | PageTable * next; 28 | } * TableList; 29 | 30 | class MemoryManager 31 | { 32 | public: 33 | //声明一个内存块链表 34 | MemoryBlockList mem_list; 35 | 36 | //声明映射表 37 | TableList tableList; 38 | 39 | DiskManager * dManager; 40 | 41 | // 构造函数 42 | MemoryManager(DiskManager * dManager); 43 | 44 | // 分配内存,分配成功isAlloc <- true. 45 | int allocMemory(TCB *t); 46 | 47 | // 释放TCB里面的数据 48 | int freeBlock(TCB *t); 49 | 50 | // 从内存读取数据,index 51 | ReadStat read(TCB *t,int pageIndex); 52 | 53 | // // 回写数据 54 | // int writeBack(TCB* t,int pageIndex); 55 | // 56 | // 读取换出页的数据 57 | string loadWriteBackData(TCB* t,int pageIndex); 58 | 59 | // 输出当前MemoryBlock的状态 60 | queue getCurrentMemoryBlock(); 61 | 62 | //更新内存块调用时间 63 | static void reGetAccessTime(MemoryBlock *mb); 64 | 65 | //更新内存块分配时间 66 | static void getEnterTime(MemoryBlock *mb); 67 | 68 | //更新页表链 69 | void creatPageTable(TCB *t); 70 | 71 | //处理缺页 72 | int loosePage(TCB *t, int pageIndex, string data); 73 | 74 | //页面置换算法 75 | int LRU(TCB *t, int pageIndex, string data); 76 | 77 | //获取最近最久未访问的内存块号 78 | int lruBlockId(); 79 | }; 80 | 81 | #endif // MEMORYMANAGER_H 82 | -------------------------------------------------------------------------------- /cereal/types/map.hpp: -------------------------------------------------------------------------------- 1 | /*! \file map.hpp 2 | \brief Support for types found in \ 3 | \ingroup STLSupport */ 4 | /* 5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of cereal nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef CEREAL_TYPES_MAP_HPP_ 31 | #define CEREAL_TYPES_MAP_HPP_ 32 | 33 | #include "cereal/types/concepts/pair_associative_container.hpp" 34 | #include 35 | 36 | #endif // CEREAL_TYPES_MAP_HPP_ 37 | -------------------------------------------------------------------------------- /cereal/types/unordered_map.hpp: -------------------------------------------------------------------------------- 1 | /*! \file unordered_map.hpp 2 | \brief Support for types found in \ 3 | \ingroup STLSupport */ 4 | /* 5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of cereal nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef CEREAL_TYPES_UNORDERED_MAP_HPP_ 31 | #define CEREAL_TYPES_UNORDERED_MAP_HPP_ 32 | 33 | #include "cereal/types/concepts/pair_associative_container.hpp" 34 | #include 35 | 36 | #endif // CEREAL_TYPES_UNORDERED_MAP_HPP_ 37 | -------------------------------------------------------------------------------- /cereal/types/functional.hpp: -------------------------------------------------------------------------------- 1 | /*! \file functional.hpp 2 | \brief Support for types found in \ 3 | \ingroup STLSupport */ 4 | /* 5 | Copyright (c) 2016, Randolph Voorhies, Shane Grant 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of cereal nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef CEREAL_TYPES_FUNCTIONAL_HPP_ 31 | #define CEREAL_TYPES_FUNCTIONAL_HPP_ 32 | 33 | #include 34 | 35 | namespace cereal 36 | { 37 | //! Saving for std::less 38 | template inline 39 | void serialize( Archive &, std::less & ) 40 | { } 41 | } // namespace cereal 42 | 43 | #endif // CEREAL_TYPES_FUNCTIONAL_HPP_ 44 | -------------------------------------------------------------------------------- /systemwindow.h: -------------------------------------------------------------------------------- 1 | #ifndef SYSTEMWINDOW_H 2 | #define SYSTEMWINDOW_H 3 | 4 | #include 5 | #include 6 | #include 7 | #include 8 | #include "gendatathread.h" 9 | #include "window_exe_data.h" 10 | #include 11 | #include 12 | #include "data_define.h" 13 | #include "cglobal.h" 14 | #include "memory_monitor.h" 15 | #include "dialog_delete_data.h" 16 | #include "dialog_gen_data.h" 17 | #include 18 | 19 | namespace Ui { 20 | class SystemWindow; 21 | } 22 | 23 | class SystemWindow : public QMainWindow 24 | { 25 | Q_OBJECT 26 | 27 | public: 28 | explicit SystemWindow(QWidget *parent = nullptr); 29 | ~SystemWindow(); 30 | 31 | // 功能 32 | QLabel * functionLabel; 33 | QPushButton * btn_gen_data; 34 | QPushButton * btn_del_data; 35 | QPushButton * btn_exe_data; 36 | QHBoxLayout * h1Layout; 37 | 38 | // 监视 39 | QLabel * monitorLabel; 40 | QPushButton * btn_memory_monitor; 41 | QPushButton * btn_disk_monitor; 42 | QHBoxLayout * h2Layout; 43 | 44 | // Window 45 | window_exe_data * exeform; 46 | MemoryMonitor * mMonitor; 47 | 48 | 49 | signals: 50 | void onMoveToPushButton(QString btnStr); 51 | 52 | void updateMemoryBitMap(queue items); 53 | // 主线程发信号,通知两个监视器更新数据 54 | void notifyUpdate(); 55 | 56 | public slots: 57 | // 状态显示 58 | void showMessageOnStatusBar(QString str); 59 | void showBtnTextOnStatusBar(); 60 | 61 | // 创建进程 62 | void createDataGenThread(); 63 | void createDataDelThread(); 64 | void createDataExeThread(); 65 | 66 | // 打开监视 67 | void openDataGenUI(); 68 | void openDataDelUI(); 69 | void openDataExeUI(TCB* tcb); 70 | void openMemoryMonitor(); 71 | void openDiskMonitor(); 72 | 73 | // 显示等待框 74 | void showDialog(QDialog * dialog); 75 | void closeDialog(QDialog * dialog); 76 | void showMessage(QString str); 77 | 78 | // 更新槽,通知内存和磁盘监视器进行刷新 79 | void updateMemoryUI(); 80 | void updateDiskUI(); 81 | 82 | // 接受数据生成、删除线程传递的槽,通知主线程数据发生变化 83 | void updateData(); 84 | 85 | 86 | private: 87 | Ui::SystemWindow *ui; 88 | 89 | // QWidget interface 90 | protected: 91 | void closeEvent(QCloseEvent *event); 92 | }; 93 | 94 | #endif // SYSTEMWINDOW_H 95 | -------------------------------------------------------------------------------- /cereal/types/utility.hpp: -------------------------------------------------------------------------------- 1 | /*! \file utility.hpp 2 | \brief Support for types found in \ 3 | \ingroup STLSupport */ 4 | /* 5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of cereal nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef CEREAL_TYPES_UTILITY_HPP_ 31 | #define CEREAL_TYPES_UTILITY_HPP_ 32 | 33 | #include "cereal/cereal.hpp" 34 | #include 35 | 36 | namespace cereal 37 | { 38 | //! Serializing for std::pair 39 | template inline 40 | void CEREAL_SERIALIZE_FUNCTION_NAME( Archive & ar, std::pair & pair ) 41 | { 42 | ar( CEREAL_NVP_("first", pair.first), 43 | CEREAL_NVP_("second", pair.second) ); 44 | } 45 | } // namespace cereal 46 | 47 | #endif // CEREAL_TYPES_UTILITY_HPP_ 48 | -------------------------------------------------------------------------------- /OperatingSystem.pro: -------------------------------------------------------------------------------- 1 | #------------------------------------------------- 2 | # 3 | # Project created by QtCreator 2019-12-25T10:02:58 4 | # 5 | #------------------------------------------------- 6 | 7 | QT += core gui 8 | 9 | greaterThan(QT_MAJOR_VERSION, 4): QT += widgets 10 | 11 | TARGET = OperatingSystem 12 | TEMPLATE = app 13 | 14 | # The following define makes your compiler emit warnings if you use 15 | # any feature of Qt which has been marked as deprecated (the exact warnings 16 | # depend on your compiler). Please consult the documentation of the 17 | # deprecated API in order to know how to port your code away from it. 18 | DEFINES += QT_DEPRECATED_WARNINGS 19 | 20 | # You can also make your code fail to compile if you use deprecated APIs. 21 | # In order to do so, uncomment the following line. 22 | # You can also select to disable deprecated APIs only up to a certain version of Qt. 23 | #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 24 | 25 | CONFIG += c++11 26 | 27 | SOURCES += \ 28 | cglobal.cpp \ 29 | data_define.cpp \ 30 | dialog_delete_data.cpp \ 31 | dialog_gen_data.cpp \ 32 | disk_manager.cpp \ 33 | disk_monitor.cpp \ 34 | folder_manager.cpp \ 35 | gendatathread.cpp \ 36 | main.cpp \ 37 | mainwindow.cpp \ 38 | memory_manager.cpp \ 39 | memory_monitor.cpp \ 40 | systemwindow.cpp \ 41 | user.cpp \ 42 | window_exe_data.cpp 43 | 44 | HEADERS += \ 45 | cglobal.h \ 46 | data_define.h \ 47 | dialog_delete_data.h \ 48 | dialog_gen_data.h \ 49 | disk_manager.h \ 50 | disk_monitor.h \ 51 | folder_manager.h \ 52 | gendatathread.h \ 53 | memory_manager.h \ 54 | memory_monitor.h \ 55 | systemwindow.h \ 56 | user.h \ 57 | widget.h \ 58 | mainwindow.h \ 59 | window_exe_data.h 60 | 61 | FORMS += \ 62 | dialog_delete_data.ui \ 63 | dialog_gen_data.ui \ 64 | disk_monitor.ui \ 65 | mainwindow.ui \ 66 | memory_monitor.ui \ 67 | systemwindow.ui \ 68 | window_exe_data.ui 69 | 70 | # Default rules for deployment. 71 | qnx: target.path = /tmp/$${TARGET}/bin 72 | else: unix:!android: target.path = /opt/$${TARGET}/bin 73 | !isEmpty(target.path): INSTALLS += target 74 | -------------------------------------------------------------------------------- /cereal/types/atomic.hpp: -------------------------------------------------------------------------------- 1 | /*! \file atomic.hpp 2 | \brief Support for types found in \ 3 | \ingroup STLSupport */ 4 | /* 5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of cereal nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef CEREAL_TYPES_ATOMIC_HPP_ 31 | #define CEREAL_TYPES_ATOMIC_HPP_ 32 | 33 | #include 34 | #include 35 | 36 | namespace cereal 37 | { 38 | //! Serializing (save) for std::atomic 39 | template inline 40 | void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::atomic const & a ) 41 | { 42 | ar( CEREAL_NVP_("atomic_data", a.load()) ); 43 | } 44 | 45 | //! Serializing (load) for std::atomic 46 | template inline 47 | void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::atomic & a ) 48 | { 49 | T tmp; 50 | ar( CEREAL_NVP_("atomic_data", tmp) ); 51 | a.store( tmp ); 52 | } 53 | } // namespace cereal 54 | 55 | #endif // CEREAL_TYPES_ATOMIC_HPP_ 56 | -------------------------------------------------------------------------------- /cereal/version.hpp: -------------------------------------------------------------------------------- 1 | /*! \file version.hpp 2 | \brief Macros to detect cereal version 3 | 4 | These macros can assist in determining the version of cereal. Be 5 | warned that cereal is not guaranteed to be compatible across 6 | different versions. For more information on releases of cereal, 7 | see https://github.com/USCiLab/cereal/releases. 8 | 9 | \ingroup utility */ 10 | /* 11 | Copyright (c) 2018, Shane Grant 12 | All rights reserved. 13 | 14 | Redistribution and use in source and binary forms, with or without 15 | modification, are permitted provided that the following conditions are met: 16 | * Redistributions of source code must retain the above copyright 17 | notice, this list of conditions and the following disclaimer. 18 | * Redistributions in binary form must reproduce the above copyright 19 | notice, this list of conditions and the following disclaimer in the 20 | documentation and/or other materials provided with the distribution. 21 | * Neither the name of cereal nor the 22 | names of its contributors may be used to endorse or promote products 23 | derived from this software without specific prior written permission. 24 | 25 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 26 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 27 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 28 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY 29 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 30 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 31 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 32 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 33 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 34 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 35 | */ 36 | 37 | #ifndef CEREAL_VERSION_HPP_ 38 | #define CEREAL_VERSION_HPP_ 39 | 40 | //! The major version 41 | #define CEREAL_VERSION_MAJOR 1 42 | //! The minor version 43 | #define CEREAL_VERSION_MINOR 3 44 | //! The patch version 45 | #define CEREAL_VERSION_PATCH 0 46 | 47 | //! The full version as a single number 48 | #define CEREAL_VERSION (CEREAL_VERSION_MAJOR * 10000 \ 49 | + CEREAL_VERSION_MINOR * 100 \ 50 | + CEREAL_VERSION_PATCH) 51 | 52 | #endif // CEREAL_VERSION_HPP_ 53 | -------------------------------------------------------------------------------- /cereal/external/rapidjson/internal/strfunc.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef CEREAL_RAPIDJSON_INTERNAL_STRFUNC_H_ 16 | #define CEREAL_RAPIDJSON_INTERNAL_STRFUNC_H_ 17 | 18 | #include "../stream.h" 19 | #include 20 | 21 | CEREAL_RAPIDJSON_NAMESPACE_BEGIN 22 | namespace internal { 23 | 24 | //! Custom strlen() which works on different character types. 25 | /*! \tparam Ch Character type (e.g. char, wchar_t, short) 26 | \param s Null-terminated input string. 27 | \return Number of characters in the string. 28 | \note This has the same semantics as strlen(), the return value is not number of Unicode codepoints. 29 | */ 30 | template 31 | inline SizeType StrLen(const Ch* s) { 32 | CEREAL_RAPIDJSON_ASSERT(s != 0); 33 | const Ch* p = s; 34 | while (*p) ++p; 35 | return SizeType(p - s); 36 | } 37 | 38 | template <> 39 | inline SizeType StrLen(const char* s) { 40 | return SizeType(std::strlen(s)); 41 | } 42 | 43 | template <> 44 | inline SizeType StrLen(const wchar_t* s) { 45 | return SizeType(std::wcslen(s)); 46 | } 47 | 48 | //! Returns number of code points in a encoded string. 49 | template 50 | bool CountStringCodePoint(const typename Encoding::Ch* s, SizeType length, SizeType* outCount) { 51 | CEREAL_RAPIDJSON_ASSERT(s != 0); 52 | CEREAL_RAPIDJSON_ASSERT(outCount != 0); 53 | GenericStringStream is(s); 54 | const typename Encoding::Ch* end = s + length; 55 | SizeType count = 0; 56 | while (is.src_ < end) { 57 | unsigned codepoint; 58 | if (!Encoding::Decode(is, &codepoint)) 59 | return false; 60 | count++; 61 | } 62 | *outCount = count; 63 | return true; 64 | } 65 | 66 | } // namespace internal 67 | CEREAL_RAPIDJSON_NAMESPACE_END 68 | 69 | #endif // CEREAL_RAPIDJSON_INTERNAL_STRFUNC_H_ 70 | -------------------------------------------------------------------------------- /cereal/types/complex.hpp: -------------------------------------------------------------------------------- 1 | /*! \file complex.hpp 2 | \brief Support for types found in \ 3 | \ingroup STLSupport */ 4 | /* 5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of cereal nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef CEREAL_TYPES_COMPLEX_HPP_ 31 | #define CEREAL_TYPES_COMPLEX_HPP_ 32 | 33 | #include 34 | 35 | namespace cereal 36 | { 37 | //! Serializing (save) for std::complex 38 | template inline 39 | void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::complex const & comp ) 40 | { 41 | ar( CEREAL_NVP_("real", comp.real()), 42 | CEREAL_NVP_("imag", comp.imag()) ); 43 | } 44 | 45 | //! Serializing (load) for std::complex 46 | template inline 47 | void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::complex & bits ) 48 | { 49 | T real, imag; 50 | ar( CEREAL_NVP_("real", real), 51 | CEREAL_NVP_("imag", imag) ); 52 | bits = {real, imag}; 53 | } 54 | } // namespace cereal 55 | 56 | #endif // CEREAL_TYPES_COMPLEX_HPP_ 57 | -------------------------------------------------------------------------------- /memory_monitor.cpp: -------------------------------------------------------------------------------- 1 | #include "memory_monitor.h" 2 | #include "ui_memory_monitor.h" 3 | 4 | MemoryMonitor::MemoryMonitor(QWidget *parent) : 5 | QMainWindow(parent), 6 | ui(new Ui::MemoryMonitor) 7 | { 8 | ui->setupUi(this); 9 | this->setWindowTitle("内存监视器"); 10 | // 关闭即销毁 11 | this->setAttribute(Qt::WA_DeleteOnClose,true); 12 | // 定义 13 | tv_memory = ui->tv_memory; 14 | 15 | model = new QStandardItemModel(tv_memory); 16 | // 4列,内存号,内存内容,是否空闲,最近一次访问时间 17 | model->setColumnCount(4); 18 | model->setHeaderData(0,Qt::Horizontal,"内存号"); 19 | model->setHeaderData(1,Qt::Horizontal,"内存内容"); 20 | model->setHeaderData(2,Qt::Horizontal,"是否空闲"); 21 | model->setHeaderData(3,Qt::Horizontal,"最近访问时间"); 22 | // 设置属性 23 | tv_memory->setModel(model); 24 | tv_memory->horizontalHeader()->setDefaultAlignment(Qt::AlignCenter); 25 | tv_memory->setEditTriggers(QTableView::NoEditTriggers); 26 | tv_memory->setRowHeight(0,50); 27 | tv_memory->setSelectionMode(QAbstractItemView::SingleSelection); 28 | tv_memory->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); 29 | tv_memory->verticalHeader()->hide(); 30 | 31 | // 刷新数据 32 | updateMemoryUI(); 33 | } 34 | 35 | MemoryMonitor::~MemoryMonitor() 36 | { 37 | delete ui; 38 | } 39 | 40 | // 刷新UI 41 | void MemoryMonitor::updateMemoryUI() 42 | { 43 | qDebug() << "内存监视器:更新数据"; 44 | queue items = CGlobal::mManager->getCurrentMemoryBlock(); 45 | // 清空表格 46 | //model->removeRows(0,model->rowCount()); 47 | 48 | int cnt = 0; 49 | while(!items.empty()){ 50 | auto qitem = items.front(); 51 | QStandardItem * id =new QStandardItem(); 52 | QStandardItem * data =new QStandardItem(); 53 | QStandardItem * isAlloc =new QStandardItem(); 54 | QStandardItem * lTime = new QStandardItem(); 55 | 56 | id->setTextAlignment(Qt::AlignCenter); 57 | data->setTextAlignment(Qt::AlignCenter); 58 | isAlloc->setTextAlignment(Qt::AlignCenter); 59 | lTime->setTextAlignment(Qt::AlignCenter); 60 | 61 | id->setText(QString::number(qitem.id)); 62 | data->setText(QString::fromStdString(qitem.data)); 63 | lTime->setText(parseTMSimple(qitem.time.accessTime)); 64 | 65 | model->setItem(cnt,0,id); 66 | model->setItem(cnt,1,data); 67 | model->setItem(cnt,3,lTime); 68 | 69 | if(qitem.isFree){ 70 | isAlloc->setText("是"); 71 | } else { 72 | isAlloc->setText("否"); 73 | } 74 | model->setItem(cnt,2,isAlloc); 75 | items.pop(); 76 | cnt++; 77 | } 78 | } 79 | 80 | -------------------------------------------------------------------------------- /cereal/types/list.hpp: -------------------------------------------------------------------------------- 1 | /*! \file list.hpp 2 | \brief Support for types found in \ 3 | \ingroup STLSupport */ 4 | /* 5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of cereal nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef CEREAL_TYPES_LIST_HPP_ 31 | #define CEREAL_TYPES_LIST_HPP_ 32 | 33 | #include "cereal/cereal.hpp" 34 | #include 35 | 36 | namespace cereal 37 | { 38 | //! Saving for std::list 39 | template inline 40 | void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::list const & list ) 41 | { 42 | ar( make_size_tag( static_cast(list.size()) ) ); 43 | 44 | for( auto const & i : list ) 45 | ar( i ); 46 | } 47 | 48 | //! Loading for std::list 49 | template inline 50 | void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::list & list ) 51 | { 52 | size_type size; 53 | ar( make_size_tag( size ) ); 54 | 55 | list.resize( static_cast( size ) ); 56 | 57 | for( auto & i : list ) 58 | ar( i ); 59 | } 60 | } // namespace cereal 61 | 62 | #endif // CEREAL_TYPES_LIST_HPP_ 63 | -------------------------------------------------------------------------------- /cereal/types/deque.hpp: -------------------------------------------------------------------------------- 1 | /*! \file deque.hpp 2 | \brief Support for types found in \ 3 | \ingroup STLSupport */ 4 | /* 5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of cereal nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef CEREAL_TYPES_DEQUE_HPP_ 31 | #define CEREAL_TYPES_DEQUE_HPP_ 32 | 33 | #include "cereal/cereal.hpp" 34 | #include 35 | 36 | namespace cereal 37 | { 38 | //! Saving for std::deque 39 | template inline 40 | void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::deque const & deque ) 41 | { 42 | ar( make_size_tag( static_cast(deque.size()) ) ); 43 | 44 | for( auto const & i : deque ) 45 | ar( i ); 46 | } 47 | 48 | //! Loading for std::deque 49 | template inline 50 | void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::deque & deque ) 51 | { 52 | size_type size; 53 | ar( make_size_tag( size ) ); 54 | 55 | deque.resize( static_cast( size ) ); 56 | 57 | for( auto & i : deque ) 58 | ar( i ); 59 | } 60 | } // namespace cereal 61 | 62 | #endif // CEREAL_TYPES_DEQUE_HPP_ 63 | -------------------------------------------------------------------------------- /cereal/external/rapidjson/cursorstreamwrapper.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef CEREAL_RAPIDJSON_CURSORSTREAMWRAPPER_H_ 16 | #define CEREAL_RAPIDJSON_CURSORSTREAMWRAPPER_H_ 17 | 18 | #include "stream.h" 19 | 20 | #if defined(__GNUC__) 21 | CEREAL_RAPIDJSON_DIAG_PUSH 22 | CEREAL_RAPIDJSON_DIAG_OFF(effc++) 23 | #endif 24 | 25 | #if defined(_MSC_VER) && _MSC_VER <= 1800 26 | CEREAL_RAPIDJSON_DIAG_PUSH 27 | CEREAL_RAPIDJSON_DIAG_OFF(4702) // unreachable code 28 | CEREAL_RAPIDJSON_DIAG_OFF(4512) // assignment operator could not be generated 29 | #endif 30 | 31 | CEREAL_RAPIDJSON_NAMESPACE_BEGIN 32 | 33 | 34 | //! Cursor stream wrapper for counting line and column number if error exists. 35 | /*! 36 | \tparam InputStream Any stream that implements Stream Concept 37 | */ 38 | template > 39 | class CursorStreamWrapper : public GenericStreamWrapper { 40 | public: 41 | typedef typename Encoding::Ch Ch; 42 | 43 | CursorStreamWrapper(InputStream& is): 44 | GenericStreamWrapper(is), line_(1), col_(0) {} 45 | 46 | // counting line and column number 47 | Ch Take() { 48 | Ch ch = this->is_.Take(); 49 | if(ch == '\n') { 50 | line_ ++; 51 | col_ = 0; 52 | } else { 53 | col_ ++; 54 | } 55 | return ch; 56 | } 57 | 58 | //! Get the error line number, if error exists. 59 | size_t GetLine() const { return line_; } 60 | //! Get the error column number, if error exists. 61 | size_t GetColumn() const { return col_; } 62 | 63 | private: 64 | size_t line_; //!< Current Line 65 | size_t col_; //!< Current Column 66 | }; 67 | 68 | #if defined(_MSC_VER) && _MSC_VER <= 1800 69 | CEREAL_RAPIDJSON_DIAG_POP 70 | #endif 71 | 72 | #if defined(__GNUC__) 73 | CEREAL_RAPIDJSON_DIAG_POP 74 | #endif 75 | 76 | CEREAL_RAPIDJSON_NAMESPACE_END 77 | 78 | #endif // CEREAL_RAPIDJSON_CURSORSTREAMWRAPPER_H_ 79 | -------------------------------------------------------------------------------- /dialog_delete_data.cpp: -------------------------------------------------------------------------------- 1 | #include "dialog_delete_data.h" 2 | #include "ui_dialog_delete_data.h" 3 | 4 | dialog_delete_data::dialog_delete_data(QWidget *parent) : 5 | QDialog(parent), 6 | ui(new Ui::dialog_delete_data) 7 | { 8 | ui->setupUi(this); 9 | this->setWindowTitle("删除数据"); 10 | // 关闭即销毁 11 | this->setAttribute (Qt::WA_DeleteOnClose,true); 12 | model = new QStandardItemModel(this); 13 | row_selected = -1; 14 | lv_fileLists = ui->lv_fileLists; 15 | ll_owner = ui->text_owner; 16 | ll_fileSize = ui->text_fileSize; 17 | lv_fileLists->setModel(model); 18 | connect(lv_fileLists,SIGNAL(clicked(QModelIndex)),this,SLOT(showClick(QModelIndex))); 19 | getFileList(); 20 | } 21 | 22 | dialog_delete_data::~dialog_delete_data() 23 | { 24 | delete ui; 25 | } 26 | 27 | void dialog_delete_data::closeEvent(QCloseEvent *event) 28 | { 29 | CGlobal::delThreadSem->release(); 30 | } 31 | 32 | // 获取文件列表 33 | void dialog_delete_data::getFileList() 34 | { 35 | // 清空缓存数据 36 | model->clear(); 37 | tmpFCB.clear(); 38 | row_selected = -1; 39 | queue q = CGlobal::fManager->getFiles(); 40 | // 备份一份 41 | while(!q.empty()){ 42 | FCB* fcb = q.front(); 43 | QStandardItem * item = new QStandardItem(); 44 | item->setEditable(false); 45 | item->setText(QString::fromStdString(fcb->fileName)); 46 | model->appendRow(item); 47 | q.pop(); 48 | tmpFCB.push_back(fcb); 49 | } 50 | } 51 | 52 | void dialog_delete_data::on_pushButton_clicked() 53 | { 54 | int row = row_selected; 55 | QMessageBox * mBox = new QMessageBox(this); 56 | if (row != -1){ 57 | FCB* fcb = tmpFCB.at(row); 58 | int status = CGlobal::fManager->deleteData(fcb); 59 | switch (status) { 60 | case STATUS_OK: 61 | mBox->setText("删除成功"); 62 | break; 63 | case STATUS_BUSY: 64 | mBox->setText("文件正在使用,请稍后再试"); 65 | break; 66 | case STATUS_ERR: 67 | mBox->setText("删除失败"); 68 | break; 69 | } 70 | mBox->exec(); 71 | emit dataUpdated(); 72 | refresh(); 73 | } else { 74 | mBox->setText("请选择要删除的文件"); 75 | mBox->exec(); 76 | } 77 | } 78 | 79 | void dialog_delete_data::showClick(QModelIndex index) 80 | { 81 | qDebug() << "点击了一个文件:行数"+QString::number(index.row()); 82 | row_selected = index.row(); 83 | ll_fileSize->setText(QString::number(tmpFCB.at(row_selected)->fileSize)); 84 | ll_owner->setText(QString::fromStdString(tmpFCB.at(row_selected)->owner)); 85 | } 86 | 87 | void dialog_delete_data::refresh() 88 | { 89 | ll_owner->clear(); 90 | ll_fileSize->clear(); 91 | getFileList(); 92 | } 93 | -------------------------------------------------------------------------------- /cereal/external/rapidjson/ostreamwrapper.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef CEREAL_RAPIDJSON_OSTREAMWRAPPER_H_ 16 | #define CEREAL_RAPIDJSON_OSTREAMWRAPPER_H_ 17 | 18 | #include "stream.h" 19 | #include 20 | 21 | #ifdef __clang__ 22 | CEREAL_RAPIDJSON_DIAG_PUSH 23 | CEREAL_RAPIDJSON_DIAG_OFF(padded) 24 | #endif 25 | 26 | CEREAL_RAPIDJSON_NAMESPACE_BEGIN 27 | 28 | //! Wrapper of \c std::basic_ostream into RapidJSON's Stream concept. 29 | /*! 30 | The classes can be wrapped including but not limited to: 31 | 32 | - \c std::ostringstream 33 | - \c std::stringstream 34 | - \c std::wpstringstream 35 | - \c std::wstringstream 36 | - \c std::ifstream 37 | - \c std::fstream 38 | - \c std::wofstream 39 | - \c std::wfstream 40 | 41 | \tparam StreamType Class derived from \c std::basic_ostream. 42 | */ 43 | 44 | template 45 | class BasicOStreamWrapper { 46 | public: 47 | typedef typename StreamType::char_type Ch; 48 | BasicOStreamWrapper(StreamType& stream) : stream_(stream) {} 49 | 50 | void Put(Ch c) { 51 | stream_.put(c); 52 | } 53 | 54 | void Flush() { 55 | stream_.flush(); 56 | } 57 | 58 | // Not implemented 59 | char Peek() const { CEREAL_RAPIDJSON_ASSERT(false); return 0; } 60 | char Take() { CEREAL_RAPIDJSON_ASSERT(false); return 0; } 61 | size_t Tell() const { CEREAL_RAPIDJSON_ASSERT(false); return 0; } 62 | char* PutBegin() { CEREAL_RAPIDJSON_ASSERT(false); return 0; } 63 | size_t PutEnd(char*) { CEREAL_RAPIDJSON_ASSERT(false); return 0; } 64 | 65 | private: 66 | BasicOStreamWrapper(const BasicOStreamWrapper&); 67 | BasicOStreamWrapper& operator=(const BasicOStreamWrapper&); 68 | 69 | StreamType& stream_; 70 | }; 71 | 72 | typedef BasicOStreamWrapper OStreamWrapper; 73 | typedef BasicOStreamWrapper WOStreamWrapper; 74 | 75 | #ifdef __clang__ 76 | CEREAL_RAPIDJSON_DIAG_POP 77 | #endif 78 | 79 | CEREAL_RAPIDJSON_NAMESPACE_END 80 | 81 | #endif // CEREAL_RAPIDJSON_OSTREAMWRAPPER_H_ 82 | -------------------------------------------------------------------------------- /cereal/types/optional.hpp: -------------------------------------------------------------------------------- 1 | /*! \file optional.hpp 2 | \brief Support for std::optional 3 | \ingroup STLSupport */ 4 | /* 5 | Copyright (c) 2017, Juan Pedro Bolivar Puente 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of cereal nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef CEREAL_TYPES_STD_OPTIONAL_ 31 | #define CEREAL_TYPES_STD_OPTIONAL_ 32 | 33 | #include "cereal/cereal.hpp" 34 | #include 35 | 36 | namespace cereal { 37 | //! Saving for std::optional 38 | template inline 39 | void CEREAL_SAVE_FUNCTION_NAME(Archive& ar, const std::optional& optional) 40 | { 41 | if(!optional) { 42 | ar(CEREAL_NVP_("nullopt", true)); 43 | } else { 44 | ar(CEREAL_NVP_("nullopt", false), 45 | CEREAL_NVP_("data", *optional)); 46 | } 47 | } 48 | 49 | //! Loading for std::optional 50 | template inline 51 | void CEREAL_LOAD_FUNCTION_NAME(Archive& ar, std::optional& optional) 52 | { 53 | bool nullopt; 54 | ar(CEREAL_NVP_("nullopt", nullopt)); 55 | 56 | if (nullopt) { 57 | optional = std::nullopt; 58 | } else { 59 | T value; 60 | ar(CEREAL_NVP_("data", value)); 61 | optional = std::move(value); 62 | } 63 | } 64 | } // namespace cereal 65 | 66 | #endif // CEREAL_TYPES_STD_OPTIONAL_ 67 | -------------------------------------------------------------------------------- /cereal/external/rapidjson/memorybuffer.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef CEREAL_RAPIDJSON_MEMORYBUFFER_H_ 16 | #define CEREAL_RAPIDJSON_MEMORYBUFFER_H_ 17 | 18 | #include "stream.h" 19 | #include "internal/stack.h" 20 | 21 | CEREAL_RAPIDJSON_NAMESPACE_BEGIN 22 | 23 | //! Represents an in-memory output byte stream. 24 | /*! 25 | This class is mainly for being wrapped by EncodedOutputStream or AutoUTFOutputStream. 26 | 27 | It is similar to FileWriteBuffer but the destination is an in-memory buffer instead of a file. 28 | 29 | Differences between MemoryBuffer and StringBuffer: 30 | 1. StringBuffer has Encoding but MemoryBuffer is only a byte buffer. 31 | 2. StringBuffer::GetString() returns a null-terminated string. MemoryBuffer::GetBuffer() returns a buffer without terminator. 32 | 33 | \tparam Allocator type for allocating memory buffer. 34 | \note implements Stream concept 35 | */ 36 | template 37 | struct GenericMemoryBuffer { 38 | typedef char Ch; // byte 39 | 40 | GenericMemoryBuffer(Allocator* allocator = 0, size_t capacity = kDefaultCapacity) : stack_(allocator, capacity) {} 41 | 42 | void Put(Ch c) { *stack_.template Push() = c; } 43 | void Flush() {} 44 | 45 | void Clear() { stack_.Clear(); } 46 | void ShrinkToFit() { stack_.ShrinkToFit(); } 47 | Ch* Push(size_t count) { return stack_.template Push(count); } 48 | void Pop(size_t count) { stack_.template Pop(count); } 49 | 50 | const Ch* GetBuffer() const { 51 | return stack_.template Bottom(); 52 | } 53 | 54 | size_t GetSize() const { return stack_.GetSize(); } 55 | 56 | static const size_t kDefaultCapacity = 256; 57 | mutable internal::Stack stack_; 58 | }; 59 | 60 | typedef GenericMemoryBuffer<> MemoryBuffer; 61 | 62 | //! Implement specialized version of PutN() with memset() for better performance. 63 | template<> 64 | inline void PutN(MemoryBuffer& memoryBuffer, char c, size_t n) { 65 | std::memset(memoryBuffer.stack_.Push(n), c, n * sizeof(c)); 66 | } 67 | 68 | CEREAL_RAPIDJSON_NAMESPACE_END 69 | 70 | #endif // CEREAL_RAPIDJSON_MEMORYBUFFER_H_ 71 | -------------------------------------------------------------------------------- /cereal/external/rapidxml/license.txt: -------------------------------------------------------------------------------- 1 | Use of this software is granted under one of the following two licenses, 2 | to be chosen freely by the user. 3 | 4 | 1. Boost Software License - Version 1.0 - August 17th, 2003 5 | =============================================================================== 6 | 7 | Copyright (c) 2006, 2007 Marcin Kalicinski 8 | 9 | Permission is hereby granted, free of charge, to any person or organization 10 | obtaining a copy of the software and accompanying documentation covered by 11 | this license (the "Software") to use, reproduce, display, distribute, 12 | execute, and transmit the Software, and to prepare derivative works of the 13 | Software, and to permit third-parties to whom the Software is furnished to 14 | do so, all subject to the following: 15 | 16 | The copyright notices in the Software and this entire statement, including 17 | the above license grant, this restriction and the following disclaimer, 18 | must be included in all copies of the Software, in whole or in part, and 19 | all derivative works of the Software, unless such copies or derivative 20 | works are solely in the form of machine-executable object code generated by 21 | a source language processor. 22 | 23 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25 | FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT 26 | SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE 27 | FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, 28 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 29 | DEALINGS IN THE SOFTWARE. 30 | 31 | 2. The MIT License 32 | =============================================================================== 33 | 34 | Copyright (c) 2006, 2007 Marcin Kalicinski 35 | 36 | Permission is hereby granted, free of charge, to any person obtaining a copy 37 | of this software and associated documentation files (the "Software"), to deal 38 | in the Software without restriction, including without limitation the rights 39 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 40 | of the Software, and to permit persons to whom the Software is furnished to do so, 41 | subject to the following conditions: 42 | 43 | The above copyright notice and this permission notice shall be included in all 44 | copies or substantial portions of the Software. 45 | 46 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 47 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 48 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 49 | THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 50 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 51 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 52 | IN THE SOFTWARE. 53 | -------------------------------------------------------------------------------- /cereal/external/rapidjson/memorystream.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef CEREAL_RAPIDJSON_MEMORYSTREAM_H_ 16 | #define CEREAL_RAPIDJSON_MEMORYSTREAM_H_ 17 | 18 | #include "stream.h" 19 | 20 | #ifdef __clang__ 21 | CEREAL_RAPIDJSON_DIAG_PUSH 22 | CEREAL_RAPIDJSON_DIAG_OFF(unreachable-code) 23 | CEREAL_RAPIDJSON_DIAG_OFF(missing-noreturn) 24 | #endif 25 | 26 | CEREAL_RAPIDJSON_NAMESPACE_BEGIN 27 | 28 | //! Represents an in-memory input byte stream. 29 | /*! 30 | This class is mainly for being wrapped by EncodedInputStream or AutoUTFInputStream. 31 | 32 | It is similar to FileReadBuffer but the source is an in-memory buffer instead of a file. 33 | 34 | Differences between MemoryStream and StringStream: 35 | 1. StringStream has encoding but MemoryStream is a byte stream. 36 | 2. MemoryStream needs size of the source buffer and the buffer don't need to be null terminated. StringStream assume null-terminated string as source. 37 | 3. MemoryStream supports Peek4() for encoding detection. StringStream is specified with an encoding so it should not have Peek4(). 38 | \note implements Stream concept 39 | */ 40 | struct MemoryStream { 41 | typedef char Ch; // byte 42 | 43 | MemoryStream(const Ch *src, size_t size) : src_(src), begin_(src), end_(src + size), size_(size) {} 44 | 45 | Ch Peek() const { return CEREAL_RAPIDJSON_UNLIKELY(src_ == end_) ? '\0' : *src_; } 46 | Ch Take() { return CEREAL_RAPIDJSON_UNLIKELY(src_ == end_) ? '\0' : *src_++; } 47 | size_t Tell() const { return static_cast(src_ - begin_); } 48 | 49 | Ch* PutBegin() { CEREAL_RAPIDJSON_ASSERT(false); return 0; } 50 | void Put(Ch) { CEREAL_RAPIDJSON_ASSERT(false); } 51 | void Flush() { CEREAL_RAPIDJSON_ASSERT(false); } 52 | size_t PutEnd(Ch*) { CEREAL_RAPIDJSON_ASSERT(false); return 0; } 53 | 54 | // For encoding detection only. 55 | const Ch* Peek4() const { 56 | return Tell() + 4 <= size_ ? src_ : 0; 57 | } 58 | 59 | const Ch* src_; //!< Current read position. 60 | const Ch* begin_; //!< Original head of the string. 61 | const Ch* end_; //!< End of stream. 62 | size_t size_; //!< Size of the stream. 63 | }; 64 | 65 | CEREAL_RAPIDJSON_NAMESPACE_END 66 | 67 | #ifdef __clang__ 68 | CEREAL_RAPIDJSON_DIAG_POP 69 | #endif 70 | 71 | #endif // CEREAL_RAPIDJSON_MEMORYBUFFER_H_ 72 | -------------------------------------------------------------------------------- /mainwindow.cpp: -------------------------------------------------------------------------------- 1 | #include "mainwindow.h" 2 | #include "ui_mainwindow.h" 3 | #include 4 | #include 5 | #include 6 | 7 | #include "systemwindow.h" 8 | #include 9 | 10 | MainWindow::MainWindow(QWidget *parent) : 11 | QMainWindow(parent), 12 | ui(new Ui::MainWindow) 13 | { 14 | ui->setupUi(this); 15 | this->setWindowTitle("操作系统课程设计"); 16 | //1.设置UI界面 17 | // 设置菜单 18 | QMenuBar * bar = new QMenuBar(); 19 | bar->setParent(this); 20 | setMenuBar(bar); 21 | // 第一个菜单, 22 | QMenu * menu1 = new QMenu(); 23 | menu1->addAction("关于",[=](){ 24 | QMessageBox * message = new QMessageBox(); 25 | message->setText("Thread Simulator V1.0\n东北大学秦皇岛分校计科1702班小组作品:\n成员:金韬、杭功茂、王鹏、张伯羽"); 26 | message->addButton("确定",QMessageBox::AcceptRole); 27 | message->addButton("取消",QMessageBox::DestructiveRole); 28 | message->show(); 29 | }); 30 | menu1->addAction("退出",[=](){ 31 | // 退出功能 32 | this->close(); 33 | }); 34 | menu1->setTitle("关于"); 35 | bar->addMenu(menu1); 36 | // 设置要求表格 37 | model = new QStandardItemModel(); 38 | // 4个要求 39 | model->setColumnCount(4); 40 | model->setRowCount(1); 41 | model->setHeaderData(0,Qt::Horizontal,"置换策略"); 42 | model->setHeaderData(1,Qt::Horizontal,"目录结构"); 43 | model->setHeaderData(2,Qt::Horizontal,"外存组织"); 44 | model->setHeaderData(3,Qt::Horizontal,"空闲磁盘管理"); 45 | // 要求细则 46 | QStandardItem * item0 = new QStandardItem("全局置换LRU"); 47 | QStandardItem * item1 = new QStandardItem("单级目录"); 48 | QStandardItem * item2 = new QStandardItem("混合索引"); 49 | QStandardItem * item3 = new QStandardItem("位示图"); 50 | item0->setTextAlignment(Qt::AlignCenter); 51 | item1->setTextAlignment(Qt::AlignCenter); 52 | item2->setTextAlignment(Qt::AlignCenter); 53 | item3->setTextAlignment(Qt::AlignCenter); 54 | model->setItem(0,0,item0); 55 | model->setItem(0,1,item1); 56 | model->setItem(0,2,item2); 57 | model->setItem(0,3,item3); 58 | 59 | // 设置属性 60 | ui->tv_class->setModel(model); 61 | ui->tv_class->setRowHeight(0,50); 62 | ui->tv_class->horizontalHeader()->setDefaultAlignment(Qt::AlignCenter); 63 | ui->tv_class->setEditTriggers(QTableView::NoEditTriggers); 64 | ui->tv_class->setSelectionMode(QAbstractItemView::SingleSelection); 65 | ui->tv_class->horizontalHeader()->setSectionResizeMode(QHeaderView::Stretch); 66 | ui->tv_class->verticalHeader()->hide(); 67 | 68 | //初始化全局变量 69 | cglobal = new CGlobal(); 70 | } 71 | 72 | 73 | MainWindow::~MainWindow() 74 | { 75 | delete ui; 76 | } 77 | 78 | 79 | void MainWindow::on_pushButton_clicked() 80 | { 81 | // 将用户名填入全局变量 82 | if (ui->edit_username->text().trimmed().size() == 0){ 83 | // 不做任何操作 84 | } else { 85 | User::userName = ui->edit_username->text().toStdString(); 86 | } 87 | this->hide(); 88 | sysWin.show(); 89 | } 90 | 91 | void MainWindow::showDialog(QDialog *dialog) 92 | { 93 | if (dialog != nullptr){ 94 | dialog->exec(); 95 | } 96 | } 97 | -------------------------------------------------------------------------------- /cereal/types/forward_list.hpp: -------------------------------------------------------------------------------- 1 | /*! \file forward_list.hpp 2 | \brief Support for types found in \ 3 | \ingroup STLSupport */ 4 | /* 5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of cereal nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef CEREAL_TYPES_FORWARD_LIST_HPP_ 31 | #define CEREAL_TYPES_FORWARD_LIST_HPP_ 32 | 33 | #include "cereal/cereal.hpp" 34 | #include 35 | 36 | namespace cereal 37 | { 38 | //! Saving for std::forward_list all other types 39 | template inline 40 | void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::forward_list const & forward_list ) 41 | { 42 | // write the size - note that this is slow because we need to traverse 43 | // the entire list. there are ways we could avoid this but this was chosen 44 | // since it works in the most general fashion with any archive type 45 | size_type const size = std::distance( forward_list.begin(), forward_list.end() ); 46 | 47 | ar( make_size_tag( size ) ); 48 | 49 | // write the list 50 | for( const auto & i : forward_list ) 51 | ar( i ); 52 | } 53 | 54 | //! Loading for std::forward_list all other types from 55 | template 56 | void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::forward_list & forward_list ) 57 | { 58 | size_type size; 59 | ar( make_size_tag( size ) ); 60 | 61 | forward_list.resize( static_cast( size ) ); 62 | 63 | for( auto & i : forward_list ) 64 | ar( i ); 65 | } 66 | } // namespace cereal 67 | 68 | #endif // CEREAL_TYPES_FORWARD_LIST_HPP_ 69 | -------------------------------------------------------------------------------- /cereal/details/polymorphic_impl_fwd.hpp: -------------------------------------------------------------------------------- 1 | /*! \file polymorphic_impl_fwd.hpp 2 | \brief Internal polymorphism support forward declarations 3 | \ingroup Internal */ 4 | /* 5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of cereal nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | 31 | /* This code is heavily inspired by the boost serialization implementation by the following authors 32 | 33 | (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . 34 | Use, modification and distribution is subject to the Boost Software 35 | License, Version 1.0. (See http://www.boost.org/LICENSE_1_0.txt) 36 | 37 | See http://www.boost.org for updates, documentation, and revision history. 38 | 39 | (C) Copyright 2006 David Abrahams - http://www.boost.org. 40 | 41 | See /boost/serialization/export.hpp and /boost/archive/detail/register_archive.hpp for their 42 | implementation. 43 | */ 44 | 45 | #ifndef CEREAL_DETAILS_POLYMORPHIC_IMPL_FWD_HPP_ 46 | #define CEREAL_DETAILS_POLYMORPHIC_IMPL_FWD_HPP_ 47 | 48 | namespace cereal 49 | { 50 | namespace detail 51 | { 52 | //! Forward declaration, see polymorphic_impl.hpp for more information 53 | template 54 | struct RegisterPolymorphicCaster; 55 | 56 | //! Forward declaration, see polymorphic_impl.hpp for more information 57 | struct PolymorphicCasters; 58 | 59 | //! Forward declaration, see polymorphic_impl.hpp for more information 60 | template 61 | struct PolymorphicRelation; 62 | } // namespace detail 63 | } // namespace cereal 64 | 65 | #endif // CEREAL_DETAILS_POLYMORPHIC_IMPL_FWD_HPP_ 66 | -------------------------------------------------------------------------------- /cereal/types/string.hpp: -------------------------------------------------------------------------------- 1 | /*! \file string.hpp 2 | \brief Support for types found in \ 3 | \ingroup STLSupport */ 4 | /* 5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of cereal nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef CEREAL_TYPES_STRING_HPP_ 31 | #define CEREAL_TYPES_STRING_HPP_ 32 | 33 | #include "cereal/cereal.hpp" 34 | #include 35 | 36 | namespace cereal 37 | { 38 | //! Serialization for basic_string types, if binary data is supported 39 | template inline 40 | typename std::enable_if, Archive>::value, void>::type 41 | CEREAL_SAVE_FUNCTION_NAME(Archive & ar, std::basic_string const & str) 42 | { 43 | // Save number of chars + the data 44 | ar( make_size_tag( static_cast(str.size()) ) ); 45 | ar( binary_data( str.data(), str.size() * sizeof(CharT) ) ); 46 | } 47 | 48 | //! Serialization for basic_string types, if binary data is supported 49 | template inline 50 | typename std::enable_if, Archive>::value, void>::type 51 | CEREAL_LOAD_FUNCTION_NAME(Archive & ar, std::basic_string & str) 52 | { 53 | size_type size; 54 | ar( make_size_tag( size ) ); 55 | str.resize(static_cast(size)); 56 | ar( binary_data( const_cast( str.data() ), static_cast(size) * sizeof(CharT) ) ); 57 | } 58 | } // namespace cereal 59 | 60 | #endif // CEREAL_TYPES_STRING_HPP_ 61 | 62 | -------------------------------------------------------------------------------- /cereal/types/chrono.hpp: -------------------------------------------------------------------------------- 1 | /*! \file chrono.hpp 2 | \brief Support for types found in \ 3 | \ingroup STLSupport */ 4 | /* 5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of cereal nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef CEREAL_TYPES_CHRONO_HPP_ 31 | #define CEREAL_TYPES_CHRONO_HPP_ 32 | 33 | #include 34 | 35 | namespace cereal 36 | { 37 | //! Saving std::chrono::duration 38 | template inline 39 | void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::chrono::duration const & dur ) 40 | { 41 | ar( CEREAL_NVP_("count", dur.count()) ); 42 | } 43 | 44 | //! Loading std::chrono::duration 45 | template inline 46 | void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::chrono::duration & dur ) 47 | { 48 | R count; 49 | ar( CEREAL_NVP_("count", count) ); 50 | 51 | dur = std::chrono::duration{count}; 52 | } 53 | 54 | //! Saving std::chrono::time_point 55 | template inline 56 | void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::chrono::time_point const & dur ) 57 | { 58 | ar( CEREAL_NVP_("time_since_epoch", dur.time_since_epoch()) ); 59 | } 60 | 61 | //! Loading std::chrono::time_point 62 | template inline 63 | void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::chrono::time_point & dur ) 64 | { 65 | D elapsed; 66 | ar( CEREAL_NVP_("time_since_epoch", elapsed) ); 67 | 68 | dur = std::chrono::time_point{elapsed}; 69 | } 70 | } // namespace cereal 71 | 72 | #endif // CEREAL_TYPES_CHRONO_HPP_ 73 | -------------------------------------------------------------------------------- /cereal/types/stack.hpp: -------------------------------------------------------------------------------- 1 | /*! \file stack.hpp 2 | \brief Support for types found in \ 3 | \ingroup STLSupport */ 4 | /* 5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of cereal nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef CEREAL_TYPES_STACK_HPP_ 31 | #define CEREAL_TYPES_STACK_HPP_ 32 | 33 | #include "cereal/cereal.hpp" 34 | #include 35 | 36 | // The default container for stack is deque, so let's include that too 37 | #include "cereal/types/deque.hpp" 38 | 39 | namespace cereal 40 | { 41 | namespace stack_detail 42 | { 43 | //! Allows access to the protected container in stack 44 | template inline 45 | C const & container( std::stack const & stack ) 46 | { 47 | struct H : public std::stack 48 | { 49 | static C const & get( std::stack const & s ) 50 | { 51 | return s.*(&H::c); 52 | } 53 | }; 54 | 55 | return H::get( stack ); 56 | } 57 | } 58 | 59 | //! Saving for std::stack 60 | template inline 61 | void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::stack const & stack ) 62 | { 63 | ar( CEREAL_NVP_("container", stack_detail::container( stack )) ); 64 | } 65 | 66 | //! Loading for std::stack 67 | template inline 68 | void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::stack & stack ) 69 | { 70 | C container; 71 | ar( CEREAL_NVP_("container", container) ); 72 | stack = std::stack( std::move( container ) ); 73 | } 74 | } // namespace cereal 75 | 76 | #endif // CEREAL_TYPES_STACK_HPP_ 77 | -------------------------------------------------------------------------------- /cereal/details/util.hpp: -------------------------------------------------------------------------------- 1 | /*! \file util.hpp 2 | \brief Internal misc utilities 3 | \ingroup Internal */ 4 | /* 5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of cereal nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef CEREAL_DETAILS_UTIL_HPP_ 31 | #define CEREAL_DETAILS_UTIL_HPP_ 32 | 33 | #include 34 | #include 35 | 36 | #ifdef _MSC_VER 37 | namespace cereal 38 | { 39 | namespace util 40 | { 41 | //! Demangles the type encoded in a string 42 | /*! @internal */ 43 | inline std::string demangle( std::string const & name ) 44 | { return name; } 45 | 46 | //! Gets the demangled name of a type 47 | /*! @internal */ 48 | template inline 49 | std::string demangledName() 50 | { return typeid( T ).name(); } 51 | } // namespace util 52 | } // namespace cereal 53 | #else // clang or gcc 54 | #include 55 | #include 56 | namespace cereal 57 | { 58 | namespace util 59 | { 60 | //! Demangles the type encoded in a string 61 | /*! @internal */ 62 | inline std::string demangle(std::string mangledName) 63 | { 64 | int status = 0; 65 | char *demangledName = nullptr; 66 | std::size_t len; 67 | 68 | demangledName = abi::__cxa_demangle(mangledName.c_str(), 0, &len, &status); 69 | 70 | std::string retName(demangledName); 71 | free(demangledName); 72 | 73 | return retName; 74 | } 75 | 76 | //! Gets the demangled name of a type 77 | /*! @internal */ 78 | template inline 79 | std::string demangledName() 80 | { return demangle(typeid(T).name()); } 81 | } 82 | } // namespace cereal 83 | #endif // clang or gcc branch of _MSC_VER 84 | #endif // CEREAL_DETAILS_UTIL_HPP_ 85 | -------------------------------------------------------------------------------- /dialog_delete_data.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | dialog_delete_data 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 327 11 | 12 | 13 | 14 | Dialog 15 | 16 | 17 | 18 | 19 | 20 20 | 20 21 | 361 22 | 16 23 | 24 | 25 | 26 | 请选择你要删除的目录文件或文件夹 27 | 28 | 29 | Qt::AlignCenter 30 | 31 | 32 | 33 | 34 | 35 | 30 36 | 51 37 | 341 38 | 181 39 | 40 | 41 | 42 | 43 | 44 | 45 | 130 46 | 290 47 | 112 48 | 32 49 | 50 | 51 | 52 | 删除 53 | 54 | 55 | 56 | 57 | 58 | 20 59 | 260 60 | 91 61 | 21 62 | 63 | 64 | 65 | 文件大小(块) 66 | 67 | 68 | Qt::AlignCenter 69 | 70 | 71 | 72 | 73 | 74 | 210 75 | 260 76 | 58 77 | 21 78 | 79 | 80 | 81 | 所有者 82 | 83 | 84 | Qt::AlignCenter 85 | 86 | 87 | 88 | 89 | 90 | 110 91 | 260 92 | 101 93 | 20 94 | 95 | 96 | 97 | 单击文件后显示 98 | 99 | 100 | Qt::AlignCenter 101 | 102 | 103 | 104 | 105 | 106 | 270 107 | 260 108 | 111 109 | 20 110 | 111 | 112 | 113 | 单击文件后显示 114 | 115 | 116 | Qt::AlignCenter 117 | 118 | 119 | 120 | 121 | 122 | 123 | -------------------------------------------------------------------------------- /dialog_gen_data.cpp: -------------------------------------------------------------------------------- 1 | #include "dialog_gen_data.h" 2 | #include "ui_dialog_gen_data.h" 3 | 4 | dialog_gen_data::dialog_gen_data(QWidget *parent) : 5 | QDialog(parent), 6 | ui(new Ui::dialog_gen_data) 7 | { 8 | ui->setupUi(this); 9 | // 初始化 10 | changeInputCount(""); 11 | // 绑定 12 | connect(ui->edit_fileContent,SIGNAL(textChanged(const QString &)),this,SLOT(changeInputCount(const QString &))); 13 | this->setWindowTitle("生成数据"); 14 | // 关闭即销毁 15 | this->setAttribute(Qt::WA_DeleteOnClose,true); 16 | this->edit_fileName = ui->edit_fileName; 17 | this->edit_fileContent = ui->edit_fileContent; 18 | } 19 | 20 | dialog_gen_data::~dialog_gen_data() 21 | { 22 | delete ui; 23 | } 24 | 25 | void dialog_gen_data::closeEvent(QCloseEvent *event) 26 | { 27 | CGlobal::genThreadSem->release(); 28 | } 29 | 30 | void dialog_gen_data::on_btn_submit_clicked() 31 | { 32 | CGlobal::genThreadSem->release(); 33 | // 获取界面数据 34 | QString fileName = edit_fileName->text(); 35 | QString fileContent = edit_fileContent->text(); 36 | 37 | if (fileName.trimmed().size() == 0 || fileContent ==0){ 38 | QDialog * dialog = new QDialog(this); 39 | QVBoxLayout *layout = new QVBoxLayout(); 40 | QPushButton *btn_ok = new QPushButton("确定"); 41 | btn_ok->setParent(dialog); 42 | connect(btn_ok,SIGNAL(clicked()),this,SLOT(on_message_btn_ok())); 43 | layout->addWidget(new QLabel("数据存盘失败,可能的原因:")); 44 | layout->addWidget(new QLabel("1.文件名为空")); 45 | layout->addWidget(new QLabel("2.文件内容为空")); 46 | layout->addWidget(btn_ok); 47 | dialog->setLayout(layout); 48 | dialog->exec(); 49 | return; 50 | } 51 | 52 | int status = CGlobal::fManager->generateData(fileContent.toStdString(),fileName.toStdString()); 53 | if(status == STATUS_ERR){ 54 | // 失败了,弹出失败框 55 | QDialog * dialog = new QDialog(this); 56 | QVBoxLayout *layout = new QVBoxLayout(); 57 | QPushButton *btn_ok = new QPushButton("确定"); 58 | btn_ok->setParent(dialog); 59 | connect(btn_ok,SIGNAL(clicked()),this,SLOT(on_message_btn_ok())); 60 | layout->addWidget(new QLabel("数据存盘失败,可能的原因有:")); 61 | layout->addWidget(new QLabel("1.磁盘空间不足,请删除一些文件后重试")); 62 | layout->addWidget(new QLabel("2.存在同名文件,请检查后重试")); 63 | layout->addWidget(btn_ok); 64 | dialog->setLayout(layout); 65 | dialog->exec(); 66 | return; 67 | } else { 68 | // 发出信号给主线程 69 | QDialog * dialog = new QDialog(this); 70 | QVBoxLayout *layout = new QVBoxLayout(); 71 | QPushButton *btn_ok = new QPushButton("确定"); 72 | btn_ok->setParent(dialog); 73 | connect(btn_ok,SIGNAL(clicked()),this,SLOT(on_message_btn_ok())); 74 | layout->addWidget(new QLabel("文件写入成功")); 75 | layout->addWidget(btn_ok); 76 | dialog->setLayout(layout); 77 | dialog->exec(); 78 | emit dataUpdated(); 79 | this->close(); 80 | } 81 | } 82 | 83 | void dialog_gen_data::on_message_btn_ok() 84 | { 85 | ((QDialog*)((QPushButton*)sender())->parent())->close(); 86 | } 87 | 88 | void dialog_gen_data::changeInputCount(const QString &text) 89 | { 90 | ui->txt_inputNum->setText(QString::number(text.size())+"/96"); 91 | } 92 | -------------------------------------------------------------------------------- /cereal/external/rapidjson/internal/ieee754.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef CEREAL_RAPIDJSON_IEEE754_ 16 | #define CEREAL_RAPIDJSON_IEEE754_ 17 | 18 | #include "../rapidjson.h" 19 | 20 | CEREAL_RAPIDJSON_NAMESPACE_BEGIN 21 | namespace internal { 22 | 23 | class Double { 24 | public: 25 | Double() {} 26 | Double(double d) : d_(d) {} 27 | Double(uint64_t u) : u_(u) {} 28 | 29 | double Value() const { return d_; } 30 | uint64_t Uint64Value() const { return u_; } 31 | 32 | double NextPositiveDouble() const { 33 | CEREAL_RAPIDJSON_ASSERT(!Sign()); 34 | return Double(u_ + 1).Value(); 35 | } 36 | 37 | bool Sign() const { return (u_ & kSignMask) != 0; } 38 | uint64_t Significand() const { return u_ & kSignificandMask; } 39 | int Exponent() const { return static_cast(((u_ & kExponentMask) >> kSignificandSize) - kExponentBias); } 40 | 41 | bool IsNan() const { return (u_ & kExponentMask) == kExponentMask && Significand() != 0; } 42 | bool IsInf() const { return (u_ & kExponentMask) == kExponentMask && Significand() == 0; } 43 | bool IsNanOrInf() const { return (u_ & kExponentMask) == kExponentMask; } 44 | bool IsNormal() const { return (u_ & kExponentMask) != 0 || Significand() == 0; } 45 | bool IsZero() const { return (u_ & (kExponentMask | kSignificandMask)) == 0; } 46 | 47 | uint64_t IntegerSignificand() const { return IsNormal() ? Significand() | kHiddenBit : Significand(); } 48 | int IntegerExponent() const { return (IsNormal() ? Exponent() : kDenormalExponent) - kSignificandSize; } 49 | uint64_t ToBias() const { return (u_ & kSignMask) ? ~u_ + 1 : u_ | kSignMask; } 50 | 51 | static int EffectiveSignificandSize(int order) { 52 | if (order >= -1021) 53 | return 53; 54 | else if (order <= -1074) 55 | return 0; 56 | else 57 | return order + 1074; 58 | } 59 | 60 | private: 61 | static const int kSignificandSize = 52; 62 | static const int kExponentBias = 0x3FF; 63 | static const int kDenormalExponent = 1 - kExponentBias; 64 | static const uint64_t kSignMask = CEREAL_RAPIDJSON_UINT64_C2(0x80000000, 0x00000000); 65 | static const uint64_t kExponentMask = CEREAL_RAPIDJSON_UINT64_C2(0x7FF00000, 0x00000000); 66 | static const uint64_t kSignificandMask = CEREAL_RAPIDJSON_UINT64_C2(0x000FFFFF, 0xFFFFFFFF); 67 | static const uint64_t kHiddenBit = CEREAL_RAPIDJSON_UINT64_C2(0x00100000, 0x00000000); 68 | 69 | union { 70 | double d_; 71 | uint64_t u_; 72 | }; 73 | }; 74 | 75 | } // namespace internal 76 | CEREAL_RAPIDJSON_NAMESPACE_END 77 | 78 | #endif // CEREAL_RAPIDJSON_IEEE754_ 79 | -------------------------------------------------------------------------------- /cereal/types/concepts/pair_associative_container.hpp: -------------------------------------------------------------------------------- 1 | /*! \file pair_associative_container.hpp 2 | \brief Support for the PairAssociativeContainer refinement of the 3 | AssociativeContainer concept. 4 | \ingroup TypeConcepts */ 5 | /* 6 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 7 | All rights reserved. 8 | 9 | Redistribution and use in source and binary forms, with or without 10 | modification, are permitted provided that the following conditions are met: 11 | * Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | * Neither the name of cereal nor the 17 | names of its contributors may be used to endorse or promote products 18 | derived from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY 24 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | #ifndef CEREAL_CONCEPTS_PAIR_ASSOCIATIVE_CONTAINER_HPP_ 32 | #define CEREAL_CONCEPTS_PAIR_ASSOCIATIVE_CONTAINER_HPP_ 33 | 34 | #include "cereal/cereal.hpp" 35 | 36 | namespace cereal 37 | { 38 | //! Saving for std-like pair associative containers 39 | template class Map, typename... Args, typename = typename Map::mapped_type> inline 40 | void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, Map const & map ) 41 | { 42 | ar( make_size_tag( static_cast(map.size()) ) ); 43 | 44 | for( const auto & i : map ) 45 | ar( make_map_item(i.first, i.second) ); 46 | } 47 | 48 | //! Loading for std-like pair associative containers 49 | template class Map, typename... Args, typename = typename Map::mapped_type> inline 50 | void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, Map & map ) 51 | { 52 | size_type size; 53 | ar( make_size_tag( size ) ); 54 | 55 | map.clear(); 56 | 57 | auto hint = map.begin(); 58 | for( size_t i = 0; i < size; ++i ) 59 | { 60 | typename Map::key_type key; 61 | typename Map::mapped_type value; 62 | 63 | ar( make_map_item(key, value) ); 64 | #ifdef CEREAL_OLDER_GCC 65 | hint = map.insert( hint, std::make_pair(std::move(key), std::move(value)) ); 66 | #else // NOT CEREAL_OLDER_GCC 67 | hint = map.emplace_hint( hint, std::move( key ), std::move( value ) ); 68 | #endif // NOT CEREAL_OLDER_GCC 69 | } 70 | } 71 | } // namespace cereal 72 | 73 | #endif // CEREAL_CONCEPTS_PAIR_ASSOCIATIVE_CONTAINER_HPP_ 74 | -------------------------------------------------------------------------------- /folder_manager.cpp: -------------------------------------------------------------------------------- 1 | #include "folder_manager.h" 2 | #include "data_define.h" 3 | #include 4 | #include 5 | 6 | FolderManager::FolderManager(DiskManager * dManager) 7 | { 8 | this->dManager = dManager; 9 | 10 | std::ifstream os("folder.json"); 11 | if (os.is_open()){ 12 | cereal::JSONInputArchive archieve(os); 13 | this->serialize(archieve); 14 | for(int i=0;i<128;i++){ 15 | fileLocks[i] = false; 16 | } 17 | } else { 18 | for(int i=0;i<128;i++){ 19 | fileTable[i].fileName = ""; 20 | fileTable[i].fileSize = 0; 21 | fileTable[i].owner = ""; 22 | fileTable[i].type = 0; 23 | fileLocks[i] = false; 24 | } 25 | } 26 | 27 | } 28 | 29 | // 按照指针指向的FolderElement删除目录项 30 | int FolderManager::deleteData(FCB* element){ 31 | // 删除磁盘中FCB 32 | for(int i=0;i<128;i++){ 33 | if(element->fileName == fileTable[i].fileName){ 34 | if (fileLocks[i]){ 35 | //上锁了 36 | return STATUS_BUSY; 37 | } else { 38 | // 删除磁盘中的文件 39 | int status = this->dManager->receiveF_delete(element); 40 | // 删除目录项中的文件 41 | fileTable[i].fileName = ""; 42 | fileTable[i].fileSize = 0; 43 | return status; 44 | } 45 | } 46 | } 47 | } 48 | 49 | // 输出信息:获取所有文件 50 | queue FolderManager::getFiles(){ 51 | queue q; 52 | for(int i=0;i<128;i++){ 53 | if(fileTable[i].fileName != ""){ 54 | q.push(&fileTable[i]); 55 | } 56 | else continue; 57 | } 58 | return q; 59 | } 60 | 61 | // 创建新文件,注意:添加时记得往element里面填写tm时间数据 62 | int FolderManager::generateData(string data,string fileName){ 63 | for(int k=0;k<128;k++){ 64 | if(fileTable[k].fileName == fileName){ 65 | return STATUS_SAME_FILE; 66 | } 67 | } 68 | // 获取时间 69 | for(int i=0;i<128;i++){ 70 | if(fileTable[i].fileName == ""){ 71 | fileTable[i].fileName = fileName; 72 | int a; 73 | a = data.size(); 74 | int b; 75 | if(a%4 == 0){ 76 | b = a/4; 77 | } 78 | else b = (a/4)+1; 79 | fileTable[i].fileSize = b; 80 | time_t t = time(nullptr); 81 | fileTable[i].createTime = *localtime(&t); 82 | fileTable[i].owner = User::userName; 83 | return this->dManager->receiveF_add(&fileTable[i],data); 84 | } 85 | } 86 | // 最多存放128个块 87 | return STATUS_ERR; 88 | } 89 | 90 | // 读取数据 91 | string FolderManager::getData(FCB * element){ 92 | string data_read = this->dManager->receiveF_read(element); 93 | return data_read; 94 | } 95 | int FolderManager::lockFile(FCB * fcb){ 96 | for(int i=0;i<128;i++){ 97 | if(fcb->fileName == fileTable[i].fileName){ 98 | fileLocks[i] = true; 99 | } 100 | } 101 | return STATUS_OK; 102 | } 103 | int FolderManager::unlockFile(FCB * fcb){ 104 | for(int i=0;i<128;i++){ 105 | if(fcb->fileName == fileTable[i].fileName){ 106 | fileLocks[i] = false; 107 | } 108 | } 109 | return STATUS_OK; 110 | } 111 | -------------------------------------------------------------------------------- /cereal/external/rapidjson/filereadstream.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef CEREAL_RAPIDJSON_FILEREADSTREAM_H_ 16 | #define CEREAL_RAPIDJSON_FILEREADSTREAM_H_ 17 | 18 | #include "stream.h" 19 | #include 20 | 21 | #ifdef __clang__ 22 | CEREAL_RAPIDJSON_DIAG_PUSH 23 | CEREAL_RAPIDJSON_DIAG_OFF(padded) 24 | CEREAL_RAPIDJSON_DIAG_OFF(unreachable-code) 25 | CEREAL_RAPIDJSON_DIAG_OFF(missing-noreturn) 26 | #endif 27 | 28 | CEREAL_RAPIDJSON_NAMESPACE_BEGIN 29 | 30 | //! File byte stream for input using fread(). 31 | /*! 32 | \note implements Stream concept 33 | */ 34 | class FileReadStream { 35 | public: 36 | typedef char Ch; //!< Character type (byte). 37 | 38 | //! Constructor. 39 | /*! 40 | \param fp File pointer opened for read. 41 | \param buffer user-supplied buffer. 42 | \param bufferSize size of buffer in bytes. Must >=4 bytes. 43 | */ 44 | FileReadStream(std::FILE* fp, char* buffer, size_t bufferSize) : fp_(fp), buffer_(buffer), bufferSize_(bufferSize), bufferLast_(0), current_(buffer_), readCount_(0), count_(0), eof_(false) { 45 | CEREAL_RAPIDJSON_ASSERT(fp_ != 0); 46 | CEREAL_RAPIDJSON_ASSERT(bufferSize >= 4); 47 | Read(); 48 | } 49 | 50 | Ch Peek() const { return *current_; } 51 | Ch Take() { Ch c = *current_; Read(); return c; } 52 | size_t Tell() const { return count_ + static_cast(current_ - buffer_); } 53 | 54 | // Not implemented 55 | void Put(Ch) { CEREAL_RAPIDJSON_ASSERT(false); } 56 | void Flush() { CEREAL_RAPIDJSON_ASSERT(false); } 57 | Ch* PutBegin() { CEREAL_RAPIDJSON_ASSERT(false); return 0; } 58 | size_t PutEnd(Ch*) { CEREAL_RAPIDJSON_ASSERT(false); return 0; } 59 | 60 | // For encoding detection only. 61 | const Ch* Peek4() const { 62 | return (current_ + 4 - !eof_ <= bufferLast_) ? current_ : 0; 63 | } 64 | 65 | private: 66 | void Read() { 67 | if (current_ < bufferLast_) 68 | ++current_; 69 | else if (!eof_) { 70 | count_ += readCount_; 71 | readCount_ = std::fread(buffer_, 1, bufferSize_, fp_); 72 | bufferLast_ = buffer_ + readCount_ - 1; 73 | current_ = buffer_; 74 | 75 | if (readCount_ < bufferSize_) { 76 | buffer_[readCount_] = '\0'; 77 | ++bufferLast_; 78 | eof_ = true; 79 | } 80 | } 81 | } 82 | 83 | std::FILE* fp_; 84 | Ch *buffer_; 85 | size_t bufferSize_; 86 | Ch *bufferLast_; 87 | Ch *current_; 88 | size_t readCount_; 89 | size_t count_; //!< Number of characters read 90 | bool eof_; 91 | }; 92 | 93 | CEREAL_RAPIDJSON_NAMESPACE_END 94 | 95 | #ifdef __clang__ 96 | CEREAL_RAPIDJSON_DIAG_POP 97 | #endif 98 | 99 | #endif // CEREAL_RAPIDJSON_FILESTREAM_H_ 100 | -------------------------------------------------------------------------------- /cereal/external/rapidjson/filewritestream.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef CEREAL_RAPIDJSON_FILEWRITESTREAM_H_ 16 | #define CEREAL_RAPIDJSON_FILEWRITESTREAM_H_ 17 | 18 | #include "stream.h" 19 | #include 20 | 21 | #ifdef __clang__ 22 | CEREAL_RAPIDJSON_DIAG_PUSH 23 | CEREAL_RAPIDJSON_DIAG_OFF(unreachable-code) 24 | #endif 25 | 26 | CEREAL_RAPIDJSON_NAMESPACE_BEGIN 27 | 28 | //! Wrapper of C file stream for output using fwrite(). 29 | /*! 30 | \note implements Stream concept 31 | */ 32 | class FileWriteStream { 33 | public: 34 | typedef char Ch; //!< Character type. Only support char. 35 | 36 | FileWriteStream(std::FILE* fp, char* buffer, size_t bufferSize) : fp_(fp), buffer_(buffer), bufferEnd_(buffer + bufferSize), current_(buffer_) { 37 | CEREAL_RAPIDJSON_ASSERT(fp_ != 0); 38 | } 39 | 40 | void Put(char c) { 41 | if (current_ >= bufferEnd_) 42 | Flush(); 43 | 44 | *current_++ = c; 45 | } 46 | 47 | void PutN(char c, size_t n) { 48 | size_t avail = static_cast(bufferEnd_ - current_); 49 | while (n > avail) { 50 | std::memset(current_, c, avail); 51 | current_ += avail; 52 | Flush(); 53 | n -= avail; 54 | avail = static_cast(bufferEnd_ - current_); 55 | } 56 | 57 | if (n > 0) { 58 | std::memset(current_, c, n); 59 | current_ += n; 60 | } 61 | } 62 | 63 | void Flush() { 64 | if (current_ != buffer_) { 65 | size_t result = std::fwrite(buffer_, 1, static_cast(current_ - buffer_), fp_); 66 | if (result < static_cast(current_ - buffer_)) { 67 | // failure deliberately ignored at this time 68 | // added to avoid warn_unused_result build errors 69 | } 70 | current_ = buffer_; 71 | } 72 | } 73 | 74 | // Not implemented 75 | char Peek() const { CEREAL_RAPIDJSON_ASSERT(false); return 0; } 76 | char Take() { CEREAL_RAPIDJSON_ASSERT(false); return 0; } 77 | size_t Tell() const { CEREAL_RAPIDJSON_ASSERT(false); return 0; } 78 | char* PutBegin() { CEREAL_RAPIDJSON_ASSERT(false); return 0; } 79 | size_t PutEnd(char*) { CEREAL_RAPIDJSON_ASSERT(false); return 0; } 80 | 81 | private: 82 | // Prohibit copy constructor & assignment operator. 83 | FileWriteStream(const FileWriteStream&); 84 | FileWriteStream& operator=(const FileWriteStream&); 85 | 86 | std::FILE* fp_; 87 | char *buffer_; 88 | char *bufferEnd_; 89 | char *current_; 90 | }; 91 | 92 | //! Implement specialized version of PutN() with memset() for better performance. 93 | template<> 94 | inline void PutN(FileWriteStream& stream, char c, size_t n) { 95 | stream.PutN(c, n); 96 | } 97 | 98 | CEREAL_RAPIDJSON_NAMESPACE_END 99 | 100 | #ifdef __clang__ 101 | CEREAL_RAPIDJSON_DIAG_POP 102 | #endif 103 | 104 | #endif // CEREAL_RAPIDJSON_FILESTREAM_H_ 105 | -------------------------------------------------------------------------------- /cereal/types/array.hpp: -------------------------------------------------------------------------------- 1 | /*! \file array.hpp 2 | \brief Support for types found in \ 3 | \ingroup STLSupport */ 4 | /* 5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of cereal nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef CEREAL_TYPES_ARRAY_HPP_ 31 | #define CEREAL_TYPES_ARRAY_HPP_ 32 | 33 | #include "cereal/cereal.hpp" 34 | #include 35 | 36 | namespace cereal 37 | { 38 | //! Saving for std::array primitive types 39 | //! using binary serialization, if supported 40 | template inline 41 | typename std::enable_if, Archive>::value 42 | && std::is_arithmetic::value, void>::type 43 | CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::array const & array ) 44 | { 45 | ar( binary_data( array.data(), sizeof(array) ) ); 46 | } 47 | 48 | //! Loading for std::array primitive types 49 | //! using binary serialization, if supported 50 | template inline 51 | typename std::enable_if, Archive>::value 52 | && std::is_arithmetic::value, void>::type 53 | CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::array & array ) 54 | { 55 | ar( binary_data( array.data(), sizeof(array) ) ); 56 | } 57 | 58 | //! Saving for std::array all other types 59 | template inline 60 | typename std::enable_if, Archive>::value 61 | || !std::is_arithmetic::value, void>::type 62 | CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::array const & array ) 63 | { 64 | for( auto const & i : array ) 65 | ar( i ); 66 | } 67 | 68 | //! Loading for std::array all other types 69 | template inline 70 | typename std::enable_if, Archive>::value 71 | || !std::is_arithmetic::value, void>::type 72 | CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::array & array ) 73 | { 74 | for( auto & i : array ) 75 | ar( i ); 76 | } 77 | } // namespace cereal 78 | 79 | #endif // CEREAL_TYPES_ARRAY_HPP_ 80 | -------------------------------------------------------------------------------- /cereal/external/rapidjson/internal/pow10.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef CEREAL_RAPIDJSON_POW10_ 16 | #define CEREAL_RAPIDJSON_POW10_ 17 | 18 | #include "../rapidjson.h" 19 | 20 | CEREAL_RAPIDJSON_NAMESPACE_BEGIN 21 | namespace internal { 22 | 23 | //! Computes integer powers of 10 in double (10.0^n). 24 | /*! This function uses lookup table for fast and accurate results. 25 | \param n non-negative exponent. Must <= 308. 26 | \return 10.0^n 27 | */ 28 | inline double Pow10(int n) { 29 | static const double e[] = { // 1e-0...1e308: 309 * 8 bytes = 2472 bytes 30 | 1e+0, 31 | 1e+1, 1e+2, 1e+3, 1e+4, 1e+5, 1e+6, 1e+7, 1e+8, 1e+9, 1e+10, 1e+11, 1e+12, 1e+13, 1e+14, 1e+15, 1e+16, 1e+17, 1e+18, 1e+19, 1e+20, 32 | 1e+21, 1e+22, 1e+23, 1e+24, 1e+25, 1e+26, 1e+27, 1e+28, 1e+29, 1e+30, 1e+31, 1e+32, 1e+33, 1e+34, 1e+35, 1e+36, 1e+37, 1e+38, 1e+39, 1e+40, 33 | 1e+41, 1e+42, 1e+43, 1e+44, 1e+45, 1e+46, 1e+47, 1e+48, 1e+49, 1e+50, 1e+51, 1e+52, 1e+53, 1e+54, 1e+55, 1e+56, 1e+57, 1e+58, 1e+59, 1e+60, 34 | 1e+61, 1e+62, 1e+63, 1e+64, 1e+65, 1e+66, 1e+67, 1e+68, 1e+69, 1e+70, 1e+71, 1e+72, 1e+73, 1e+74, 1e+75, 1e+76, 1e+77, 1e+78, 1e+79, 1e+80, 35 | 1e+81, 1e+82, 1e+83, 1e+84, 1e+85, 1e+86, 1e+87, 1e+88, 1e+89, 1e+90, 1e+91, 1e+92, 1e+93, 1e+94, 1e+95, 1e+96, 1e+97, 1e+98, 1e+99, 1e+100, 36 | 1e+101,1e+102,1e+103,1e+104,1e+105,1e+106,1e+107,1e+108,1e+109,1e+110,1e+111,1e+112,1e+113,1e+114,1e+115,1e+116,1e+117,1e+118,1e+119,1e+120, 37 | 1e+121,1e+122,1e+123,1e+124,1e+125,1e+126,1e+127,1e+128,1e+129,1e+130,1e+131,1e+132,1e+133,1e+134,1e+135,1e+136,1e+137,1e+138,1e+139,1e+140, 38 | 1e+141,1e+142,1e+143,1e+144,1e+145,1e+146,1e+147,1e+148,1e+149,1e+150,1e+151,1e+152,1e+153,1e+154,1e+155,1e+156,1e+157,1e+158,1e+159,1e+160, 39 | 1e+161,1e+162,1e+163,1e+164,1e+165,1e+166,1e+167,1e+168,1e+169,1e+170,1e+171,1e+172,1e+173,1e+174,1e+175,1e+176,1e+177,1e+178,1e+179,1e+180, 40 | 1e+181,1e+182,1e+183,1e+184,1e+185,1e+186,1e+187,1e+188,1e+189,1e+190,1e+191,1e+192,1e+193,1e+194,1e+195,1e+196,1e+197,1e+198,1e+199,1e+200, 41 | 1e+201,1e+202,1e+203,1e+204,1e+205,1e+206,1e+207,1e+208,1e+209,1e+210,1e+211,1e+212,1e+213,1e+214,1e+215,1e+216,1e+217,1e+218,1e+219,1e+220, 42 | 1e+221,1e+222,1e+223,1e+224,1e+225,1e+226,1e+227,1e+228,1e+229,1e+230,1e+231,1e+232,1e+233,1e+234,1e+235,1e+236,1e+237,1e+238,1e+239,1e+240, 43 | 1e+241,1e+242,1e+243,1e+244,1e+245,1e+246,1e+247,1e+248,1e+249,1e+250,1e+251,1e+252,1e+253,1e+254,1e+255,1e+256,1e+257,1e+258,1e+259,1e+260, 44 | 1e+261,1e+262,1e+263,1e+264,1e+265,1e+266,1e+267,1e+268,1e+269,1e+270,1e+271,1e+272,1e+273,1e+274,1e+275,1e+276,1e+277,1e+278,1e+279,1e+280, 45 | 1e+281,1e+282,1e+283,1e+284,1e+285,1e+286,1e+287,1e+288,1e+289,1e+290,1e+291,1e+292,1e+293,1e+294,1e+295,1e+296,1e+297,1e+298,1e+299,1e+300, 46 | 1e+301,1e+302,1e+303,1e+304,1e+305,1e+306,1e+307,1e+308 47 | }; 48 | CEREAL_RAPIDJSON_ASSERT(n >= 0 && n <= 308); 49 | return e[n]; 50 | } 51 | 52 | } // namespace internal 53 | CEREAL_RAPIDJSON_NAMESPACE_END 54 | 55 | #endif // CEREAL_RAPIDJSON_POW10_ 56 | -------------------------------------------------------------------------------- /cereal/external/rapidxml/rapidxml_utils.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CEREAL_RAPIDXML_UTILS_HPP_INCLUDED 2 | #define CEREAL_RAPIDXML_UTILS_HPP_INCLUDED 3 | 4 | // Copyright (C) 2006, 2009 Marcin Kalicinski 5 | // Version 1.13 6 | // Revision $DateTime: 2009/05/13 01:46:17 $ 7 | //! in certain simple scenarios. They should probably not be used if maximizing performance is the main objective. 8 | 9 | #include "rapidxml.hpp" 10 | #include 11 | #include 12 | #include 13 | #include 14 | 15 | namespace cereal { 16 | namespace rapidxml 17 | { 18 | 19 | //! Represents data loaded from a file 20 | template 21 | class file 22 | { 23 | 24 | public: 25 | 26 | //! Loads file into the memory. Data will be automatically destroyed by the destructor. 27 | //! \param filename Filename to load. 28 | file(const char *filename) 29 | { 30 | using namespace std; 31 | 32 | // Open stream 33 | basic_ifstream stream(filename, ios::binary); 34 | if (!stream) 35 | throw runtime_error(string("cannot open file ") + filename); 36 | stream.unsetf(ios::skipws); 37 | 38 | // Determine stream size 39 | stream.seekg(0, ios::end); 40 | size_t size = stream.tellg(); 41 | stream.seekg(0); 42 | 43 | // Load data and add terminating 0 44 | m_data.resize(size + 1); 45 | stream.read(&m_data.front(), static_cast(size)); 46 | m_data[size] = 0; 47 | } 48 | 49 | //! Loads file into the memory. Data will be automatically destroyed by the destructor 50 | //! \param stream Stream to load from 51 | file(std::basic_istream &stream) 52 | { 53 | using namespace std; 54 | 55 | // Load data and add terminating 0 56 | stream.unsetf(ios::skipws); 57 | m_data.assign(istreambuf_iterator(stream), istreambuf_iterator()); 58 | if (stream.fail() || stream.bad()) 59 | throw runtime_error("error reading stream"); 60 | m_data.push_back(0); 61 | } 62 | 63 | //! Gets file data. 64 | //! \return Pointer to data of file. 65 | Ch *data() 66 | { 67 | return &m_data.front(); 68 | } 69 | 70 | //! Gets file data. 71 | //! \return Pointer to data of file. 72 | const Ch *data() const 73 | { 74 | return &m_data.front(); 75 | } 76 | 77 | //! Gets file data size. 78 | //! \return Size of file data, in characters. 79 | std::size_t size() const 80 | { 81 | return m_data.size(); 82 | } 83 | 84 | private: 85 | 86 | std::vector m_data; // File data 87 | 88 | }; 89 | 90 | //! Counts children of node. Time complexity is O(n). 91 | //! \return Number of children of node 92 | template 93 | inline std::size_t count_children(xml_node *node) 94 | { 95 | xml_node *child = node->first_node(); 96 | std::size_t count = 0; 97 | while (child) 98 | { 99 | ++count; 100 | child = child->next_sibling(); 101 | } 102 | return count; 103 | } 104 | 105 | //! Counts attributes of node. Time complexity is O(n). 106 | //! \return Number of attributes of node 107 | template 108 | inline std::size_t count_attributes(xml_node *node) 109 | { 110 | xml_attribute *attr = node->first_attribute(); 111 | std::size_t count = 0; 112 | while (attr) 113 | { 114 | ++count; 115 | attr = attr->next_attribute(); 116 | } 117 | return count; 118 | } 119 | 120 | } 121 | } // namespace cereal 122 | 123 | #endif 124 | -------------------------------------------------------------------------------- /disk_monitor.cpp: -------------------------------------------------------------------------------- 1 | #include "disk_monitor.h" 2 | #include "ui_disk_monitor.h" 3 | 4 | DiskMonitor::DiskMonitor(QWidget *parent) : 5 | QMainWindow(parent), 6 | ui(new Ui::DiskMonitor) 7 | { 8 | ui->setupUi(this); 9 | this->setWindowTitle("磁盘监视器"); 10 | // 关闭即销毁 11 | this->setAttribute(Qt::WA_DeleteOnClose,true); 12 | // 定义 13 | tv_disk = ui->tv_disk; 14 | ll_pos = ui->text_block_pos; 15 | ll_data = ui->text_block_data; 16 | ll_page = ui->text_page; 17 | ll_status = ui->text_block_status; 18 | ll_totoal_free = ui->text_total_free_block; 19 | // 表格 20 | model = new QStandardItemModel(tv_disk); 21 | // 32*32 22 | model->setRowCount(32); 23 | model->setColumnCount(32); 24 | // 设置属性 25 | tv_disk->setModel(model); 26 | tv_disk->horizontalHeader()->setDefaultAlignment(Qt::AlignCenter); 27 | tv_disk->setEditTriggers(QTableView::NoEditTriggers); 28 | // tv_disk->setRowHeight(0,50); 29 | tv_disk->setSelectionMode(QAbstractItemView::SingleSelection); 30 | // tv_disk->horizontalHeader()->hide(); 31 | // tv_disk->verticalHeader()->hide(); 32 | // 初始化行号从0开始 33 | for (int i=0;irowCount();i++) { 34 | model->setHeaderData(i,Qt::Vertical,i); 35 | } 36 | for (int i=0;irowCount();i++) { 37 | model->setHeaderData(i,Qt::Horizontal,i); 38 | } 39 | // 设置点击事件 40 | connect(tv_disk, SIGNAL(clicked(const QModelIndex &)), this, SLOT(onTableClicked(const QModelIndex &))); 41 | // 获取数据 42 | notFreeModel = new QStandardItemModel(ui->tv_notFree); 43 | ui->tv_notFree->setModel(notFreeModel); 44 | ui->tv_notFree->setEditTriggers(QTableView::NoEditTriggers); 45 | 46 | updateDiskUI(); 47 | } 48 | 49 | DiskMonitor::~DiskMonitor() 50 | { 51 | delete ui; 52 | } 53 | 54 | void DiskMonitor::updateDiskUI() 55 | { 56 | qDebug() << "磁盘监视器:更新数据"; 57 | qMapTemp = CGlobal::dManager->getCurrentBitMap(); 58 | int freeBlockCnt = 0; 59 | int totalBlock = 0; 60 | // 清空空闲分区 61 | notFreeModel->clear(); 62 | while(!qMapTemp.empty()){ 63 | auto item = qMapTemp.front(); 64 | if(item.isFree){ 65 | freeBlockCnt++; 66 | } 67 | totalBlock++; 68 | if (item.x >=0 && item.y >=0 && item.x <32 && item.y <32){ 69 | QStandardItem * qItem =new QStandardItem(QString::fromStdString(item.data)); 70 | model->setItem(item.x,item.y,qItem); 71 | if (!item.isFree){ 72 | // 染色 73 | model->setData(model->index(item.x,item.y),QVariant(QBrush(Qt::red)), Qt::BackgroundRole); 74 | QStandardItem * it = new QStandardItem(); 75 | it->setText(QString::fromStdString(item.data)+"-("+QString::number(item.x)+","+QString::number(item.y)+")"); 76 | notFreeModel->appendRow(it); 77 | } 78 | this->bMItem[item.x][item.y] =item; 79 | } else { 80 | qDebug() << "警告:试图写入非法UI空间"; 81 | } 82 | qMapTemp.pop(); 83 | } 84 | ll_totoal_free->setText(QString::number(freeBlockCnt)+"/"+QString::number(totalBlock)); 85 | } 86 | 87 | void DiskMonitor::onTableClicked(const QModelIndex &mIndex) 88 | { 89 | auto item = bMItem[mIndex.row()][mIndex.column()]; 90 | // 判断是否是坐标 91 | int index = mIndex.row()*32+mIndex.column(); 92 | if(index >= 900){ 93 | ll_page->setText(QString::number(index)+"(对换区)"); 94 | } else { 95 | ll_page->setText(QString::number(index)+"(普通区)"); 96 | } 97 | 98 | QString textStr = QString("(") +QString::number(item.x) + QString(",") +QString::number(item.y)+QString(")"); 99 | ll_pos->setText(textStr); 100 | 101 | ll_data->setText(QString::fromStdString(item.data)); 102 | if(item.isFree){ 103 | ll_status ->setText("空闲"); 104 | } else { 105 | ll_status ->setText("已被占用"); 106 | } 107 | 108 | } 109 | -------------------------------------------------------------------------------- /cereal/types/set.hpp: -------------------------------------------------------------------------------- 1 | /*! \file set.hpp 2 | \brief Support for types found in \ 3 | \ingroup STLSupport */ 4 | /* 5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of cereal nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef CEREAL_TYPES_SET_HPP_ 31 | #define CEREAL_TYPES_SET_HPP_ 32 | 33 | #include "cereal/cereal.hpp" 34 | #include 35 | 36 | namespace cereal 37 | { 38 | namespace set_detail 39 | { 40 | //! @internal 41 | template inline 42 | void save( Archive & ar, SetT const & set ) 43 | { 44 | ar( make_size_tag( static_cast(set.size()) ) ); 45 | 46 | for( const auto & i : set ) 47 | ar( i ); 48 | } 49 | 50 | //! @internal 51 | template inline 52 | void load( Archive & ar, SetT & set ) 53 | { 54 | size_type size; 55 | ar( make_size_tag( size ) ); 56 | 57 | set.clear(); 58 | 59 | auto hint = set.begin(); 60 | for( size_type i = 0; i < size; ++i ) 61 | { 62 | typename SetT::key_type key; 63 | 64 | ar( key ); 65 | #ifdef CEREAL_OLDER_GCC 66 | hint = set.insert( hint, std::move( key ) ); 67 | #else // NOT CEREAL_OLDER_GCC 68 | hint = set.emplace_hint( hint, std::move( key ) ); 69 | #endif // NOT CEREAL_OLDER_GCC 70 | } 71 | } 72 | } 73 | 74 | //! Saving for std::set 75 | template inline 76 | void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::set const & set ) 77 | { 78 | set_detail::save( ar, set ); 79 | } 80 | 81 | //! Loading for std::set 82 | template inline 83 | void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::set & set ) 84 | { 85 | set_detail::load( ar, set ); 86 | } 87 | 88 | //! Saving for std::multiset 89 | template inline 90 | void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::multiset const & multiset ) 91 | { 92 | set_detail::save( ar, multiset ); 93 | } 94 | 95 | //! Loading for std::multiset 96 | template inline 97 | void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::multiset & multiset ) 98 | { 99 | set_detail::load( ar, multiset ); 100 | } 101 | } // namespace cereal 102 | 103 | #endif // CEREAL_TYPES_SET_HPP_ 104 | -------------------------------------------------------------------------------- /mainwindow.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | MainWindow 4 | 5 | 6 | 7 | 0 8 | 0 9 | 494 10 | 354 11 | 12 | 13 | 14 | MainWindow 15 | 16 | 17 | 18 | 19 | 20 | 150 21 | 270 22 | 181 23 | 31 24 | 25 | 26 | 27 | 登录 28 | 29 | 30 | true 31 | 32 | 33 | false 34 | 35 | 36 | 37 | 38 | 39 | 90 40 | 40 41 | 301 42 | 31 43 | 44 | 45 | 46 | 操作系统课程设计 47 | 48 | 49 | Qt::AlignCenter 50 | 51 | 52 | 53 | 54 | 55 | 90 56 | 110 57 | 301 58 | 31 59 | 60 | 61 | 62 | 组员:金韬、杭功茂、王鹏、张伯羽 63 | 64 | 65 | Qt::AlignCenter 66 | 67 | 68 | 69 | 70 | 71 | 90 72 | 70 73 | 301 74 | 31 75 | 76 | 77 | 78 | 东北大学秦皇岛分校计科1702班17-20号 79 | 80 | 81 | Qt::AlignCenter 82 | 83 | 84 | 85 | 86 | 87 | 210 88 | 240 89 | 113 90 | 21 91 | 92 | 93 | 94 | 未命名 95 | 96 | 97 | 98 | 99 | 100 | 150 101 | 235 102 | 58 103 | 31 104 | 105 | 106 | 107 | 用户名 108 | 109 | 110 | Qt::AlignCenter 111 | 112 | 113 | 114 | 115 | 116 | 60 117 | 150 118 | 371 119 | 71 120 | 121 | 122 | 123 | 124 | 125 | 126 | 127 | 0 128 | 0 129 | 494 130 | 22 131 | 132 | 133 | 134 | 135 | 136 | 137 | quit 138 | 139 | 140 | 141 | 142 | about 143 | 144 | 145 | 146 | 147 | 148 | 149 | 150 | -------------------------------------------------------------------------------- /cereal/types/unordered_set.hpp: -------------------------------------------------------------------------------- 1 | /*! \file unordered_set.hpp 2 | \brief Support for types found in \ 3 | \ingroup STLSupport */ 4 | /* 5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of cereal nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef CEREAL_TYPES_UNORDERED_SET_HPP_ 31 | #define CEREAL_TYPES_UNORDERED_SET_HPP_ 32 | 33 | #include "cereal/cereal.hpp" 34 | #include 35 | 36 | namespace cereal 37 | { 38 | namespace unordered_set_detail 39 | { 40 | //! @internal 41 | template inline 42 | void save( Archive & ar, SetT const & set ) 43 | { 44 | ar( make_size_tag( static_cast(set.size()) ) ); 45 | 46 | for( const auto & i : set ) 47 | ar( i ); 48 | } 49 | 50 | //! @internal 51 | template inline 52 | void load( Archive & ar, SetT & set ) 53 | { 54 | size_type size; 55 | ar( make_size_tag( size ) ); 56 | 57 | set.clear(); 58 | set.reserve( static_cast( size ) ); 59 | 60 | for( size_type i = 0; i < size; ++i ) 61 | { 62 | typename SetT::key_type key; 63 | 64 | ar( key ); 65 | set.emplace( std::move( key ) ); 66 | } 67 | } 68 | } 69 | 70 | //! Saving for std::unordered_set 71 | template inline 72 | void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::unordered_set const & unordered_set ) 73 | { 74 | unordered_set_detail::save( ar, unordered_set ); 75 | } 76 | 77 | //! Loading for std::unordered_set 78 | template inline 79 | void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::unordered_set & unordered_set ) 80 | { 81 | unordered_set_detail::load( ar, unordered_set ); 82 | } 83 | 84 | //! Saving for std::unordered_multiset 85 | template inline 86 | void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::unordered_multiset const & unordered_multiset ) 87 | { 88 | unordered_set_detail::save( ar, unordered_multiset ); 89 | } 90 | 91 | //! Loading for std::unordered_multiset 92 | template inline 93 | void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::unordered_multiset & unordered_multiset ) 94 | { 95 | unordered_set_detail::load( ar, unordered_multiset ); 96 | } 97 | } // namespace cereal 98 | 99 | #endif // CEREAL_TYPES_UNORDERED_SET_HPP_ 100 | -------------------------------------------------------------------------------- /cereal/types/valarray.hpp: -------------------------------------------------------------------------------- 1 | /*! \file valarray.hpp 2 | \brief Support for types found in \ 3 | \ingroup STLSupport */ 4 | 5 | /* 6 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 7 | All rights reserved. 8 | 9 | Redistribution and use in source and binary forms, with or without 10 | modification, are permitted provided that the following conditions are met: 11 | * Redistributions of source code must retain the above copyright 12 | notice, this list of conditions and the following disclaimer. 13 | * Redistributions in binary form must reproduce the above copyright 14 | notice, this list of conditions and the following disclaimer in the 15 | documentation and/or other materials provided with the distribution. 16 | * Neither the name of cereal nor the 17 | names of its contributors may be used to endorse or promote products 18 | derived from this software without specific prior written permission. 19 | 20 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 21 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 22 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 23 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY 24 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 25 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 26 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 27 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 28 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 29 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 30 | */ 31 | 32 | #ifndef CEREAL_TYPES_VALARRAY_HPP_ 33 | #define CEREAL_TYPES_VALARRAY_HPP_ 34 | 35 | #include "cereal/cereal.hpp" 36 | #include 37 | 38 | namespace cereal 39 | { 40 | //! Saving for std::valarray arithmetic types, using binary serialization, if supported 41 | template inline 42 | typename std::enable_if, Archive>::value 43 | && std::is_arithmetic::value, void>::type 44 | CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::valarray const & valarray ) 45 | { 46 | ar( make_size_tag( static_cast(valarray.size()) ) ); // number of elements 47 | ar( binary_data( &valarray[0], valarray.size() * sizeof(T) ) ); // &valarray[0] ok since guaranteed contiguous 48 | } 49 | 50 | //! Loading for std::valarray arithmetic types, using binary serialization, if supported 51 | template inline 52 | typename std::enable_if, Archive>::value 53 | && std::is_arithmetic::value, void>::type 54 | CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::valarray & valarray ) 55 | { 56 | size_type valarraySize; 57 | ar( make_size_tag( valarraySize ) ); 58 | 59 | valarray.resize( static_cast( valarraySize ) ); 60 | ar( binary_data( &valarray[0], static_cast( valarraySize ) * sizeof(T) ) ); 61 | } 62 | 63 | //! Saving for std::valarray all other types 64 | template inline 65 | typename std::enable_if, Archive>::value 66 | || !std::is_arithmetic::value, void>::type 67 | CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::valarray const & valarray ) 68 | { 69 | ar( make_size_tag( static_cast(valarray.size()) ) ); // number of elements 70 | for(auto && v : valarray) 71 | ar(v); 72 | } 73 | 74 | //! Loading for std::valarray all other types 75 | template inline 76 | typename std::enable_if, Archive>::value 77 | || !std::is_arithmetic::value, void>::type 78 | CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::valarray & valarray ) 79 | { 80 | size_type valarraySize; 81 | ar( make_size_tag( valarraySize ) ); 82 | 83 | valarray.resize( static_cast( valarraySize ) ); 84 | for(auto && v : valarray) 85 | ar(v); 86 | } 87 | } // namespace cereal 88 | 89 | #endif // CEREAL_TYPES_VALARRAY_HPP_ 90 | -------------------------------------------------------------------------------- /cereal/external/rapidjson/error/en.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef CEREAL_RAPIDJSON_ERROR_EN_H_ 16 | #define CEREAL_RAPIDJSON_ERROR_EN_H_ 17 | 18 | #include "error.h" 19 | 20 | #ifdef __clang__ 21 | CEREAL_RAPIDJSON_DIAG_PUSH 22 | CEREAL_RAPIDJSON_DIAG_OFF(switch-enum) 23 | CEREAL_RAPIDJSON_DIAG_OFF(covered-switch-default) 24 | #endif 25 | 26 | CEREAL_RAPIDJSON_NAMESPACE_BEGIN 27 | 28 | //! Maps error code of parsing into error message. 29 | /*! 30 | \ingroup CEREAL_RAPIDJSON_ERRORS 31 | \param parseErrorCode Error code obtained in parsing. 32 | \return the error message. 33 | \note User can make a copy of this function for localization. 34 | Using switch-case is safer for future modification of error codes. 35 | */ 36 | inline const CEREAL_RAPIDJSON_ERROR_CHARTYPE* GetParseError_En(ParseErrorCode parseErrorCode) { 37 | switch (parseErrorCode) { 38 | case kParseErrorNone: return CEREAL_RAPIDJSON_ERROR_STRING("No error."); 39 | 40 | case kParseErrorDocumentEmpty: return CEREAL_RAPIDJSON_ERROR_STRING("The document is empty."); 41 | case kParseErrorDocumentRootNotSingular: return CEREAL_RAPIDJSON_ERROR_STRING("The document root must not be followed by other values."); 42 | 43 | case kParseErrorValueInvalid: return CEREAL_RAPIDJSON_ERROR_STRING("Invalid value."); 44 | 45 | case kParseErrorObjectMissName: return CEREAL_RAPIDJSON_ERROR_STRING("Missing a name for object member."); 46 | case kParseErrorObjectMissColon: return CEREAL_RAPIDJSON_ERROR_STRING("Missing a colon after a name of object member."); 47 | case kParseErrorObjectMissCommaOrCurlyBracket: return CEREAL_RAPIDJSON_ERROR_STRING("Missing a comma or '}' after an object member."); 48 | 49 | case kParseErrorArrayMissCommaOrSquareBracket: return CEREAL_RAPIDJSON_ERROR_STRING("Missing a comma or ']' after an array element."); 50 | 51 | case kParseErrorStringUnicodeEscapeInvalidHex: return CEREAL_RAPIDJSON_ERROR_STRING("Incorrect hex digit after \\u escape in string."); 52 | case kParseErrorStringUnicodeSurrogateInvalid: return CEREAL_RAPIDJSON_ERROR_STRING("The surrogate pair in string is invalid."); 53 | case kParseErrorStringEscapeInvalid: return CEREAL_RAPIDJSON_ERROR_STRING("Invalid escape character in string."); 54 | case kParseErrorStringMissQuotationMark: return CEREAL_RAPIDJSON_ERROR_STRING("Missing a closing quotation mark in string."); 55 | case kParseErrorStringInvalidEncoding: return CEREAL_RAPIDJSON_ERROR_STRING("Invalid encoding in string."); 56 | 57 | case kParseErrorNumberTooBig: return CEREAL_RAPIDJSON_ERROR_STRING("Number too big to be stored in double."); 58 | case kParseErrorNumberMissFraction: return CEREAL_RAPIDJSON_ERROR_STRING("Miss fraction part in number."); 59 | case kParseErrorNumberMissExponent: return CEREAL_RAPIDJSON_ERROR_STRING("Miss exponent in number."); 60 | 61 | case kParseErrorTermination: return CEREAL_RAPIDJSON_ERROR_STRING("Terminate parsing due to Handler error."); 62 | case kParseErrorUnspecificSyntaxError: return CEREAL_RAPIDJSON_ERROR_STRING("Unspecific syntax error."); 63 | 64 | default: return CEREAL_RAPIDJSON_ERROR_STRING("Unknown error."); 65 | } 66 | } 67 | 68 | CEREAL_RAPIDJSON_NAMESPACE_END 69 | 70 | #ifdef __clang__ 71 | CEREAL_RAPIDJSON_DIAG_POP 72 | #endif 73 | 74 | #endif // CEREAL_RAPIDJSON_ERROR_EN_H_ 75 | -------------------------------------------------------------------------------- /cereal/external/rapidjson/stringbuffer.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef CEREAL_RAPIDJSON_STRINGBUFFER_H_ 16 | #define CEREAL_RAPIDJSON_STRINGBUFFER_H_ 17 | 18 | #include "stream.h" 19 | #include "internal/stack.h" 20 | 21 | #if CEREAL_RAPIDJSON_HAS_CXX11_RVALUE_REFS 22 | #include // std::move 23 | #endif 24 | 25 | #include "internal/stack.h" 26 | 27 | #if defined(__clang__) 28 | CEREAL_RAPIDJSON_DIAG_PUSH 29 | CEREAL_RAPIDJSON_DIAG_OFF(c++98-compat) 30 | #endif 31 | 32 | CEREAL_RAPIDJSON_NAMESPACE_BEGIN 33 | 34 | //! Represents an in-memory output stream. 35 | /*! 36 | \tparam Encoding Encoding of the stream. 37 | \tparam Allocator type for allocating memory buffer. 38 | \note implements Stream concept 39 | */ 40 | template 41 | class GenericStringBuffer { 42 | public: 43 | typedef typename Encoding::Ch Ch; 44 | 45 | GenericStringBuffer(Allocator* allocator = 0, size_t capacity = kDefaultCapacity) : stack_(allocator, capacity) {} 46 | 47 | #if CEREAL_RAPIDJSON_HAS_CXX11_RVALUE_REFS 48 | GenericStringBuffer(GenericStringBuffer&& rhs) : stack_(std::move(rhs.stack_)) {} 49 | GenericStringBuffer& operator=(GenericStringBuffer&& rhs) { 50 | if (&rhs != this) 51 | stack_ = std::move(rhs.stack_); 52 | return *this; 53 | } 54 | #endif 55 | 56 | void Put(Ch c) { *stack_.template Push() = c; } 57 | void PutUnsafe(Ch c) { *stack_.template PushUnsafe() = c; } 58 | void Flush() {} 59 | 60 | void Clear() { stack_.Clear(); } 61 | void ShrinkToFit() { 62 | // Push and pop a null terminator. This is safe. 63 | *stack_.template Push() = '\0'; 64 | stack_.ShrinkToFit(); 65 | stack_.template Pop(1); 66 | } 67 | 68 | void Reserve(size_t count) { stack_.template Reserve(count); } 69 | Ch* Push(size_t count) { return stack_.template Push(count); } 70 | Ch* PushUnsafe(size_t count) { return stack_.template PushUnsafe(count); } 71 | void Pop(size_t count) { stack_.template Pop(count); } 72 | 73 | const Ch* GetString() const { 74 | // Push and pop a null terminator. This is safe. 75 | *stack_.template Push() = '\0'; 76 | stack_.template Pop(1); 77 | 78 | return stack_.template Bottom(); 79 | } 80 | 81 | //! Get the size of string in bytes in the string buffer. 82 | size_t GetSize() const { return stack_.GetSize(); } 83 | 84 | //! Get the length of string in Ch in the string buffer. 85 | size_t GetLength() const { return stack_.GetSize() / sizeof(Ch); } 86 | 87 | static const size_t kDefaultCapacity = 256; 88 | mutable internal::Stack stack_; 89 | 90 | private: 91 | // Prohibit copy constructor & assignment operator. 92 | GenericStringBuffer(const GenericStringBuffer&); 93 | GenericStringBuffer& operator=(const GenericStringBuffer&); 94 | }; 95 | 96 | //! String buffer with UTF8 encoding 97 | typedef GenericStringBuffer > StringBuffer; 98 | 99 | template 100 | inline void PutReserve(GenericStringBuffer& stream, size_t count) { 101 | stream.Reserve(count); 102 | } 103 | 104 | template 105 | inline void PutUnsafe(GenericStringBuffer& stream, typename Encoding::Ch c) { 106 | stream.PutUnsafe(c); 107 | } 108 | 109 | //! Implement specialized version of PutN() with memset() for better performance. 110 | template<> 111 | inline void PutN(GenericStringBuffer >& stream, char c, size_t n) { 112 | std::memset(stream.stack_.Push(n), c, n * sizeof(c)); 113 | } 114 | 115 | CEREAL_RAPIDJSON_NAMESPACE_END 116 | 117 | #if defined(__clang__) 118 | CEREAL_RAPIDJSON_DIAG_POP 119 | #endif 120 | 121 | #endif // CEREAL_RAPIDJSON_STRINGBUFFER_H_ 122 | -------------------------------------------------------------------------------- /cereal/types/variant.hpp: -------------------------------------------------------------------------------- 1 | /*! \file variant.hpp 2 | \brief Support for std::variant 3 | \ingroup STLSupport */ 4 | /* 5 | Copyright (c) 2014, 2017, Randolph Voorhies, Shane Grant, Juan Pedro 6 | Bolivar Puente. All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of cereal nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef CEREAL_TYPES_STD_VARIANT_HPP_ 31 | #define CEREAL_TYPES_STD_VARIANT_HPP_ 32 | 33 | #include "cereal/cereal.hpp" 34 | #include 35 | #include 36 | 37 | namespace cereal 38 | { 39 | namespace variant_detail 40 | { 41 | //! @internal 42 | template 43 | struct variant_save_visitor 44 | { 45 | variant_save_visitor(Archive & ar_) : ar(ar_) {} 46 | 47 | template 48 | void operator()(T const & value) const 49 | { 50 | ar( CEREAL_NVP_("data", value) ); 51 | } 52 | 53 | Archive & ar; 54 | }; 55 | 56 | //! @internal 57 | template 58 | typename std::enable_if, void>::type 59 | load_variant(Archive & /*ar*/, int /*target*/, Variant & /*variant*/) 60 | { 61 | throw ::cereal::Exception("Error traversing variant during load"); 62 | } 63 | //! @internal 64 | template 65 | typename std::enable_if, void>::type 66 | load_variant(Archive & ar, int target, Variant & variant) 67 | { 68 | if(N == target) 69 | { 70 | H value; 71 | ar( CEREAL_NVP_("data", value) ); 72 | variant = std::move(value); 73 | } 74 | else 75 | load_variant(ar, target, variant); 76 | } 77 | 78 | } // namespace variant_detail 79 | 80 | //! Saving for std::variant 81 | template inline 82 | void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::variant const & variant ) 83 | { 84 | std::int32_t index = static_cast(variant.index()); 85 | ar( CEREAL_NVP_("index", index) ); 86 | variant_detail::variant_save_visitor visitor(ar); 87 | std::visit(visitor, variant); 88 | } 89 | 90 | //! Loading for std::variant 91 | template inline 92 | void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::variant & variant ) 93 | { 94 | using variant_t = typename std::variant; 95 | 96 | std::int32_t index; 97 | ar( CEREAL_NVP_("index", index) ); 98 | if(index >= static_cast(std::variant_size_v)) 99 | throw Exception("Invalid 'index' selector when deserializing std::variant"); 100 | 101 | variant_detail::load_variant<0, variant_t, VariantTypes...>(ar, index, variant); 102 | } 103 | 104 | //! Serializing a std::monostate 105 | template 106 | void CEREAL_SERIALIZE_FUNCTION_NAME( Archive &, std::monostate const & ) {} 107 | } // namespace cereal 108 | 109 | #endif // CEREAL_TYPES_STD_VARIANT_HPP_ 110 | -------------------------------------------------------------------------------- /cereal/external/rapidxml/rapidxml_iterators.hpp: -------------------------------------------------------------------------------- 1 | #ifndef CEREAL_RAPIDXML_ITERATORS_HPP_INCLUDED 2 | #define CEREAL_RAPIDXML_ITERATORS_HPP_INCLUDED 3 | 4 | // Copyright (C) 2006, 2009 Marcin Kalicinski 5 | // Version 1.13 6 | // Revision $DateTime: 2009/05/13 01:46:17 $ 7 | 8 | #include "rapidxml.hpp" 9 | 10 | namespace cereal { 11 | namespace rapidxml 12 | { 13 | 14 | //! Iterator of child nodes of xml_node 15 | template 16 | class node_iterator 17 | { 18 | 19 | public: 20 | 21 | typedef typename xml_node value_type; 22 | typedef typename xml_node &reference; 23 | typedef typename xml_node *pointer; 24 | typedef std::ptrdiff_t difference_type; 25 | typedef std::bidirectional_iterator_tag iterator_category; 26 | 27 | node_iterator() 28 | : m_node(0) 29 | { 30 | } 31 | 32 | node_iterator(xml_node *node) 33 | : m_node(node->first_node()) 34 | { 35 | } 36 | 37 | reference operator *() const 38 | { 39 | assert(m_node); 40 | return *m_node; 41 | } 42 | 43 | pointer operator->() const 44 | { 45 | assert(m_node); 46 | return m_node; 47 | } 48 | 49 | node_iterator& operator++() 50 | { 51 | assert(m_node); 52 | m_node = m_node->next_sibling(); 53 | return *this; 54 | } 55 | 56 | node_iterator operator++(int) 57 | { 58 | node_iterator tmp = *this; 59 | ++this; 60 | return tmp; 61 | } 62 | 63 | node_iterator& operator--() 64 | { 65 | assert(m_node && m_node->previous_sibling()); 66 | m_node = m_node->previous_sibling(); 67 | return *this; 68 | } 69 | 70 | node_iterator operator--(int) 71 | { 72 | node_iterator tmp = *this; 73 | ++this; 74 | return tmp; 75 | } 76 | 77 | bool operator ==(const node_iterator &rhs) 78 | { 79 | return m_node == rhs.m_node; 80 | } 81 | 82 | bool operator !=(const node_iterator &rhs) 83 | { 84 | return m_node != rhs.m_node; 85 | } 86 | 87 | private: 88 | 89 | xml_node *m_node; 90 | 91 | }; 92 | 93 | //! Iterator of child attributes of xml_node 94 | template 95 | class attribute_iterator 96 | { 97 | 98 | public: 99 | 100 | typedef typename xml_attribute value_type; 101 | typedef typename xml_attribute &reference; 102 | typedef typename xml_attribute *pointer; 103 | typedef std::ptrdiff_t difference_type; 104 | typedef std::bidirectional_iterator_tag iterator_category; 105 | 106 | attribute_iterator() 107 | : m_attribute(0) 108 | { 109 | } 110 | 111 | attribute_iterator(xml_node *node) 112 | : m_attribute(node->first_attribute()) 113 | { 114 | } 115 | 116 | reference operator *() const 117 | { 118 | assert(m_attribute); 119 | return *m_attribute; 120 | } 121 | 122 | pointer operator->() const 123 | { 124 | assert(m_attribute); 125 | return m_attribute; 126 | } 127 | 128 | attribute_iterator& operator++() 129 | { 130 | assert(m_attribute); 131 | m_attribute = m_attribute->next_attribute(); 132 | return *this; 133 | } 134 | 135 | attribute_iterator operator++(int) 136 | { 137 | attribute_iterator tmp = *this; 138 | ++this; 139 | return tmp; 140 | } 141 | 142 | attribute_iterator& operator--() 143 | { 144 | assert(m_attribute && m_attribute->previous_attribute()); 145 | m_attribute = m_attribute->previous_attribute(); 146 | return *this; 147 | } 148 | 149 | attribute_iterator operator--(int) 150 | { 151 | attribute_iterator tmp = *this; 152 | ++this; 153 | return tmp; 154 | } 155 | 156 | bool operator ==(const attribute_iterator &rhs) 157 | { 158 | return m_attribute == rhs.m_attribute; 159 | } 160 | 161 | bool operator !=(const attribute_iterator &rhs) 162 | { 163 | return m_attribute != rhs.m_attribute; 164 | } 165 | 166 | private: 167 | 168 | xml_attribute *m_attribute; 169 | 170 | }; 171 | 172 | } 173 | } // namespace cereal 174 | 175 | #endif 176 | -------------------------------------------------------------------------------- /cereal/external/rapidjson/istreamwrapper.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef CEREAL_RAPIDJSON_ISTREAMWRAPPER_H_ 16 | #define CEREAL_RAPIDJSON_ISTREAMWRAPPER_H_ 17 | 18 | #include "stream.h" 19 | #include 20 | #include 21 | 22 | #ifdef __clang__ 23 | CEREAL_RAPIDJSON_DIAG_PUSH 24 | CEREAL_RAPIDJSON_DIAG_OFF(padded) 25 | #elif defined(_MSC_VER) 26 | CEREAL_RAPIDJSON_DIAG_PUSH 27 | CEREAL_RAPIDJSON_DIAG_OFF(4351) // new behavior: elements of array 'array' will be default initialized 28 | #endif 29 | 30 | CEREAL_RAPIDJSON_NAMESPACE_BEGIN 31 | 32 | //! Wrapper of \c std::basic_istream into RapidJSON's Stream concept. 33 | /*! 34 | The classes can be wrapped including but not limited to: 35 | 36 | - \c std::istringstream 37 | - \c std::stringstream 38 | - \c std::wistringstream 39 | - \c std::wstringstream 40 | - \c std::ifstream 41 | - \c std::fstream 42 | - \c std::wifstream 43 | - \c std::wfstream 44 | 45 | \tparam StreamType Class derived from \c std::basic_istream. 46 | */ 47 | 48 | template 49 | class BasicIStreamWrapper { 50 | public: 51 | typedef typename StreamType::char_type Ch; 52 | 53 | //! Constructor. 54 | /*! 55 | \param stream stream opened for read. 56 | */ 57 | BasicIStreamWrapper(StreamType &stream) : stream_(stream), buffer_(peekBuffer_), bufferSize_(4), bufferLast_(0), current_(buffer_), readCount_(0), count_(0), eof_(false) { 58 | Read(); 59 | } 60 | 61 | //! Constructor. 62 | /*! 63 | \param stream stream opened for read. 64 | \param buffer user-supplied buffer. 65 | \param bufferSize size of buffer in bytes. Must >=4 bytes. 66 | */ 67 | BasicIStreamWrapper(StreamType &stream, char* buffer, size_t bufferSize) : stream_(stream), buffer_(buffer), bufferSize_(bufferSize), bufferLast_(0), current_(buffer_), readCount_(0), count_(0), eof_(false) { 68 | CEREAL_RAPIDJSON_ASSERT(bufferSize >= 4); 69 | Read(); 70 | } 71 | 72 | Ch Peek() const { return *current_; } 73 | Ch Take() { Ch c = *current_; Read(); return c; } 74 | size_t Tell() const { return count_ + static_cast(current_ - buffer_); } 75 | 76 | // Not implemented 77 | void Put(Ch) { CEREAL_RAPIDJSON_ASSERT(false); } 78 | void Flush() { CEREAL_RAPIDJSON_ASSERT(false); } 79 | Ch* PutBegin() { CEREAL_RAPIDJSON_ASSERT(false); return 0; } 80 | size_t PutEnd(Ch*) { CEREAL_RAPIDJSON_ASSERT(false); return 0; } 81 | 82 | // For encoding detection only. 83 | const Ch* Peek4() const { 84 | return (current_ + 4 - !eof_ <= bufferLast_) ? current_ : 0; 85 | } 86 | 87 | private: 88 | BasicIStreamWrapper(); 89 | BasicIStreamWrapper(const BasicIStreamWrapper&); 90 | BasicIStreamWrapper& operator=(const BasicIStreamWrapper&); 91 | 92 | void Read() { 93 | if (current_ < bufferLast_) 94 | ++current_; 95 | else if (!eof_) { 96 | count_ += readCount_; 97 | readCount_ = bufferSize_; 98 | bufferLast_ = buffer_ + readCount_ - 1; 99 | current_ = buffer_; 100 | 101 | if (!stream_.read(buffer_, static_cast(bufferSize_))) { 102 | readCount_ = static_cast(stream_.gcount()); 103 | *(bufferLast_ = buffer_ + readCount_) = '\0'; 104 | eof_ = true; 105 | } 106 | } 107 | } 108 | 109 | StreamType &stream_; 110 | Ch peekBuffer_[4], *buffer_; 111 | size_t bufferSize_; 112 | Ch *bufferLast_; 113 | Ch *current_; 114 | size_t readCount_; 115 | size_t count_; //!< Number of characters read 116 | bool eof_; 117 | }; 118 | 119 | typedef BasicIStreamWrapper IStreamWrapper; 120 | typedef BasicIStreamWrapper WIStreamWrapper; 121 | 122 | #if defined(__clang__) || defined(_MSC_VER) 123 | CEREAL_RAPIDJSON_DIAG_POP 124 | #endif 125 | 126 | CEREAL_RAPIDJSON_NAMESPACE_END 127 | 128 | #endif // CEREAL_RAPIDJSON_ISTREAMWRAPPER_H_ 129 | -------------------------------------------------------------------------------- /cereal/external/rapidjson/fwd.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef CEREAL_RAPIDJSON_FWD_H_ 16 | #define CEREAL_RAPIDJSON_FWD_H_ 17 | 18 | #include "rapidjson.h" 19 | 20 | CEREAL_RAPIDJSON_NAMESPACE_BEGIN 21 | 22 | // encodings.h 23 | 24 | template struct UTF8; 25 | template struct UTF16; 26 | template struct UTF16BE; 27 | template struct UTF16LE; 28 | template struct UTF32; 29 | template struct UTF32BE; 30 | template struct UTF32LE; 31 | template struct ASCII; 32 | template struct AutoUTF; 33 | 34 | template 35 | struct Transcoder; 36 | 37 | // allocators.h 38 | 39 | class CrtAllocator; 40 | 41 | template 42 | class MemoryPoolAllocator; 43 | 44 | // stream.h 45 | 46 | template 47 | struct GenericStringStream; 48 | 49 | typedef GenericStringStream > StringStream; 50 | 51 | template 52 | struct GenericInsituStringStream; 53 | 54 | typedef GenericInsituStringStream > InsituStringStream; 55 | 56 | // stringbuffer.h 57 | 58 | template 59 | class GenericStringBuffer; 60 | 61 | typedef GenericStringBuffer, CrtAllocator> StringBuffer; 62 | 63 | // filereadstream.h 64 | 65 | class FileReadStream; 66 | 67 | // filewritestream.h 68 | 69 | class FileWriteStream; 70 | 71 | // memorybuffer.h 72 | 73 | template 74 | struct GenericMemoryBuffer; 75 | 76 | typedef GenericMemoryBuffer MemoryBuffer; 77 | 78 | // memorystream.h 79 | 80 | struct MemoryStream; 81 | 82 | // reader.h 83 | 84 | template 85 | struct BaseReaderHandler; 86 | 87 | template 88 | class GenericReader; 89 | 90 | typedef GenericReader, UTF8, CrtAllocator> Reader; 91 | 92 | // writer.h 93 | 94 | template 95 | class Writer; 96 | 97 | // prettywriter.h 98 | 99 | template 100 | class PrettyWriter; 101 | 102 | // document.h 103 | 104 | template 105 | struct GenericMember; 106 | 107 | template 108 | class GenericMemberIterator; 109 | 110 | template 111 | struct GenericStringRef; 112 | 113 | template 114 | class GenericValue; 115 | 116 | typedef GenericValue, MemoryPoolAllocator > Value; 117 | 118 | template 119 | class GenericDocument; 120 | 121 | typedef GenericDocument, MemoryPoolAllocator, CrtAllocator> Document; 122 | 123 | // pointer.h 124 | 125 | template 126 | class GenericPointer; 127 | 128 | typedef GenericPointer Pointer; 129 | 130 | // schema.h 131 | 132 | template 133 | class IGenericRemoteSchemaDocumentProvider; 134 | 135 | template 136 | class GenericSchemaDocument; 137 | 138 | typedef GenericSchemaDocument SchemaDocument; 139 | typedef IGenericRemoteSchemaDocumentProvider IRemoteSchemaDocumentProvider; 140 | 141 | template < 142 | typename SchemaDocumentType, 143 | typename OutputHandler, 144 | typename StateAllocator> 145 | class GenericSchemaValidator; 146 | 147 | typedef GenericSchemaValidator, void>, CrtAllocator> SchemaValidator; 148 | 149 | CEREAL_RAPIDJSON_NAMESPACE_END 150 | 151 | #endif // CEREAL_RAPIDJSON_RAPIDJSONFWD_H_ 152 | -------------------------------------------------------------------------------- /cereal/external/base64.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (C) 2004-2008 René Nyffenegger 3 | 4 | This source code is provided 'as-is', without any express or implied 5 | warranty. In no event will the author be held liable for any damages 6 | arising from the use of this software. 7 | 8 | Permission is granted to anyone to use this software for any purpose, 9 | including commercial applications, and to alter it and redistribute it 10 | freely, subject to the following restrictions: 11 | 12 | 1. The origin of this source code must not be misrepresented; you must not 13 | claim that you wrote the original source code. If you use this source code 14 | in a product, an acknowledgment in the product documentation would be 15 | appreciated but is not required. 16 | 17 | 2. Altered source versions must be plainly marked as such, and must not be 18 | misrepresented as being the original source code. 19 | 20 | 3. This notice may not be removed or altered from any source distribution. 21 | 22 | René Nyffenegger rene.nyffenegger@adp-gmbh.ch 23 | */ 24 | 25 | #ifndef CEREAL_EXTERNAL_BASE64_HPP_ 26 | #define CEREAL_EXTERNAL_BASE64_HPP_ 27 | 28 | #ifdef __GNUC__ 29 | #pragma GCC diagnostic push 30 | #pragma GCC diagnostic ignored "-Wconversion" 31 | #endif 32 | 33 | #include 34 | 35 | namespace cereal 36 | { 37 | namespace base64 38 | { 39 | static const std::string chars = 40 | "ABCDEFGHIJKLMNOPQRSTUVWXYZ" 41 | "abcdefghijklmnopqrstuvwxyz" 42 | "0123456789+/"; 43 | 44 | static inline bool is_base64(unsigned char c) { 45 | return (isalnum(c) || (c == '+') || (c == '/')); 46 | } 47 | 48 | inline std::string encode(unsigned char const* bytes_to_encode, size_t in_len) { 49 | std::string ret; 50 | int i = 0; 51 | int j = 0; 52 | unsigned char char_array_3[3]; 53 | unsigned char char_array_4[4]; 54 | 55 | while (in_len--) { 56 | char_array_3[i++] = *(bytes_to_encode++); 57 | if (i == 3) { 58 | char_array_4[0] = static_cast((char_array_3[0] & 0xfc) >> 2); 59 | char_array_4[1] = static_cast( ( ( char_array_3[0] & 0x03 ) << 4 ) + ( ( char_array_3[1] & 0xf0 ) >> 4 ) ); 60 | char_array_4[2] = static_cast( ( ( char_array_3[1] & 0x0f ) << 2 ) + ( ( char_array_3[2] & 0xc0 ) >> 6 ) ); 61 | char_array_4[3] = static_cast( char_array_3[2] & 0x3f ); 62 | 63 | for(i = 0; (i <4) ; i++) 64 | ret += chars[char_array_4[i]]; 65 | i = 0; 66 | } 67 | } 68 | 69 | if (i) 70 | { 71 | for(j = i; j < 3; j++) 72 | char_array_3[j] = '\0'; 73 | 74 | char_array_4[0] = (char_array_3[0] & 0xfc) >> 2; 75 | char_array_4[1] = ((char_array_3[0] & 0x03) << 4) + ((char_array_3[1] & 0xf0) >> 4); 76 | char_array_4[2] = ((char_array_3[1] & 0x0f) << 2) + ((char_array_3[2] & 0xc0) >> 6); 77 | char_array_4[3] = char_array_3[2] & 0x3f; 78 | 79 | for (j = 0; (j < i + 1); j++) 80 | ret += chars[char_array_4[j]]; 81 | 82 | while((i++ < 3)) 83 | ret += '='; 84 | } 85 | 86 | return ret; 87 | } 88 | 89 | inline std::string decode(std::string const& encoded_string) { 90 | size_t in_len = encoded_string.size(); 91 | size_t i = 0; 92 | size_t j = 0; 93 | int in_ = 0; 94 | unsigned char char_array_4[4], char_array_3[3]; 95 | std::string ret; 96 | 97 | while (in_len-- && ( encoded_string[in_] != '=') && is_base64(encoded_string[in_])) { 98 | char_array_4[i++] = encoded_string[in_]; in_++; 99 | if (i ==4) { 100 | for (i = 0; i <4; i++) 101 | char_array_4[i] = static_cast(chars.find( char_array_4[i] )); 102 | 103 | char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); 104 | char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); 105 | char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3]; 106 | 107 | for (i = 0; (i < 3); i++) 108 | ret += char_array_3[i]; 109 | i = 0; 110 | } 111 | } 112 | 113 | if (i) { 114 | for (j = i; j <4; j++) 115 | char_array_4[j] = 0; 116 | 117 | for (j = 0; j <4; j++) 118 | char_array_4[j] = static_cast(chars.find( char_array_4[j] )); 119 | 120 | char_array_3[0] = (char_array_4[0] << 2) + ((char_array_4[1] & 0x30) >> 4); 121 | char_array_3[1] = ((char_array_4[1] & 0xf) << 4) + ((char_array_4[2] & 0x3c) >> 2); 122 | char_array_3[2] = ((char_array_4[2] & 0x3) << 6) + char_array_4[3]; 123 | 124 | for (j = 0; (j < i - 1); j++) ret += char_array_3[j]; 125 | } 126 | 127 | return ret; 128 | } 129 | } // namespace base64 130 | } // namespace cereal 131 | #ifdef __GNUC__ 132 | #pragma GCC diagnostic pop 133 | #endif 134 | #endif // CEREAL_EXTERNAL_BASE64_HPP_ 135 | -------------------------------------------------------------------------------- /cereal/types/tuple.hpp: -------------------------------------------------------------------------------- 1 | /*! \file tuple.hpp 2 | \brief Support for types found in \ 3 | \ingroup STLSupport */ 4 | /* 5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of cereal nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef CEREAL_TYPES_TUPLE_HPP_ 31 | #define CEREAL_TYPES_TUPLE_HPP_ 32 | 33 | #include "cereal/cereal.hpp" 34 | #include 35 | 36 | namespace cereal 37 | { 38 | namespace tuple_detail 39 | { 40 | //! Creates a c string from a sequence of characters 41 | /*! The c string created will always be prefixed by "tuple_element" 42 | Based on code from: http://stackoverflow/a/20973438/710791 43 | @internal */ 44 | template 45 | struct char_seq_to_c_str 46 | { 47 | static const int size = 14;// Size of array for the word: tuple_element 48 | typedef const char (&arr_type)[sizeof...(Cs) + size]; 49 | static const char str[sizeof...(Cs) + size]; 50 | }; 51 | 52 | // the word tuple_element plus a number 53 | //! @internal 54 | template 55 | const char char_seq_to_c_str::str[sizeof...(Cs) + size] = 56 | {'t','u','p','l','e','_','e','l','e','m','e','n','t', Cs..., '\0'}; 57 | 58 | //! Converts a number into a sequence of characters 59 | /*! @tparam Q The quotient of dividing the original number by 10 60 | @tparam R The remainder of dividing the original number by 10 61 | @tparam C The sequence built so far 62 | @internal */ 63 | template 64 | struct to_string_impl 65 | { 66 | using type = typename to_string_impl(R+std::size_t{'0'}), C...>::type; 67 | }; 68 | 69 | //! Base case with no quotient 70 | /*! @internal */ 71 | template 72 | struct to_string_impl<0, R, C...> 73 | { 74 | using type = char_seq_to_c_str(R+std::size_t{'0'}), C...>; 75 | }; 76 | 77 | //! Generates a c string for a given index of a tuple 78 | /*! Example use: 79 | @code{cpp} 80 | tuple_element_name<3>::c_str();// returns "tuple_element3" 81 | @endcode 82 | @internal */ 83 | template 84 | struct tuple_element_name 85 | { 86 | using type = typename to_string_impl::type; 87 | static const typename type::arr_type c_str(){ return type::str; } 88 | }; 89 | 90 | // unwinds a tuple to save it 91 | //! @internal 92 | template 93 | struct serialize 94 | { 95 | template inline 96 | static void apply( Archive & ar, std::tuple & tuple ) 97 | { 98 | serialize::template apply( ar, tuple ); 99 | ar( CEREAL_NVP_(tuple_element_name::c_str(), 100 | std::get( tuple )) ); 101 | } 102 | }; 103 | 104 | // Zero height specialization - nothing to do here 105 | //! @internal 106 | template <> 107 | struct serialize<0> 108 | { 109 | template inline 110 | static void apply( Archive &, std::tuple & ) 111 | { } 112 | }; 113 | } 114 | 115 | //! Serializing for std::tuple 116 | template inline 117 | void CEREAL_SERIALIZE_FUNCTION_NAME( Archive & ar, std::tuple & tuple ) 118 | { 119 | tuple_detail::serialize>::value>::template apply( ar, tuple ); 120 | } 121 | } // namespace cereal 122 | 123 | #endif // CEREAL_TYPES_TUPLE_HPP_ 124 | -------------------------------------------------------------------------------- /window_exe_data.cpp: -------------------------------------------------------------------------------- 1 | #include "window_exe_data.h" 2 | #include "ui_window_exe_data.h" 3 | 4 | window_exe_data::window_exe_data(QWidget *parent,TCB* tcb) : 5 | QWidget(parent), 6 | ui(new Ui::window_exe_data) 7 | { 8 | ui->setupUi(this); 9 | this->tcb = tcb; 10 | fileSelected = nullptr; 11 | this->setWindowTitle("数据执行"); 12 | // 关闭即销毁 13 | this->setAttribute(Qt::WA_DeleteOnClose,true); 14 | // 定义 15 | lv_fileList = ui->lv_fileList; 16 | ll_owner = ui->text_owner; 17 | ll_fileName = ui->text_fileName; 18 | ll_fileSize = ui->text_fileSize; 19 | ll_createTime = ui->text_createTime; 20 | ll_loadFile = ui->text_loadFiles; 21 | nb_pageNumber = ui->nb_pageNumber; 22 | tb_outputBuffer = ui->tb_outputBuffer; 23 | // 是否已经打开文件 24 | isInUse = false; 25 | 26 | model = new QStandardItemModel(); 27 | lv_fileList->setModel(model); 28 | connect(lv_fileList,SIGNAL(clicked(QModelIndex)),this,SLOT(showClick(QModelIndex))); 29 | 30 | updateFiles(); 31 | } 32 | 33 | window_exe_data::~window_exe_data() 34 | { 35 | delete ui; 36 | } 37 | 38 | // 读入按钮被按下 39 | void window_exe_data::on_pushButton_clicked() 40 | { 41 | // 加锁 42 | CGlobal::mSem->acquire(); 43 | //ui->pushButton->setDisabled(true); 44 | // 获取页号数 45 | int page = nb_pageNumber->value(); 46 | // 在内存中读取数据 47 | auto status = CGlobal::mManager->read(tcb,page); 48 | // 通过string来判断 49 | if (status.code == STATUS_OK){ 50 | // 没有发生换页 51 | 52 | } else if (status.code == STATUS_MEMORY_EXIST){ 53 | // 直接引用内存 54 | QMessageBox * box = new QMessageBox(); 55 | box->setText("内存中已存在该页,内存块号为:"+QString::number(status.mBlock)); 56 | box->exec(); 57 | } 58 | else if (status.code == STATUS_EXCHANGE_PAGE){ 59 | // 发生了换页 60 | QMessageBox * box = new QMessageBox(); 61 | box->setText("发生LRU全局置换,替换的内存块号为:"+QString::number(status.mBlock)); 62 | box->exec(); 63 | } 64 | // 更新UI 65 | tb_outputBuffer->append("第"+QString::number(page)+"页数据:"+QString::fromStdString(status.data)); 66 | // 通知主线程 67 | emit notifyUpdate(); 68 | // 解锁 69 | CGlobal::mSem->release(); 70 | } 71 | 72 | // 更新文件列表 73 | void window_exe_data::updateFiles() 74 | { 75 | qDebug() << "执行线程:更新文件列表"; 76 | model->clear(); 77 | queue q = CGlobal::fManager->getFiles(); 78 | // 备份一份 79 | while(!q.empty()){ 80 | FCB* fcb = q.front(); 81 | QStandardItem * item = new QStandardItem(); 82 | item->setEditable(false); 83 | item->setText(QString::fromStdString(fcb->fileName)); 84 | model->appendRow(item); 85 | q.pop(); 86 | tmpFCB.push_back(fcb); 87 | } 88 | } 89 | 90 | // 锁定一个数据执行线程只能访问一个文件,要访问第二个文件需要打开多个窗口 91 | void window_exe_data::on_btn_load_clicked() 92 | { 93 | // fileSelected 指向选中文件的指针 94 | if(fileSelected == nullptr){ 95 | auto box = new QMessageBox(); 96 | box->setText("未选择文件"); 97 | box->exec(); 98 | } else { 99 | tcb->fcb = fileSelected; 100 | // 在tcb中加入读入的数据 101 | tcb->data = CGlobal::fManager->getData(tcb->fcb); 102 | // 上锁,在窗口关闭的时候解锁 103 | int status = CGlobal::mManager->allocMemory(tcb); 104 | if (status == STATUS_OK){ 105 | CGlobal::fManager->lockFile(fileSelected); 106 | isInUse = true; 107 | // 在创建数据执行线程时,已经在FCB中分配了4个内存,所以直接禁用调入内存等 108 | ((QPushButton*)sender())->setEnabled(false); 109 | lv_fileList->setDisabled(true); 110 | ll_loadFile->setText(QString::fromStdString(fileSelected->fileName)); 111 | // 设置页号范围 112 | int blockSize = fileSelected->fileSize; 113 | if (blockSize <= 0){ 114 | nb_pageNumber->setRange(0,0); 115 | // 不允许读入 116 | } else { 117 | nb_pageNumber->setRange(0,blockSize-1); 118 | ui->pushButton->setEnabled(true); 119 | } 120 | emit notifyUpdate(); 121 | } else { 122 | QMessageBox *box = new QMessageBox(); 123 | box->setText("内存不足,无法打开更多的执行线程,请关闭一些执行线程再重试"); 124 | box->exec(); 125 | } 126 | } 127 | } 128 | 129 | void window_exe_data::showClick(QModelIndex index) 130 | { 131 | FCB* fcb = tmpFCB.at(index.row()); 132 | ll_owner->setText(QString::fromStdString(fcb->owner)); 133 | ll_fileName->setText(QString::fromStdString(fcb->fileName)); 134 | ll_fileSize->setText(QString::number(fcb->fileSize)); 135 | ll_createTime->setText(parseTM(fcb->createTime)); 136 | fileSelected = fcb; 137 | } 138 | 139 | void window_exe_data::closeEvent(QCloseEvent *event) 140 | { 141 | // TODO 清除内存,先获取信号量 142 | CGlobal::mSem->acquire(); 143 | int status = CGlobal::mManager->freeBlock(this->tcb); 144 | if(status == STATUS_OK){ 145 | qDebug() << "内存管理器返回正常,内存已清除" ; 146 | } else { 147 | qDebug() << "警告!内存泄露,清除失败" ; 148 | } 149 | 150 | if (isInUse && fileSelected != nullptr){ 151 | // 解锁 152 | CGlobal::fManager->unlockFile(fileSelected); 153 | } 154 | 155 | CGlobal::mSem->release(); 156 | // 发射信号 157 | emit notifyUpdate(); 158 | } 159 | -------------------------------------------------------------------------------- /cereal/types/vector.hpp: -------------------------------------------------------------------------------- 1 | /*! \file vector.hpp 2 | \brief Support for types found in \ 3 | \ingroup STLSupport */ 4 | /* 5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of cereal nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef CEREAL_TYPES_VECTOR_HPP_ 31 | #define CEREAL_TYPES_VECTOR_HPP_ 32 | 33 | #include "cereal/cereal.hpp" 34 | #include 35 | 36 | namespace cereal 37 | { 38 | //! Serialization for std::vectors of arithmetic (but not bool) using binary serialization, if supported 39 | template inline 40 | typename std::enable_if, Archive>::value 41 | && std::is_arithmetic::value && !std::is_same::value, void>::type 42 | CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::vector const & vector ) 43 | { 44 | ar( make_size_tag( static_cast(vector.size()) ) ); // number of elements 45 | ar( binary_data( vector.data(), vector.size() * sizeof(T) ) ); 46 | } 47 | 48 | //! Serialization for std::vectors of arithmetic (but not bool) using binary serialization, if supported 49 | template inline 50 | typename std::enable_if, Archive>::value 51 | && std::is_arithmetic::value && !std::is_same::value, void>::type 52 | CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::vector & vector ) 53 | { 54 | size_type vectorSize; 55 | ar( make_size_tag( vectorSize ) ); 56 | 57 | vector.resize( static_cast( vectorSize ) ); 58 | ar( binary_data( vector.data(), static_cast( vectorSize ) * sizeof(T) ) ); 59 | } 60 | 61 | //! Serialization for non-arithmetic vector types 62 | template inline 63 | typename std::enable_if<(!traits::is_output_serializable, Archive>::value 64 | || !std::is_arithmetic::value) && !std::is_same::value, void>::type 65 | CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::vector const & vector ) 66 | { 67 | ar( make_size_tag( static_cast(vector.size()) ) ); // number of elements 68 | for(auto && v : vector) 69 | ar( v ); 70 | } 71 | 72 | //! Serialization for non-arithmetic vector types 73 | template inline 74 | typename std::enable_if<(!traits::is_input_serializable, Archive>::value 75 | || !std::is_arithmetic::value) && !std::is_same::value, void>::type 76 | CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::vector & vector ) 77 | { 78 | size_type size; 79 | ar( make_size_tag( size ) ); 80 | 81 | vector.resize( static_cast( size ) ); 82 | for(auto && v : vector) 83 | ar( v ); 84 | } 85 | 86 | //! Serialization for bool vector types 87 | template inline 88 | void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::vector const & vector ) 89 | { 90 | ar( make_size_tag( static_cast(vector.size()) ) ); // number of elements 91 | for(const auto v : vector) 92 | ar( static_cast(v) ); 93 | } 94 | 95 | //! Serialization for bool vector types 96 | template inline 97 | void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::vector & vector ) 98 | { 99 | size_type size; 100 | ar( make_size_tag( size ) ); 101 | 102 | vector.resize( static_cast( size ) ); 103 | for(auto v : vector) 104 | { 105 | bool b; 106 | ar( b ); 107 | v = b; 108 | } 109 | } 110 | } // namespace cereal 111 | 112 | #endif // CEREAL_TYPES_VECTOR_HPP_ 113 | -------------------------------------------------------------------------------- /cereal/types/queue.hpp: -------------------------------------------------------------------------------- 1 | /*! \file queue.hpp 2 | \brief Support for types found in \ 3 | \ingroup STLSupport */ 4 | /* 5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of cereal nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef CEREAL_TYPES_QUEUE_HPP_ 31 | #define CEREAL_TYPES_QUEUE_HPP_ 32 | 33 | #include "cereal/details/helpers.hpp" 34 | #include 35 | 36 | // The default container for queue is deque, so let's include that too 37 | #include "cereal/types/deque.hpp" 38 | // The default comparator for queue is less 39 | #include "cereal/types/functional.hpp" 40 | 41 | namespace cereal 42 | { 43 | namespace queue_detail 44 | { 45 | //! Allows access to the protected container in queue 46 | /*! @internal */ 47 | template inline 48 | C const & container( std::queue const & queue ) 49 | { 50 | struct H : public std::queue 51 | { 52 | static C const & get( std::queue const & q ) 53 | { 54 | return q.*(&H::c); 55 | } 56 | }; 57 | 58 | return H::get( queue ); 59 | } 60 | 61 | //! Allows access to the protected container in priority queue 62 | /*! @internal */ 63 | template inline 64 | C const & container( std::priority_queue const & priority_queue ) 65 | { 66 | struct H : public std::priority_queue 67 | { 68 | static C const & get( std::priority_queue const & pq ) 69 | { 70 | return pq.*(&H::c); 71 | } 72 | }; 73 | 74 | return H::get( priority_queue ); 75 | } 76 | 77 | //! Allows access to the protected comparator in priority queue 78 | /*! @internal */ 79 | template inline 80 | Comp const & comparator( std::priority_queue const & priority_queue ) 81 | { 82 | struct H : public std::priority_queue 83 | { 84 | static Comp const & get( std::priority_queue const & pq ) 85 | { 86 | return pq.*(&H::comp); 87 | } 88 | }; 89 | 90 | return H::get( priority_queue ); 91 | } 92 | } 93 | 94 | //! Saving for std::queue 95 | template inline 96 | void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::queue const & queue ) 97 | { 98 | ar( CEREAL_NVP_("container", queue_detail::container( queue )) ); 99 | } 100 | 101 | //! Loading for std::queue 102 | template inline 103 | void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::queue & queue ) 104 | { 105 | C container; 106 | ar( CEREAL_NVP_("container", container) ); 107 | queue = std::queue( std::move( container ) ); 108 | } 109 | 110 | //! Saving for std::priority_queue 111 | template inline 112 | void CEREAL_SAVE_FUNCTION_NAME( Archive & ar, std::priority_queue const & priority_queue ) 113 | { 114 | ar( CEREAL_NVP_("comparator", queue_detail::comparator( priority_queue )) ); 115 | ar( CEREAL_NVP_("container", queue_detail::container( priority_queue )) ); 116 | } 117 | 118 | //! Loading for std::priority_queue 119 | template inline 120 | void CEREAL_LOAD_FUNCTION_NAME( Archive & ar, std::priority_queue & priority_queue ) 121 | { 122 | Comp comparator; 123 | ar( CEREAL_NVP_("comparator", comparator) ); 124 | 125 | C container; 126 | ar( CEREAL_NVP_("container", container) ); 127 | 128 | priority_queue = std::priority_queue( comparator, std::move( container ) ); 129 | } 130 | } // namespace cereal 131 | 132 | #endif // CEREAL_TYPES_QUEUE_HPP_ 133 | -------------------------------------------------------------------------------- /cereal/details/static_object.hpp: -------------------------------------------------------------------------------- 1 | /*! \file static_object.hpp 2 | \brief Internal polymorphism static object support 3 | \ingroup Internal */ 4 | /* 5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 6 | All rights reserved. 7 | Redistribution and use in source and binary forms, with or without 8 | modification, are permitted provided that the following conditions are met: 9 | * Redistributions of source code must retain the above copyright 10 | notice, this list of conditions and the following disclaimer. 11 | * Redistributions in binary form must reproduce the above copyright 12 | notice, this list of conditions and the following disclaimer in the 13 | documentation and/or other materials provided with the distribution. 14 | * Neither the name of cereal nor the 15 | names of its contributors may be used to endorse or promote products 16 | derived from this software without specific prior written permission. 17 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 18 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 19 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 20 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY 21 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 22 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 23 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 24 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 26 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 | */ 28 | #ifndef CEREAL_DETAILS_STATIC_OBJECT_HPP_ 29 | #define CEREAL_DETAILS_STATIC_OBJECT_HPP_ 30 | 31 | #include "cereal/macros.hpp" 32 | 33 | #if CEREAL_THREAD_SAFE 34 | #include 35 | #endif 36 | 37 | //! Prevent link optimization from removing non-referenced static objects 38 | /*! Especially for polymorphic support, we create static objects which 39 | may not ever be explicitly referenced. Most linkers will detect this 40 | and remove the code causing various unpleasant runtime errors. These 41 | macros, adopted from Boost (see force_include.hpp) prevent this 42 | (C) Copyright 2002 Robert Ramey - http://www.rrsd.com . 43 | Use, modification and distribution is subject to the Boost Software 44 | License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at 45 | http://www.boost.org/LICENSE_1_0.txt) */ 46 | 47 | #ifdef _MSC_VER 48 | # define CEREAL_DLL_EXPORT __declspec(dllexport) 49 | # define CEREAL_USED 50 | #else // clang or gcc 51 | # define CEREAL_DLL_EXPORT __attribute__ ((visibility("default"))) 52 | # define CEREAL_USED __attribute__ ((__used__)) 53 | #endif 54 | 55 | namespace cereal 56 | { 57 | namespace detail 58 | { 59 | //! A static, pre-execution object 60 | /*! This class will create a single copy (singleton) of some 61 | type and ensures that merely referencing this type will 62 | cause it to be instantiated and initialized pre-execution. 63 | For example, this is used heavily in the polymorphic pointer 64 | serialization mechanisms to bind various archive types with 65 | different polymorphic classes */ 66 | template 67 | class CEREAL_DLL_EXPORT StaticObject 68 | { 69 | private: 70 | 71 | static T & create() 72 | { 73 | static T t; 74 | //! Forces instantiation at pre-execution time 75 | (void)instance; 76 | return t; 77 | } 78 | 79 | StaticObject( StaticObject const & /*other*/ ) {} 80 | 81 | public: 82 | static T & getInstance() 83 | { 84 | return create(); 85 | } 86 | 87 | //! A class that acts like std::lock_guard 88 | class LockGuard 89 | { 90 | #if CEREAL_THREAD_SAFE 91 | public: 92 | LockGuard(std::mutex & m) : lock(m) {} 93 | private: 94 | std::unique_lock lock; 95 | #else 96 | public: 97 | LockGuard(LockGuard const &) = default; // prevents implicit copy ctor warning 98 | ~LockGuard() CEREAL_NOEXCEPT {} // prevents variable not used 99 | #endif 100 | }; 101 | 102 | //! Attempts to lock this static object for the current scope 103 | /*! @note This function is a no-op if cereal is not compiled with 104 | thread safety enabled (CEREAL_THREAD_SAFE = 1). 105 | 106 | This function returns an object that holds a lock for 107 | this StaticObject that will release its lock upon destruction. This 108 | call will block until the lock is available. */ 109 | static LockGuard lock() 110 | { 111 | #if CEREAL_THREAD_SAFE 112 | static std::mutex instanceMutex; 113 | return LockGuard{instanceMutex}; 114 | #else 115 | return LockGuard{}; 116 | #endif 117 | } 118 | 119 | private: 120 | static T & instance; 121 | }; 122 | 123 | template T & StaticObject::instance = StaticObject::create(); 124 | } // namespace detail 125 | } // namespace cereal 126 | 127 | #endif // CEREAL_DETAILS_STATIC_OBJECT_HPP_ 128 | -------------------------------------------------------------------------------- /cereal/types/common.hpp: -------------------------------------------------------------------------------- 1 | /*! \file common.hpp 2 | \brief Support common types - always included automatically 3 | \ingroup OtherTypes */ 4 | /* 5 | Copyright (c) 2014, Randolph Voorhies, Shane Grant 6 | All rights reserved. 7 | 8 | Redistribution and use in source and binary forms, with or without 9 | modification, are permitted provided that the following conditions are met: 10 | * Redistributions of source code must retain the above copyright 11 | notice, this list of conditions and the following disclaimer. 12 | * Redistributions in binary form must reproduce the above copyright 13 | notice, this list of conditions and the following disclaimer in the 14 | documentation and/or other materials provided with the distribution. 15 | * Neither the name of cereal nor the 16 | names of its contributors may be used to endorse or promote products 17 | derived from this software without specific prior written permission. 18 | 19 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND 20 | ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 21 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 22 | DISCLAIMED. IN NO EVENT SHALL RANDOLPH VOORHIES OR SHANE GRANT BE LIABLE FOR ANY 23 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 26 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 28 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | */ 30 | #ifndef CEREAL_TYPES_COMMON_HPP_ 31 | #define CEREAL_TYPES_COMMON_HPP_ 32 | 33 | #include "cereal/cereal.hpp" 34 | 35 | namespace cereal 36 | { 37 | namespace common_detail 38 | { 39 | //! Serialization for arrays if BinaryData is supported and we are arithmetic 40 | /*! @internal */ 41 | template inline 42 | void serializeArray( Archive & ar, T & array, std::true_type /* binary_supported */ ) 43 | { 44 | ar( binary_data( array, sizeof(array) ) ); 45 | } 46 | 47 | //! Serialization for arrays if BinaryData is not supported or we are not arithmetic 48 | /*! @internal */ 49 | template inline 50 | void serializeArray( Archive & ar, T & array, std::false_type /* binary_supported */ ) 51 | { 52 | for( auto & i : array ) 53 | ar( i ); 54 | } 55 | 56 | namespace 57 | { 58 | //! Gets the underlying type of an enum 59 | /*! @internal */ 60 | template 61 | struct enum_underlying_type : std::false_type {}; 62 | 63 | //! Gets the underlying type of an enum 64 | /*! Specialization for when we actually have an enum 65 | @internal */ 66 | template 67 | struct enum_underlying_type { using type = typename std::underlying_type::type; }; 68 | } // anon namespace 69 | 70 | //! Checks if a type is an enum 71 | /*! This is needed over simply calling std::is_enum because the type 72 | traits checking at compile time will attempt to call something like 73 | load_minimal with a special NoConvertRef struct that wraps up the true type. 74 | 75 | This will strip away any of that and also expose the true underlying type. 76 | @internal */ 77 | template 78 | class is_enum 79 | { 80 | private: 81 | using DecayedT = typename std::decay::type; 82 | using StrippedT = typename ::cereal::traits::strip_minimal::type; 83 | 84 | public: 85 | static const bool value = std::is_enum::value; 86 | using type = StrippedT; 87 | using base_type = typename enum_underlying_type::type; 88 | }; 89 | } 90 | 91 | //! Saving for enum types 92 | template inline 93 | typename std::enable_if::value, 94 | typename common_detail::is_enum::base_type>::type 95 | CEREAL_SAVE_MINIMAL_FUNCTION_NAME( Archive const &, T const & t ) 96 | { 97 | return static_cast::base_type>(t); 98 | } 99 | 100 | //! Loading for enum types 101 | template inline 102 | typename std::enable_if::value, void>::type 103 | CEREAL_LOAD_MINIMAL_FUNCTION_NAME( Archive const &, T && t, 104 | typename common_detail::is_enum::base_type const & value ) 105 | { 106 | t = reinterpret_cast::type const &>( value ); 107 | } 108 | 109 | //! Serialization for raw pointers 110 | /*! This exists only to throw a static_assert to let users know we don't support raw pointers. */ 111 | template inline 112 | void CEREAL_SERIALIZE_FUNCTION_NAME( Archive &, T * & ) 113 | { 114 | static_assert(cereal::traits::detail::delay_static_assert::value, 115 | "Cereal does not support serializing raw pointers - please use a smart pointer"); 116 | } 117 | 118 | //! Serialization for C style arrays 119 | template inline 120 | typename std::enable_if::value, void>::type 121 | CEREAL_SERIALIZE_FUNCTION_NAME(Archive & ar, T & array) 122 | { 123 | common_detail::serializeArray( ar, array, 124 | std::integral_constant, Archive>::value && 125 | std::is_arithmetic::type>::value>() ); 126 | } 127 | } // namespace cereal 128 | 129 | #endif // CEREAL_TYPES_COMMON_HPP_ 130 | -------------------------------------------------------------------------------- /dialog_gen_data.ui: -------------------------------------------------------------------------------- 1 | 2 | 3 | dialog_gen_data 4 | 5 | 6 | 7 | 0 8 | 0 9 | 400 10 | 300 11 | 12 | 13 | 14 | Dialog 15 | 16 | 17 | 18 | 19 | 10 20 | 30 21 | 381 22 | 16 23 | 24 | 25 | 26 | 请输入数据生成所需的以下的数据 27 | 28 | 29 | Qt::AlignCenter 30 | 31 | 32 | 33 | 34 | 35 | 90 36 | 70 37 | 271 38 | 31 39 | 40 | 41 | 42 | 43 | 0 44 | 0 45 | 46 | 47 | 48 | 49 | 50 | false 51 | 52 | 53 | 54 | 90 55 | 120 56 | 271 57 | 31 58 | 59 | 60 | 61 | ForbiddenCursor 62 | 63 | 64 | 根目录 65 | 66 | 67 | 68 | 69 | 70 | 10 71 | 70 72 | 71 73 | 31 74 | 75 | 76 | 77 | 文件名 78 | 79 | 80 | Qt::AlignCenter 81 | 82 | 83 | 84 | 85 | 86 | 10 87 | 120 88 | 71 89 | 31 90 | 91 | 92 | 93 | 文件位置 94 | 95 | 96 | Qt::AlignCenter 97 | 98 | 99 | 100 | 101 | 102 | 10 103 | 170 104 | 71 105 | 31 106 | 107 | 108 | 109 | 文件内容 110 | 111 | 112 | Qt::AlignCenter 113 | 114 | 115 | 116 | 117 | false 118 | 119 | 120 | 121 | 120 122 | 220 123 | 86 124 | 31 125 | 126 | 127 | 128 | 文件 129 | 130 | 131 | true 132 | 133 | 134 | true 135 | 136 | 137 | false 138 | 139 | 140 | 141 | 142 | false 143 | 144 | 145 | 146 | 230 147 | 220 148 | 86 149 | 31 150 | 151 | 152 | 153 | 文件夹 154 | 155 | 156 | false 157 | 158 | 159 | 160 | 161 | 162 | 10 163 | 220 164 | 71 165 | 31 166 | 167 | 168 | 169 | 文件类型 170 | 171 | 172 | Qt::AlignCenter 173 | 174 | 175 | 176 | 177 | 178 | 150 179 | 260 180 | 112 181 | 32 182 | 183 | 184 | 185 | 提交 186 | 187 | 188 | 189 | 190 | 191 | 90 192 | 170 193 | 231 194 | 31 195 | 196 | 197 | 198 | 199 | 0 200 | 0 201 | 202 | 203 | 204 | 96 205 | 206 | 207 | 208 | 209 | 210 | 330 211 | 175 212 | 41 213 | 21 214 | 215 | 216 | 217 | 218 | 219 | 220 | Qt::AlignCenter 221 | 222 | 223 | 224 | 225 | 226 | 227 | --------------------------------------------------------------------------------