Ersa Wearable Platform
Embedded smartwatch firmware and application framework
Loading...
Searching...
No Matches
storage_service.h
Go to the documentation of this file.
1#pragma once
2
3#include "ersa/common/types.h"
4#include <string>
5#include <string_view>
6#include <stdint.h>
7
8namespace ersa {
9namespace services {
10
20public:
21 virtual ~StorageService() = default;
22
24 virtual Result<void> init() = 0;
25
27 virtual bool setString(std::string_view key, std::string_view value) = 0;
29 virtual std::string getString(std::string_view key, std::string_view defaultValue = "") = 0;
30
32 virtual bool setInt(std::string_view key, int32_t value) = 0;
34 virtual int32_t getInt(std::string_view key, int32_t defaultValue = 0) = 0;
35
37 virtual bool setBool(std::string_view key, bool value) = 0;
39 virtual bool getBool(std::string_view key, bool defaultValue = false) = 0;
40
42 virtual bool setBytes(std::string_view key, const void* data, size_t size) = 0;
44 virtual size_t getBytesLength(std::string_view key) = 0;
46 virtual size_t getBytes(std::string_view key, void* data, size_t size) = 0;
47
49 virtual bool remove(std::string_view key) = 0;
51 virtual void clear() = 0;
52
54 static StorageService& instance();
57};
58
59} // namespace services
60} // namespace ersa
Definition types.h:52
Definition storage_service.h:19
virtual size_t getBytes(std::string_view key, void *data, size_t size)=0
virtual bool remove(std::string_view key)=0
virtual bool setBool(std::string_view key, bool value)=0
virtual size_t getBytesLength(std::string_view key)=0
virtual bool getBool(std::string_view key, bool defaultValue=false)=0
static StorageService & instance()
Return the installed process-wide storage service.
Definition storage_service.cpp:10
virtual Result< void > init()=0
virtual bool setInt(std::string_view key, int32_t value)=0
virtual int32_t getInt(std::string_view key, int32_t defaultValue=0)=0
static void setInstance(StorageService *instance)
Install the process-wide storage backend.
Definition storage_service.cpp:14
virtual ~StorageService()=default
virtual bool setBytes(std::string_view key, const void *data, size_t size)=0
virtual std::string getString(std::string_view key, std::string_view defaultValue="")=0
virtual bool setString(std::string_view key, std::string_view value)=0
Definition application.h:10
size_t size
Definition ota_service.cpp:47
char data[MANIFEST_LIMIT]
Definition ota_service.cpp:33