Enhance NVSStorageHandler with filtering capabilities and update constructor to accept namespace
This commit is contained in:
12
main/io/io.h
12
main/io/io.h
@@ -2,6 +2,9 @@
|
||||
#include "freertos/FreeRTOS.h"
|
||||
#include "freertos/event_groups.h"
|
||||
|
||||
typedef bool(*FilterFunc)(const char* const& key);
|
||||
typedef void (*KeyValueProcessor)(void* arg, const char* const& key, const char* const& value);
|
||||
|
||||
class KVStorageHandler {
|
||||
public:
|
||||
virtual ~KVStorageHandler() = default;
|
||||
@@ -9,12 +12,15 @@ public:
|
||||
virtual void init(const EventGroupHandle_t& system_event_group) = 0;
|
||||
|
||||
// Store a key-value pair
|
||||
virtual void put(const char*& key, const char*& value) = 0;
|
||||
virtual void put(const char* const& key, const char* const& value) = 0;
|
||||
|
||||
// Retrieve a value by key, returns nullptr if key not found
|
||||
// The caller is responsible for freeing the returned memory
|
||||
virtual char* get(const char*& key) const = 0;
|
||||
virtual char* get(const char* const& key) const = 0;
|
||||
virtual esp_err_t process_all(KeyValueProcessor processor, void* arg) const = 0;
|
||||
virtual esp_err_t process_filtered(const char* const& key_prefix, KeyValueProcessor processor, void* arg) const = 0;
|
||||
virtual esp_err_t process_filtered(FilterFunc filter_func, KeyValueProcessor processor, void* arg) const = 0;
|
||||
|
||||
// Delete a key-value pair
|
||||
virtual void remove(const char*& key) = 0;
|
||||
virtual void remove(const char* const& key) = 0;
|
||||
};
|
||||
Reference in New Issue
Block a user