6#include "libxr_def.hpp"
7#include "libxr_mem.hpp"
8#include "libxr_type.hpp"
50 template <
typename Data>
78 [[maybe_unused]]
const auto add_result = database.Add(*
this);
104 [[maybe_unused]]
const auto add_result = database.Add(*
this);
键的基类,存储键名及其数据 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 da...
数据库接口,提供键值存储和管理功能 Database interface providing key-value storage and management.
static void FastSet(void *dst, uint8_t value, size_t size)
快速内存填充 / Fast memory fill
可写原始数据视图 / Mutable raw data view
LibXR 命名空间 / LibXR namespace.
ErrorCode
定义错误码枚举 / Defines an enumeration for error codes
@ NOT_FOUND
未找到 / Not found
@ OK
操作成功 / Operation successful
static constexpr uint16_t LIBXR_DATABASE_VERSION
数据库存储格式版本号 Database storage-format version.