17 #ifndef MBED_KVSTORE_H 18 #define MBED_KVSTORE_H 33 WRITE_ONCE_FLAG = (1 << 0),
34 REQUIRE_CONFIDENTIALITY_FLAG = (1 << 1),
35 RESERVED_FLAG = (1 << 2),
36 REQUIRE_REPLAY_PROTECTION_FLAG = (1 << 3),
39 static const uint32_t MAX_KEY_SIZE = 128;
41 typedef struct _opaque_set_handle *set_handle_t;
43 typedef struct _opaque_key_iterator *iterator_t;
69 virtual int init() = 0;
84 virtual int reset() = 0;
96 virtual int set(
const char *key,
const void *buffer,
size_t size, uint32_t create_flags) = 0;
109 virtual int get(
const char *key,
void *buffer,
size_t buffer_size,
size_t *actual_size = NULL,
size_t offset = 0) = 0;
128 virtual int remove(
const char *key) = 0;
141 virtual int set_start(set_handle_t *handle,
const char *key,
size_t final_data_size, uint32_t create_flags) = 0;
152 virtual int set_add_data(set_handle_t handle,
const void *value_data,
size_t data_size) = 0;
171 virtual int iterator_open(iterator_t *it,
const char *prefix = NULL) = 0;
182 virtual int iterator_next(iterator_t it,
char *key,
size_t key_size) = 0;
202 if (!key || !strlen(key) || (strlen(key) > MAX_KEY_SIZE)) {
206 if (strpbrk(key,
" */?:;\"|<>\\")) {
virtual int deinit()=0
Deinitialize KVStore.
bool is_valid_key(const char *key) const
Convenience function for checking key validity.
virtual int get_info(const char *key, info_t *info=NULL)=0
Get information of a given key.
virtual int init()=0
Initialize KVStore.
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.
virtual int iterator_close(iterator_t it)=0
Close iteration.
virtual int iterator_next(iterator_t it, char *key, size_t key_size)=0
Get next key in iteration.
struct mbed::KVStore::info info_t
Holds key information.
virtual int reset()=0
Reset KVStore contents (clear all keys)
virtual int iterator_open(iterator_t *it, const char *prefix=NULL)=0
Start an iteration over KVStore keys.
virtual int set_finalize(set_handle_t handle)=0
Finalize an incremental KVStore set sequence.
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.