Mbed OS Reference
Loading...
Searching...
No Matches
KVStore Global API

Data Structures

struct  info
 The key size. More...
 

Typedefs

typedef struct info kv_info_t
 The key size. More...
 

Functions

int kv_set (const char *full_name_key, const void *buffer, size_t size, uint32_t create_flags)
 Set one KVStore item, given key and value. More...
 
int kv_get (const char *full_name_key, void *buffer, size_t buffer_size, size_t *actual_size)
 Get one KVStore item by given key. More...
 
int kv_get_info (const char *full_name_key, kv_info_t *info)
 Get information of a given key.The returned info contains size and flags. More...
 
int kv_remove (const char *full_name_key)
 Remove a KVStore item by given key. More...
 
int kv_iterator_open (kv_iterator_t *it, const char *full_prefix)
 Start an iteration over KVStore keys to find all the entries that fit the full_prefix. More...
 
int kv_iterator_next (kv_iterator_t it, char *key, size_t key_size)
 Get next key in iteration that matches the prefix. More...
 
int kv_iterator_close (kv_iterator_t it)
 Close iteration and deallocate the iterator handle. More...
 
int kv_reset (const char *kvstore_path)
 Remove all keys and related data from a specified partition. More...
 

Detailed Description

Typedef Documentation

◆ kv_info_t

typedef struct info kv_info_t

The key size.

Function Documentation

◆ kv_set()

int kv_set ( const char *  full_name_key,
const void *  buffer,
size_t  size,
uint32_t  create_flags 
)

Set one KVStore item, given key and value.

Parameters
[in]full_name_key/Partition_path/Key. Must not include '*' '/' '?' ':' ';' '\' '"' '|' ' ' '<' '>' '\'.
[in]bufferValue data buffer.
[in]sizeValue data size.
[in]create_flagsFlag mask.
Returns
MBED_SUCCESS on success or an error code from underlying KVStore instances

◆ kv_get()

int kv_get ( const char *  full_name_key,
void *  buffer,
size_t  buffer_size,
size_t *  actual_size 
)

Get one KVStore item by given key.

Parameters
[in]full_name_key/Partition_path/Key. Must not include '*' '/' '?' ':' ';' '\' '"' '|' ' ' '<' '>' '\'.
[in]bufferValue data buffer.
[in]buffer_sizeValue data buffer size.
[out]actual_sizeActual read size.
Returns
MBED_SUCCESS on success or an error code from underlying KVStore instances

◆ kv_get_info()

int kv_get_info ( const char *  full_name_key,
kv_info_t info 
)

Get information of a given key.The returned info contains size and flags.

Parameters
[in]full_name_key/Partition_path/Key. Must not include '*' '/' '?' ':' ';' '\' '"' '|' ' ' '<' '>' '\'.
[out]infoReturned information structure.
Returns
MBED_SUCCESS on success or an error code from underlying KVStore instances

◆ kv_remove()

int kv_remove ( const char *  full_name_key)

Remove a KVStore item by given key.

Parameters
[in]full_name_key/Partition_path/Key. Must not include '*' '/' '?' ':' ';' '\' '"' '|' ' ' '<' '>' '\'.
Returns
MBED_SUCCESS on success or an error code from underlying KVStore instances

◆ kv_iterator_open()

int kv_iterator_open ( kv_iterator_t *  it,
const char *  full_prefix 
)

Start an iteration over KVStore keys to find all the entries that fit the full_prefix.

There are no issues with any other operations while iterator is open.

Parameters
[out]itAllocating iterator handle. Do not forget to call kv_iterator_close to deallocate the memory.
[in]full_prefixfull_prefix Partition/Key prefix. If empty key or NULL pointer, all keys will match.
Returns
MBED_SUCCESS on success or an error code from underlying KVStore instances

◆ kv_iterator_next()

int kv_iterator_next ( kv_iterator_t  it,
char *  key,
size_t  key_size 
)

Get next key in iteration that matches the prefix.

There are no issues with any other operations while iterator is open.

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

◆ kv_iterator_close()

int kv_iterator_close ( kv_iterator_t  it)

Close iteration and deallocate the iterator handle.

Parameters
[in]itIterator handle.
Returns
MBED_SUCCESS on success or an error code from underlying KVStore instances

◆ kv_reset()

int kv_reset ( const char *  kvstore_path)

Remove all keys and related data from a specified partition.

Parameters
[in]kvstore_path/Partition/
Returns
MBED_SUCCESS on success or an error code from underlying KVStore instances