Mbed OS Reference
Loading...
Searching...
No Matches
KVStore Class Referenceabstract

KVStore class. More...

#include <KVStore.h>

Inheritance diagram for KVStore:
FileSystemStore SecureStore TDBStore

Data Structures

struct  info
 Holds key information. More...
 

Public Types

typedef struct mbed::KVStore::info info_t
 Holds key information. More...
 

Public Member Functions

virtual int init ()=0
 Initialize KVStore. More...
 
virtual int deinit ()=0
 Deinitialize KVStore. More...
 
virtual int reset ()=0
 Reset KVStore contents (clear all keys) More...
 
virtual int set (const char *key, const void *buffer, size_t size, uint32_t create_flags)=0
 Set one KVStore item, given key and value. More...
 
virtual int get (const char *key, void *buffer, size_t buffer_size, size_t *actual_size=NULL, size_t offset=0)=0
 Get one KVStore item, given key. More...
 
virtual int get_info (const char *key, info_t *info=NULL)=0
 Get information of a given key. More...
 
virtual int remove (const char *key)=0
 Remove a KVStore item, given key. More...
 
virtual int set_start (set_handle_t *handle, const char *key, size_t final_data_size, uint32_t create_flags)=0
 Start an incremental KVStore set sequence. More...
 
virtual int set_add_data (set_handle_t handle, const void *value_data, size_t data_size)=0
 Add data to incremental KVStore set sequence. More...
 
virtual int set_finalize (set_handle_t handle)=0
 Finalize an incremental KVStore set sequence. More...
 
virtual int iterator_open (iterator_t *it, const char *prefix=NULL)=0
 Start an iteration over KVStore keys. More...
 
virtual int iterator_next (iterator_t it, char *key, size_t key_size)=0
 Get next key in iteration. More...
 
virtual int iterator_close (iterator_t it)=0
 Close iteration. More...
 
bool is_valid_key (const char *key) const
 Convenience function for checking key validity. More...
 

Detailed Description

KVStore class.

Interface class for all Key Value Storage providers.

Definition at line 38 of file KVStore.h.

Member Typedef Documentation

◆ info_t

typedef struct mbed::KVStore::info info_t

Holds key information.

Member Function Documentation

◆ init()

virtual int init ( )
pure virtual

Initialize KVStore.

Returns
MBED_SUCCESS on success or an error code on failure

Implemented in FileSystemStore, SecureStore, and TDBStore.

◆ deinit()

virtual int deinit ( )
pure virtual

Deinitialize KVStore.

Returns
MBED_SUCCESS on success or an error code on failure

Implemented in FileSystemStore, SecureStore, and TDBStore.

◆ reset()

virtual int reset ( )
pure virtual

Reset KVStore contents (clear all keys)

Returns
MBED_SUCCESS on success or an error code on failure

Implemented in FileSystemStore, SecureStore, and TDBStore.

◆ set()

virtual int set ( const char *  key,
const void *  buffer,
size_t  size,
uint32_t  create_flags 
)
pure virtual

Set one KVStore item, given key and value.

Parameters
[in]keyKey - must not include '*' '/' '?' ':' ';' '\' '"' '|' ' ' '<' '>' '\'.
[in]bufferValue data buffer.
[in]sizeValue data size.
[in]create_flagsFlag mask.
Returns
MBED_SUCCESS on success or an error code on failure

Implemented in FileSystemStore, SecureStore, and TDBStore.

◆ get()

virtual int get ( const char *  key,
void *  buffer,
size_t  buffer_size,
size_t *  actual_size = NULL,
size_t  offset = 0 
)
pure virtual

Get one KVStore item, given key.

Parameters
[in]keyKey - must not include '*' '/' '?' ':' ';' '\' '"' '|' ' ' '<' '>' '\'.
[in]bufferValue data buffer.
[in]buffer_sizeValue data buffer size.
[out]actual_sizeActual read size (NULL to pass nothing).
[in]offsetOffset to read from in data.
Returns
MBED_SUCCESS on success or an error code on failure

Implemented in FileSystemStore, SecureStore, and TDBStore.

◆ get_info()

virtual int get_info ( const char *  key,
info_t info = NULL 
)
pure virtual

Get information of a given key.

Parameters
[in]keyKey - must not include '*' '/' '?' ':' ';' '\' '"' '|' ' ' '<' '>' '\'.
[out]infoReturned information structure (NULL to pass nothing).
Returns
MBED_SUCCESS on success or an error code on failure

Implemented in FileSystemStore, SecureStore, and TDBStore.

◆ remove()

virtual int remove ( const char *  key)
pure virtual

Remove a KVStore item, given key.

Parameters
[in]keyKey - must not include '*' '/' '?' ':' ';' '\' '"' '|' ' ' '<' '>' '\'.
Returns
MBED_SUCCESS on success or an error code on failure

Implemented in FileSystemStore, SecureStore, and TDBStore.

◆ set_start()

virtual int set_start ( set_handle_t *  handle,
const char *  key,
size_t  final_data_size,
uint32_t  create_flags 
)
pure virtual

Start an incremental KVStore set sequence.

Parameters
[out]handleReturned incremental set handle.
[in]keyKey - must not include '*' '/' '?' ':' ';' '\' '"' '|' ' ' '<' '>' '\'.
[in]final_data_sizeFinal value data size.
[in]create_flagsFlag mask.
Returns
MBED_SUCCESS on success or an error code on failure

Implemented in FileSystemStore, SecureStore, and TDBStore.

◆ set_add_data()

virtual int set_add_data ( set_handle_t  handle,
const void *  value_data,
size_t  data_size 
)
pure virtual

Add data to incremental KVStore set sequence.

Parameters
[in]handleIncremental set handle.
[in]value_dataValue data to add.
[in]data_sizeValue data size.
Returns
MBED_SUCCESS on success or an error code on failure

Implemented in FileSystemStore, SecureStore, and TDBStore.

◆ set_finalize()

virtual int set_finalize ( set_handle_t  handle)
pure virtual

Finalize an incremental KVStore set sequence.

Parameters
[in]handleIncremental set handle.
Returns
MBED_SUCCESS on success or an error code on failure

Implemented in FileSystemStore, SecureStore, and TDBStore.

◆ iterator_open()

virtual int iterator_open ( iterator_t *  it,
const char *  prefix = NULL 
)
pure virtual

Start an iteration over KVStore keys.

Parameters
[out]itReturned iterator handle.
[in]prefixKey prefix (null for all keys).
Returns
MBED_SUCCESS on success or an error code on failure

Implemented in FileSystemStore, SecureStore, and TDBStore.

◆ iterator_next()

virtual int iterator_next ( iterator_t  it,
char *  key,
size_t  key_size 
)
pure virtual

Get next key in iteration.

Parameters
[in]itIterator handle.
[in]keyBuffer for returned key.
[in]key_sizeKey buffer size.
Returns
MBED_SUCCESS on success or an error code on failure

Implemented in FileSystemStore, SecureStore, and TDBStore.

◆ iterator_close()

virtual int iterator_close ( iterator_t  it)
pure virtual

Close iteration.

Parameters
[in]itIterator handle.
Returns
MBED_SUCCESS on success or an error code on failure

Implemented in FileSystemStore, SecureStore, and TDBStore.

◆ is_valid_key()

bool is_valid_key ( const char *  key) const

Convenience function for checking key validity.

Key must not include '*' '/' '?' ':' ';' '\' '"' '|' ' ' '<' '>' '\'.

Parameters
[in]keyKey buffer.
Returns
MBED_SUCCESS on success or an error code on failure

Definition at line 208 of file KVStore.h.