⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 book.h

📁 一个帮助你学习英语的软件~~很不错的咯~~ 对功能又做了改进~大家支持下哈~
💻 H
字号:
//PK 2006/08/29 - 2007/03/10
#pragma once

#include "global.h"
#include <rpc.h>

const int BOOK_NAME_MAX_LEN = 128;
const int CONTRIBUTOR_NAME_MAX_LEN = 32;

//PK for UUID's serialization
namespace boost {
	namespace serialization {
		template<class Archive>
		void serialize(Archive & ar, UUID & id, const unsigned int version)
		{
			ar & id.Data1;
			ar & id.Data2;
			ar & id.Data3;
			ar & id.Data4;
		}
	}
}

class CRecords;
class CItem;

class CBook
{
public:
	typedef vector<CItem *> t_items;

	CBook();
	~CBook();

	bool add_item(CItem * item);
	bool delete_item(unsigned int id);
	bool delete_item(CItem * item);
	bool delete_self();

	bool load(const fs::path & dir);	//PK load all items from the directory
	bool save();	//PK when make modifications, call this method will save them.

	unsigned int size() { return _items.size(); }
	
	CRecords & recorder() { return *_recorders; }
	const fs::path & dir() { return _dir; }
	void dir(const fs::path & dir) { _dir = dir; }
	const string & get_book_id() {  assert(!_id_str.empty()); return _id_str; }

	bool is_active() { return _is_active; }
	void set_active(bool b) { _is_active = b; }

	CItem * get_item(const string title);
	CItem * get_item(unsigned int index);

	void dirty();

	const string & book_name() { return _book_name; }
	void book_name(const string & name) { _book_name = name; }
	void book_info_changed(const string & name, const string & contributor);
	const string & contributor() { return _contributor; }

	bool is_recorders_matched();
	void trim_recorders();
	void change_record_name(const string & src, const string & tar);

private:
	//PK the object cannot be copyed
	CBook(const CBook &);
	const CBook & operator = (const CBook &);

	void _clear_items();
	bool _load_info();
	bool _save_info();
	bool _load_items();
	bool _load_records();
	bool _restore_item_info();	//PK restore the item's info from records
	string _id2str(UUID & id);

	fs::path _dir;
	UUID _id;
	string _id_str;
	string _book_name;
	string _contributor;
	t_items _items;
	CRecords * _recorders;
	bool _is_active;
};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -