Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: TYBLE16_simple_data_logger TYBLE16_MP3_Air
TDBStore Class Reference
#include <TDBStore.h>
Inherits mbed::KVStore.
Public Types | |
typedef struct mbed::KVStore::info | info_t |
Holds key information. | |
Public Member Functions | |
TDBStore (BlockDevice *bd) | |
Class constructor. | |
virtual | ~TDBStore () |
Class destructor. | |
virtual int | init () |
Initialize TDBStore. | |
virtual int | deinit () |
Deinitialize TDBStore, release and free resources. | |
virtual int | reset () |
Reset TDBStore contents (clear all keys) and reserved data. | |
virtual int | set (const char *key, const void *buffer, size_t size, uint32_t create_flags) |
Set one TDBStore item, given key and value. | |
virtual int | get (const char *key, void *buffer, size_t buffer_size, size_t *actual_size=NULL, size_t offset=0) |
Get one TDBStore item by given key. | |
virtual int | get_info (const char *key, info_t *info) |
Get information of a given key. | |
virtual int | remove (const char *key) |
Remove a TDBStore item by given key. | |
virtual int | set_start (set_handle_t *handle, const char *key, size_t final_data_size, uint32_t create_flags) |
Start an incremental TDBStore set sequence. | |
virtual int | set_add_data (set_handle_t handle, const void *value_data, size_t data_size) |
Add data to incremental TDBStore set sequence. | |
virtual int | set_finalize (set_handle_t handle) |
Finalize an incremental KVStore set sequence. | |
virtual int | iterator_open (iterator_t *it, const char *prefix=NULL) |
Start an iteration over KVStore keys. | |
virtual int | iterator_next (iterator_t it, char *key, size_t key_size) |
Get next key in iteration. | |
virtual int | iterator_close (iterator_t it) |
Close iteration. | |
virtual int | reserved_data_set (const void *reserved_data, size_t reserved_data_buf_size) |
Set data in reserved area, which is a special location for special data, such as ROT. | |
virtual int | reserved_data_get (void *reserved_data, size_t reserved_data_buf_size, size_t *actual_data_size=0) |
Get data from reserved area, which is a special location for special data, such as ROT. | |
bool | is_valid_key (const char *key) const |
Convenience function for checking key validity. |
Detailed Description
TDBStore class.
Lightweight Key Value storage over a block device
Definition at line 35 of file TDBStore.h.
Member Typedef Documentation
typedef struct mbed::KVStore::info info_t [inherited] |
Holds key information.
Constructor & Destructor Documentation
TDBStore | ( | BlockDevice * | bd ) |
Class constructor.
- Parameters:
-
[in] bd Underlying block device. The BlockDevice can be any BlockDevice with flash characteristics. If using a BlockDevice without flash, such as SDBlockDevice, please add the FlashSimBlockDevice on top of it.
- Returns:
- none
Definition at line 124 of file TDBStore.cpp.
~TDBStore | ( | ) | [virtual] |
Member Function Documentation
int deinit | ( | ) | [virtual] |
Deinitialize TDBStore, release and free resources.
- Returns:
- MBED_SUCCESS Success.
Implements KVStore.
Definition at line 1121 of file TDBStore.cpp.
int get | ( | const char * | key, |
void * | buffer, | ||
size_t | buffer_size, | ||
size_t * | actual_size = NULL , |
||
size_t | offset = 0 |
||
) | [virtual] |
Get one TDBStore item by given key.
- Parameters:
-
[in] key Key - must not include '*' '/' '?' ':' ';' '\' '"' '|' ' ' '<' '>' '\'. [in] buffer Value data buffer. [in] buffer_size Value data buffer size. [out] actual_size Actual read size. [in] offset Offset to read from in data.
- Returns:
- MBED_SUCCESS Success. MBED_ERROR_NOT_READY Not initialized. MBED_ERROR_READ_FAILED Unable to read from media. MBED_ERROR_INVALID_ARGUMENT Invalid argument given in function arguments. MBED_ERROR_INVALID_SIZE Invalid size given in function arguments. MBED_ERROR_INVALID_DATA_DETECTED Data is corrupt. MBED_ERROR_ITEM_NOT_FOUND No such key.
Implements KVStore.
Definition at line 717 of file TDBStore.cpp.
int get_info | ( | const char * | key, |
info_t * | info | ||
) | [virtual] |
Get information of a given key.
The returned info contains size and flags
- Parameters:
-
[in] key Key - must not include '*' '/' '?' ':' ';' '\' '"' '|' ' ' '<' '>' '\'. [out] info Returned information structure.
- Returns:
- MBED_SUCCESS Success. MBED_ERROR_NOT_READY Not initialized. MBED_ERROR_READ_FAILED Unable to read from media. MBED_ERROR_INVALID_ARGUMENT Invalid argument given in function arguments. MBED_ERROR_INVALID_DATA_DETECTED Data is corrupt. MBED_ERROR_ITEM_NOT_FOUND No such key.
Implements KVStore.
Definition at line 748 of file TDBStore.cpp.
int init | ( | ) | [virtual] |
Initialize TDBStore.
If data exists, TDBStore will check the data integrity on initialize. If the integrity checks fails, the TDBStore will use GC to collect the available data and clean corrupted and erroneous records.
- Returns:
- MBED_SUCCESS Success.
- Negative error code on failure.
Implements KVStore.
Definition at line 987 of file TDBStore.cpp.
bool is_valid_key | ( | const char * | key ) | const [inherited] |
int iterator_close | ( | iterator_t | it ) | [virtual] |
Close iteration.
- Parameters:
-
[in] it Iterator handle.
- Returns:
- MBED_SUCCESS Success. MBED_ERROR_NOT_READY Not initialized. MBED_ERROR_INVALID_ARGUMENT Invalid argument given in function arguments.
Implements KVStore.
Definition at line 1274 of file TDBStore.cpp.
int iterator_next | ( | iterator_t | it, |
char * | key, | ||
size_t | key_size | ||
) | [virtual] |
Get next key in iteration.
There are no issues with any other operations while iterator is open.
- Parameters:
-
[in] it Iterator handle. [in] key Buffer for returned key. [in] key_size Key buffer size.
- Returns:
- MBED_SUCCESS Success. MBED_ERROR_NOT_READY Not initialized. MBED_ERROR_READ_FAILED Unable to read from block device. MBED_ERROR_INVALID_ARGUMENT Invalid argument given in function arguments. MBED_ERROR_INVALID_SIZE Invalid size given in function arguments. MBED_ERROR_INVALID_DATA_DETECTED Data is corrupt. MBED_ERROR_ITEM_NOT_FOUND No more keys found.
Implements KVStore.
Definition at line 1234 of file TDBStore.cpp.
int iterator_open | ( | iterator_t * | it, |
const char * | prefix = NULL |
||
) | [virtual] |
Start an iteration over KVStore keys.
There are no issues with any other operations while iterator is open.
- Parameters:
-
[out] it Returned iterator handle. [in] prefix Key prefix (null for all keys).
- Returns:
- MBED_SUCCESS Success. MBED_ERROR_NOT_READY Not initialized. MBED_ERROR_INVALID_ARGUMENT Invalid argument given in function arguments.
Implements KVStore.
Definition at line 1189 of file TDBStore.cpp.
int remove | ( | const char * | key ) | [virtual] |
Remove a TDBStore item by given key.
- Parameters:
-
[in] key Key - must not include '*' '/' '?' ':' ';' '\' '"' '|' ' ' '<' '>' '\'.
- Returns:
- MBED_SUCCESS Success. MBED_ERROR_NOT_READY Not initialized. MBED_ERROR_READ_FAILED Unable to read from media. MBED_ERROR_WRITE_FAILED Unable to write to media. MBED_ERROR_INVALID_ARGUMENT Invalid argument given in function arguments. MBED_ERROR_MEDIA_FULL Not enough room on media. MBED_ERROR_ITEM_NOT_FOUND No such key. MBED_ERROR_WRITE_PROTECTED Already stored with "write once" flag.
Implements KVStore.
Definition at line 712 of file TDBStore.cpp.
int reserved_data_get | ( | void * | reserved_data, |
size_t | reserved_data_buf_size, | ||
size_t * | actual_data_size = 0 |
||
) | [virtual] |
Get data from reserved area, which is a special location for special data, such as ROT.
- Parameters:
-
[in] reserved_data Reserved data buffer. [in] reserved_data_buf_size Reserved data buffer size. [in] actual_data_size Return data size.
- Returns:
- MBED_SUCCESS Success. MBED_ERROR_NOT_READY Not initialized. MBED_ERROR_READ_FAILED Unable to read from media. MBED_ERROR_INVALID_ARGUMENT Invalid argument given in function arguments. MBED_ERROR_INVALID_DATA_DETECTED Data is corrupt. MBED_ERROR_ITEM_NOT_FOUND No reserved data was written.
Definition at line 1417 of file TDBStore.cpp.
int reserved_data_set | ( | const void * | reserved_data, |
size_t | reserved_data_buf_size | ||
) | [virtual] |
Set data in reserved area, which is a special location for special data, such as ROT.
The data written to reserved area can't be overwritten.
- Parameters:
-
[in] reserved_data Reserved data buffer. [in] reserved_data_buf_size Reserved data buffer size.
- Returns:
- MBED_SUCCESS Success. MBED_ERROR_NOT_READY Not initialized. MBED_ERROR_READ_FAILED Unable to read from media. MBED_ERROR_WRITE_FAILED Unable to write to media. MBED_ERROR_INVALID_ARGUMENT Invalid argument given in function arguments. MBED_ERROR_INVALID_SIZE Invalid size given in function arguments.
Definition at line 1314 of file TDBStore.cpp.
int reset | ( | void | ) | [virtual] |
Reset TDBStore contents (clear all keys) and reserved data.
- Returns:
- MBED_SUCCESS Success. MBED_ERROR_NOT_READY Not initialized. MBED_ERROR_READ_FAILED Unable to read from media. MBED_ERROR_WRITE_FAILED Unable to write to media.
Implements KVStore.
Definition at line 1157 of file TDBStore.cpp.
int set | ( | const char * | key, |
const void * | buffer, | ||
size_t | size, | ||
uint32_t | create_flags | ||
) | [virtual] |
Set one TDBStore item, given key and value.
- Parameters:
-
[in] key Key - must not include '*' '/' '?' ':' ';' '\' '"' '|' ' ' '<' '>' '\'. [in] buffer Value data buffer. [in] size Value data size. [in] create_flags Flag mask.
- Returns:
- MBED_SUCCESS Success. MBED_ERROR_NOT_READY Not initialized. MBED_ERROR_READ_FAILED Unable to read from media. MBED_ERROR_WRITE_FAILED Unable to write to media. MBED_ERROR_INVALID_ARGUMENT Invalid argument given in function arguments. MBED_ERROR_INVALID_SIZE Invalid size given in function arguments. MBED_ERROR_MEDIA_FULL Not enough room on media. MBED_ERROR_WRITE_PROTECTED Already stored with "write once" flag.
Implements KVStore.
Definition at line 688 of file TDBStore.cpp.
int set_add_data | ( | set_handle_t | handle, |
const void * | value_data, | ||
size_t | data_size | ||
) | [virtual] |
Add data to incremental TDBStore set sequence.
This operation is blocking other operations. Any get/set/remove operation will be blocked until set_finalize will be called.
- Parameters:
-
[in] handle Incremental set handle. [in] value_data Value data to add. [in] data_size Value data size.
- Returns:
- MBED_SUCCESS Success. MBED_ERROR_NOT_READY Not initialized. MBED_ERROR_WRITE_FAILED Unable to write to media. MBED_ERROR_INVALID_ARGUMENT Invalid argument given in function arguments. MBED_ERROR_INVALID_SIZE Invalid size given in function arguments.
Implements KVStore.
Definition at line 534 of file TDBStore.cpp.
int set_finalize | ( | set_handle_t | handle ) | [virtual] |
Finalize an incremental KVStore set sequence.
- Parameters:
-
[in] handle Incremental set handle.
- Returns:
- MBED_SUCCESS Success. MBED_ERROR_NOT_READY Not initialized. MBED_ERROR_WRITE_FAILED Unable to write to media. MBED_ERROR_INVALID_ARGUMENT Invalid argument given in function arguments.
Implements KVStore.
Definition at line 583 of file TDBStore.cpp.
int set_start | ( | set_handle_t * | handle, |
const char * | key, | ||
size_t | final_data_size, | ||
uint32_t | create_flags | ||
) | [virtual] |
Start an incremental TDBStore set sequence.
This operation is blocking other operations. Any get/set/remove/iterator operation will be blocked until set_finalize is called.
- Parameters:
-
[out] handle Returned incremental set handle. [in] key Key - must not include '*' '/' '?' ':' ';' '\' '"' '|' ' ' '<' '>' '\'. [in] final_data_size Final value data size. [in] create_flags Flag mask.
- Returns:
- MBED_SUCCESS Success. MBED_ERROR_NOT_READY Not initialized. MBED_ERROR_READ_FAILED Unable to read from media. MBED_ERROR_WRITE_FAILED Unable to write to media. MBED_ERROR_INVALID_ARGUMENT Invalid argument given in function arguments. MBED_ERROR_INVALID_SIZE Invalid size given in function arguments. MBED_ERROR_MEDIA_FULL Not enough room on media. MBED_ERROR_WRITE_PROTECTED Already stored with "write once" flag.
Implements KVStore.
Definition at line 410 of file TDBStore.cpp.
Generated on Tue Jul 12 2022 13:55:43 by
