libxr  1.0
Want to be the best embedded framework
Loading...
Searching...
No Matches
LibXR::DatabaseRaw< MinWriteSize >::KeyInfo Struct Reference

键信息结构,存储键的元数据 (Structure containing key metadata). More...

Collaboration diagram for LibXR::DatabaseRaw< MinWriteSize >::KeyInfo:
[legend]

Public Member Functions

 KeyInfo ()
 构造一个默认可写的键头元数据 (Construct one default writable key-header metadata object).
 
void SetNameLength (uint8_t len)
 设置键名长度 (Set the key name length).
 
uint8_t GetNameLength () const
 获取键名长度 (Get the key name length).
 
void SetDataSize (uint32_t size)
 设置数据字节数 (Set the payload size in bytes).
 
uint32_t GetDataSize () const
 获取数据字节数 (Get the payload size in bytes).
 

Data Fields

BlockBoolData< MinWriteSize > no_next_key
 是否是最后一个键
 
BlockBoolData< MinWriteSize > available_flag
 该键是否有效
 
BlockBoolData< MinWriteSize > uninit
 该键是否未初始化
 
uint32_t raw_info = 0
 

Detailed Description

template<size_t MinWriteSize>
struct LibXR::DatabaseRaw< MinWriteSize >::KeyInfo

键信息结构,存储键的元数据 (Structure containing key metadata).

Definition at line 106 of file raw.hpp.

Constructor & Destructor Documentation

◆ KeyInfo()

template<size_t MinWriteSize>
LibXR::DatabaseRaw< MinWriteSize >::KeyInfo::KeyInfo ( )
inline

构造一个默认可写的键头元数据 (Construct one default writable key-header metadata object).

Definition at line 119 of file raw.hpp.

Member Function Documentation

◆ GetDataSize()

template<size_t MinWriteSize>
uint32_t LibXR::DatabaseRaw< MinWriteSize >::KeyInfo::GetDataSize ( ) const
inline

获取数据字节数 (Get the payload size in bytes).

Returns
数据字节数 (Payload size in bytes).

Definition at line 154 of file raw.hpp.

163{
164
188template <size_t MinWriteSize>
189class DatabaseRaw : public Database
190{
200 static constexpr uint32_t FLASH_HEADER =
201 0x12345678 + LIBXR_DATABASE_VERSION;
202
211 static constexpr uint32_t CHECKSUM_BYTE = 0x9abcedf0;
212
213 // 存储布局定义:块角色、位图编码、键头与块头。
214 // Storage layout definitions: block roles, bitmap encodings, key headers,
215 // and block headers.
216#include "layout.hpp"
217
222 size_t recycle_threshold_ = 0;
223
228 Flash& flash_;
229
234 uint32_t block_size_;
235
244 uint8_t write_buffer_[MinWriteSize];
245
246 // 底层 Flash 读写辅助:按最小写入单元对齐、补齐、复制。
247 // Low-level Flash I/O helpers: minimum-write-unit alignment, tail padding,
248 // and raw copying.
249#include "flash_io.hpp"
250
251 // 块级语义:初始化、校验、失效、已用空间计算和块间复制。
252 // Block-level semantics: initialization, validation, invalidation,
253 // used-space accounting, and block-to-block copying.
254#include "block_ops.hpp"
255
256 // 键级语义:查找、追加、逻辑更新、条目地址计算。
257 // Key-level semantics: lookup, append, logical replacement, and entry
258 // address calculations.
259#include "key_ops.hpp"
260
265 public:
266 // 对外生命周期与主流程:构造、初始化、读写、恢复、回收。
267 // Public lifecycle and main flow: construction, initialization, read/write,
268 // restore, and recycle.
269#include "lifecycle.hpp"
270};
271
272} // namespace LibXR
DatabaseRaw(Flash &flash, size_t recycle_threshold=128)
构造函数,初始化 Flash 存储和缓冲区 (Constructor to initialize Flash storage and buffer).
Definition raw.hpp:71

◆ GetNameLength()

template<size_t MinWriteSize>
uint8_t LibXR::DatabaseRaw< MinWriteSize >::KeyInfo::GetNameLength ( ) const
inline

获取键名长度 (Get the key name length).

Returns
键名长度 (Key name length).

Definition at line 139 of file raw.hpp.

148{
149
173template <size_t MinWriteSize>
174class DatabaseRaw : public Database
175{
185 static constexpr uint32_t FLASH_HEADER =
186 0x12345678 + LIBXR_DATABASE_VERSION;
187
196 static constexpr uint32_t CHECKSUM_BYTE = 0x9abcedf0;
197
198 // 存储布局定义:块角色、位图编码、键头与块头。
199 // Storage layout definitions: block roles, bitmap encodings, key headers,
200 // and block headers.
201#include "layout.hpp"
202
207 size_t recycle_threshold_ = 0;
208
213 Flash& flash_;
214
219 uint32_t block_size_;
220
229 uint8_t write_buffer_[MinWriteSize];
230
231 // 底层 Flash 读写辅助:按最小写入单元对齐、补齐、复制。
232 // Low-level Flash I/O helpers: minimum-write-unit alignment, tail padding,
233 // and raw copying.
234#include "flash_io.hpp"
235
236 // 块级语义:初始化、校验、失效、已用空间计算和块间复制。
237 // Block-level semantics: initialization, validation, invalidation,
238 // used-space accounting, and block-to-block copying.
239#include "block_ops.hpp"
240
241 // 键级语义:查找、追加、逻辑更新、条目地址计算。
242 // Key-level semantics: lookup, append, logical replacement, and entry
243 // address calculations.
244#include "key_ops.hpp"
245
250 public:
251 // 对外生命周期与主流程:构造、初始化、读写、恢复、回收。
252 // Public lifecycle and main flow: construction, initialization, read/write,
253 // restore, and recycle.
254#include "lifecycle.hpp"
255};
256
257} // namespace LibXR

◆ SetDataSize()

template<size_t MinWriteSize>
void LibXR::DatabaseRaw< MinWriteSize >::KeyInfo::SetDataSize ( uint32_t size)
inline

设置数据字节数 (Set the payload size in bytes).

Parameters
size数据字节数 (Payload size in bytes).

Definition at line 145 of file raw.hpp.

154{
155
179template <size_t MinWriteSize>
180class DatabaseRaw : public Database
181{
191 static constexpr uint32_t FLASH_HEADER =
192 0x12345678 + LIBXR_DATABASE_VERSION;
193
202 static constexpr uint32_t CHECKSUM_BYTE = 0x9abcedf0;
203
204 // 存储布局定义:块角色、位图编码、键头与块头。
205 // Storage layout definitions: block roles, bitmap encodings, key headers,
206 // and block headers.
207#include "layout.hpp"
208
213 size_t recycle_threshold_ = 0;
214
219 Flash& flash_;
220
225 uint32_t block_size_;
226
235 uint8_t write_buffer_[MinWriteSize];
236
237 // 底层 Flash 读写辅助:按最小写入单元对齐、补齐、复制。
238 // Low-level Flash I/O helpers: minimum-write-unit alignment, tail padding,
239 // and raw copying.
240#include "flash_io.hpp"
241
242 // 块级语义:初始化、校验、失效、已用空间计算和块间复制。
243 // Block-level semantics: initialization, validation, invalidation,
244 // used-space accounting, and block-to-block copying.
245#include "block_ops.hpp"
246
247 // 键级语义:查找、追加、逻辑更新、条目地址计算。
248 // Key-level semantics: lookup, append, logical replacement, and entry
249 // address calculations.
250#include "key_ops.hpp"
251
256 public:
257 // 对外生命周期与主流程:构造、初始化、读写、恢复、回收。
258 // Public lifecycle and main flow: construction, initialization, read/write,
259 // restore, and recycle.
260#include "lifecycle.hpp"
261};
262
263} // namespace LibXR

◆ SetNameLength()

template<size_t MinWriteSize>
void LibXR::DatabaseRaw< MinWriteSize >::KeyInfo::SetNameLength ( uint8_t len)
inline

设置键名长度 (Set the key name length).

Parameters
len键名长度 (Key name length).

Definition at line 130 of file raw.hpp.

139{
140
164template <size_t MinWriteSize>
165class DatabaseRaw : public Database
166{
176 static constexpr uint32_t FLASH_HEADER =
177 0x12345678 + LIBXR_DATABASE_VERSION;
178
187 static constexpr uint32_t CHECKSUM_BYTE = 0x9abcedf0;
188
189 // 存储布局定义:块角色、位图编码、键头与块头。
190 // Storage layout definitions: block roles, bitmap encodings, key headers,
191 // and block headers.
192#include "layout.hpp"
193
198 size_t recycle_threshold_ = 0;
199
204 Flash& flash_;
205
210 uint32_t block_size_;
211
220 uint8_t write_buffer_[MinWriteSize];
221
222 // 底层 Flash 读写辅助:按最小写入单元对齐、补齐、复制。
223 // Low-level Flash I/O helpers: minimum-write-unit alignment, tail padding,
224 // and raw copying.
225#include "flash_io.hpp"
226
227 // 块级语义:初始化、校验、失效、已用空间计算和块间复制。
228 // Block-level semantics: initialization, validation, invalidation,
229 // used-space accounting, and block-to-block copying.
230#include "block_ops.hpp"
231
232 // 键级语义:查找、追加、逻辑更新、条目地址计算。
233 // Key-level semantics: lookup, append, logical replacement, and entry
234 // address calculations.
235#include "key_ops.hpp"
236
241 public:
242 // 对外生命周期与主流程:构造、初始化、读写、恢复、回收。
243 // Public lifecycle and main flow: construction, initialization, read/write,
244 // restore, and recycle.
245#include "lifecycle.hpp"
246};
247
248} // namespace LibXR

Field Documentation

◆ available_flag

template<size_t MinWriteSize>
BlockBoolData<MinWriteSize> LibXR::DatabaseRaw< MinWriteSize >::KeyInfo::available_flag

该键是否有效

Definition at line 109 of file raw.hpp.

◆ no_next_key

template<size_t MinWriteSize>
BlockBoolData<MinWriteSize> LibXR::DatabaseRaw< MinWriteSize >::KeyInfo::no_next_key

是否是最后一个键

Definition at line 108 of file raw.hpp.

◆ raw_info

template<size_t MinWriteSize>
uint32_t LibXR::DatabaseRaw< MinWriteSize >::KeyInfo::raw_info = 0

高 7 位保存 nameLength,低 25 位保存 dataSize。 Upper 7 bits store nameLength and lower 25 bits store dataSize.

Definition at line 112 of file raw.hpp.

◆ uninit

template<size_t MinWriteSize>
BlockBoolData<MinWriteSize> LibXR::DatabaseRaw< MinWriteSize >::KeyInfo::uninit

该键是否未初始化

Definition at line 110 of file raw.hpp.


The documentation for this struct was generated from the following file: