6#include "libxr_def.hpp"
7#include "libxr_mem.hpp"
8#include "libxr_type.hpp"
50 template <
typename Data>
键的基类,存储键名及其数据 (Base class for keys, storing key name and associated data).
RawData raw_data_
原始数据 (Raw data associated with the key).
KeyBase(const char *name, RawData raw_data)
构造函数,初始化键名和原始数据 (Constructor to initialize key name and raw data).
const char * name_
键名 (Key name).
模板类,表示数据库中的具体键 (Template class representing a specific key in the database).
Database & database_
关联的数据库对象 (Reference to the associated database).
ErrorCode Save()
保存当前键值到数据库 (Save the current key value to the database).
ErrorCode Set(Data data)
设置键的值并更新数据库 (Set the key's value and update the database).
Key & operator=(const Key &other)=delete
禁止拷贝赋值数据库键对象 (Copy assignment is disabled for database keys).
Key(Database &database, const char *name, Data init_value)
构造函数,初始化键并从数据库加载数据 (Constructor to initialize key and load data from the database).
Data data_
键存储的数据 (The data stored in the key).
ErrorCode operator=(Data data)
赋值运算符,设置键的值 (Assignment operator to set the key's value).
Key(Key &&other)=delete
禁止移动数据库键对象 (Move construction is disabled for database keys).
Key & operator=(Key &&other)=delete
禁止移动赋值数据库键对象 (Move assignment is disabled for database keys).
ErrorCode Load()
从数据库加载键的值 (Load the key's value from the database).
Key(const Key &other)=delete
禁止拷贝数据库键对象 (Copy construction is disabled for database keys).
Key(Database &database, const char *name)
构造函数,初始化键,并在数据库不存在时赋默认值 (Constructor to initialize key, assigning default value if not found in the d...
数据库接口,提供键值存储和管理功能 (Database interface providing key-value storage and management).
virtual ErrorCode Add(KeyBase &key)=0
添加新键到数据库 (Add a new key to the database).
virtual ErrorCode Get(KeyBase &key)=0
从数据库获取键的值 (Retrieve the key's value from the database).
virtual ErrorCode Set(KeyBase &key, RawData data)=0
设置数据库中的键值 (Set the key's value in the database).
static void FastSet(void *dst, uint8_t value, size_t size)
快速内存填充 / Fast memory fill
可写原始数据视图 / Mutable raw data view
@ NOT_FOUND
未找到 | Not found
@ OK
操作成功 | Operation successful
static constexpr uint16_t LIBXR_DATABASE_VERSION
数据库存储格式版本号 (Database storage-format version).