mirror of
https://github.com/ByteWelder/Tactility.git
synced 2026-02-18 19:03:16 +00:00
- WiFi Connect app is now hidden by default, but accessible at the bottom of the WiFi Manage app when WiFi is turned on. - WiFi service now turns on WiFi when calling connect() and WiFi is not on. - Removed `blocking` option for `service::loader::startApp()`. This feature was unused and complex. - Various apps: Moved private headers into Private/ folder. - Various apps: created start() function for easy starting. - Added documentation to all TactilityC APIs - Refactored various `enum` into `class enum` - Refactor M5Stack `initBoot()` (but VBus is still 0V for some reason)
65 lines
1.4 KiB
C++
65 lines
1.4 KiB
C++
/**
|
|
* @brief key-value storage for general purpose.
|
|
* Maps strings on a fixed set of data types.
|
|
*/
|
|
#pragma once
|
|
|
|
#include <cstdint>
|
|
#include <string>
|
|
#include <unordered_map>
|
|
|
|
namespace tt {
|
|
|
|
/**
|
|
* A dictionary that maps keys (strings) onto several atomary types.
|
|
*/
|
|
class Bundle {
|
|
|
|
private:
|
|
|
|
typedef uint32_t Hash;
|
|
|
|
enum class Type {
|
|
Bool,
|
|
Int32,
|
|
String,
|
|
};
|
|
|
|
typedef struct {
|
|
Type type;
|
|
union {
|
|
bool value_bool;
|
|
int32_t value_int32;
|
|
};
|
|
std::string value_string;
|
|
} Value;
|
|
|
|
std::unordered_map<std::string, Value> entries;
|
|
|
|
public:
|
|
|
|
Bundle() = default;
|
|
|
|
Bundle(const Bundle& bundle) {
|
|
this->entries = bundle.entries;
|
|
}
|
|
|
|
bool getBool(const std::string& key) const;
|
|
int32_t getInt32(const std::string& key) const;
|
|
std::string getString(const std::string& key) const;
|
|
|
|
bool hasBool(const std::string& key) const;
|
|
bool hasInt32(const std::string& key) const;
|
|
bool hasString(const std::string& key) const;
|
|
|
|
bool optBool(const std::string& key, bool& out) const;
|
|
bool optInt32(const std::string& key, int32_t& out) const;
|
|
bool optString(const std::string& key, std::string& out) const;
|
|
|
|
void putBool(const std::string& key, bool value);
|
|
void putInt32(const std::string& key, int32_t value);
|
|
void putString(const std::string& key, const std::string& value);
|
|
};
|
|
|
|
} // namespace
|