Kenji Arai / mbed-os_TYBLE16

Dependents:   TYBLE16_simple_data_logger TYBLE16_MP3_Air

Embed: (wiki syntax)

« Back to documentation index

FileSystemStore Class Reference

FileSystemStore Class Reference

FileSystemStore for Secure Store. More...

#include <FileSystemStore.h>

Inherits mbed::KVStore.

Public Types

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

Public Member Functions

 FileSystemStore (FileSystem *fs)
 Create FileSystemStore - A Key Value API on top of FS.
virtual ~FileSystemStore ()
 Destroy FileSystemStore instance.
virtual int init ()
 Initialize FileSystemStore, checking validity of KVStore writing folder and if it doesn't exist, creating it.
virtual int deinit ()
 Deinitialize FileSystemStore, release and free resources.
virtual int reset ()
 Reset FileSystemStore contents (clear all keys)
virtual int set (const char *key, const void *buffer, size_t size, uint32_t create_flags)
 Set one FileSystemStore 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 FileSystemStore 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 FileSystemStore 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 FileSystemStore set sequence.
virtual int set_add_data (set_handle_t handle, const void *value_data, size_t data_size)
 Add data to incremental FileSystemStore set sequence.
virtual int set_finalize (set_handle_t handle)
 Finalize an incremental FileSystemStore set sequence.
virtual int iterator_open (iterator_t *it, const char *prefix=NULL)
 Start an iteration over FileSystemStore 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 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.
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 set_finalize (set_handle_t handle)=0
 Finalize an incremental KVStore set sequence.
bool is_valid_key (const char *key) const
 Convenience function for checking key validity.

Detailed Description

FileSystemStore for Secure Store.

This class implements the KVStore interface to create a key value store over FileSystem.

  ...

Definition at line 34 of file FileSystemStore.h.


Member Typedef Documentation

typedef struct mbed::KVStore::info info_t [inherited]

Holds key information.


Constructor & Destructor Documentation

Create FileSystemStore - A Key Value API on top of FS.

Parameters:
fsFile system (FAT/LITTLE) on top of which FileSystemStore is adding KV API

Definition at line 66 of file FileSystemStore.cpp.

virtual ~FileSystemStore (  ) [virtual]

Destroy FileSystemStore instance.

Definition at line 46 of file FileSystemStore.h.


Member Function Documentation

int deinit (  ) [virtual]

Deinitialize FileSystemStore, release and free resources.

Returns:
MBED_SUCCESS Success.

Implements KVStore.

Definition at line 118 of file FileSystemStore.cpp.

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

Get one FileSystemStore item by given key.

Parameters:
[in]keyKey - must not include '*' '/' '?' ':' ';' '\' '"' '|' ' ' '<' '>' '\'.
[in]bufferValue data buffer.
[in]buffer_sizeValue data buffer size.
[out]actual_sizeActual read size.
[in]offsetOffset to read from in data.
Returns:
MBED_SUCCESS Success. MBED_ERROR_NOT_READY Not initialized. MBED_ERROR_FAILED_OPERATION Underlying file system failed operation. 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 corrupted. MBED_ERROR_ITEM_NOT_FOUND No such key.

Implements KVStore.

Definition at line 198 of file FileSystemStore.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]keyKey - must not include '*' '/' '?' ':' ';' '\' '"' '|' ' ' '<' '>' '\'.
[out]infoReturned information structure.
Returns:
MBED_SUCCESS Success. MBED_ERROR_NOT_READY Not initialized. MBED_ERROR_FAILED_OPERATION Underlying file system failed operation. 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 corrupted. MBED_ERROR_ITEM_NOT_FOUND No such key.

Implements KVStore.

Definition at line 253 of file FileSystemStore.cpp.

int init (  ) [virtual]

Initialize FileSystemStore, checking validity of KVStore writing folder and if it doesn't exist, creating it.

Returns:
MBED_SUCCESS Success. MBED_ERROR_FAILED_OPERATION Underlying file system failed operation.

Implements KVStore.

Definition at line 73 of file FileSystemStore.cpp.

bool is_valid_key ( const char *  key ) const [inherited]

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 200 of file KVStore.h.

int iterator_close ( iterator_t  it ) [virtual]

Close iteration.

Parameters:
[in]itIterator 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 568 of file FileSystemStore.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]itIterator handle.
[in]keyBuffer for returned key.
[in]key_sizeKey buffer size.
Returns:
MBED_SUCCESS Success. MBED_ERROR_NOT_READY Not initialized. MBED_ERROR_INVALID_ARGUMENT Invalid argument given in function arguments. MBED_ERROR_ITEM_NOT_FOUND No more keys found.

Implements KVStore.

Definition at line 519 of file FileSystemStore.cpp.

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

Start an iteration over FileSystemStore keys.

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

Parameters:
[out]itReturned iterator handle.
[in]prefixKey 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 475 of file FileSystemStore.cpp.

int remove ( const char *  key ) [virtual]

Remove a FileSystemStore item by given key.

Parameters:
[in]keyKey - must not include '*' '/' '?' ':' ';' '\' '"' '|' ' ' '<' '>' '\'.
Returns:
MBED_SUCCESS Success. MBED_ERROR_NOT_READY Not initialized. MBED_ERROR_FAILED_OPERATION Underlying file system failed operation. MBED_ERROR_INVALID_ARGUMENT Invalid argument given in function arguments. MBED_ERROR_ITEM_NOT_FOUND No such key. MBED_ERROR_WRITE_PROTECTED Already stored with "write once" flag.

Implements KVStore.

Definition at line 287 of file FileSystemStore.cpp.

int reset ( void   ) [virtual]

Reset FileSystemStore contents (clear all keys)

Returns:
MBED_SUCCESS Success. MBED_ERROR_NOT_READY Not initialized. MBED_ERROR_FAILED_OPERATION Underlying file system failed operation.

Implements KVStore.

Definition at line 129 of file FileSystemStore.cpp.

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

Set one FileSystemStore 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 Success. MBED_ERROR_NOT_READY Not initialized. MBED_ERROR_FAILED_OPERATION Underlying file system failed operation. MBED_ERROR_INVALID_ARGUMENT Invalid argument given in function arguments. MBED_ERROR_INVALID_SIZE Invalid size given in function arguments. MBED_ERROR_WRITE_PROTECTED Already stored with "write once" flag.

Implements KVStore.

Definition at line 159 of file FileSystemStore.cpp.

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

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 SecureStore, and TDBStore.

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

Add data to incremental FileSystemStore set sequence.

This operation is blocking other operations. Any get/set/remove operation will be blocked until set_finalize is called.

Parameters:
[in]handleIncremental set handle.
[in]value_dataValue data to add.
[in]data_sizeValue data size.
Returns:
MBED_SUCCESS Success. MBED_ERROR_NOT_READY Not initialized. MBED_ERROR_FAILED_OPERATION Underlying file system failed operation. MBED_ERROR_INVALID_ARGUMENT Invalid argument given in function arguments. MBED_ERROR_INVALID_SIZE Invalid size given in function arguments. MBED_ERROR_WRITE_PROTECTED Already stored with "write once" flag.
virtual int set_finalize ( set_handle_t  handle ) [virtual]

Finalize an incremental FileSystemStore set sequence.

Parameters:
[in]handleIncremental set handle.
Returns:
MBED_SUCCESS Success. MBED_ERROR_NOT_READY Not initialized. MBED_ERROR_FAILED_OPERATION Underlying file system failed operation. MBED_ERROR_INVALID_ARGUMENT Invalid argument given in function arguments.
virtual int set_finalize ( set_handle_t  handle ) [pure virtual, inherited]

Finalize an incremental KVStore set sequence.

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

Implemented in SecureStore, and TDBStore.

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

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 SecureStore, and TDBStore.

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

Start an incremental FileSystemStore set sequence.

This operation is blocking other operations. Any get/set/remove/iterator operation will be blocked until set_finalize is called.

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 Success. MBED_ERROR_NOT_READY Not initialized. MBED_ERROR_FAILED_OPERATION Underlying file system failed operation. MBED_ERROR_INVALID_ARGUMENT Invalid argument given in function arguments. MBED_ERROR_INVALID_SIZE Invalid size given in function arguments. MBED_ERROR_WRITE_PROTECTED Already stored with "write once" flag.