settings file and save/restore ui state
This commit is contained in:
35
src/settings.h
Normal file
35
src/settings.h
Normal file
@@ -0,0 +1,35 @@
|
||||
#pragma once
|
||||
#include "serializer.h"
|
||||
|
||||
class Settings : public Serializer::Descriptor
|
||||
{
|
||||
public:
|
||||
Settings() { class_id = "pref"; }
|
||||
static Settings I;
|
||||
static bool load();
|
||||
static bool save();
|
||||
static bool has(const std::string& key)
|
||||
{
|
||||
return I.Descriptor::has(key);
|
||||
}
|
||||
template <typename T>
|
||||
static void set(const std::string& key, const T value)
|
||||
{
|
||||
I.Descriptor::set(key, value);
|
||||
}
|
||||
template <typename T>
|
||||
static std::shared_ptr<T> get(const std::string& key)
|
||||
{
|
||||
return I.Descriptor::get<T>(key);
|
||||
}
|
||||
template <typename T, typename D = decltype(T::value)>
|
||||
static void value(const std::string& key, D& dest)
|
||||
{
|
||||
I.Descriptor::value<T, D>(key, dest);
|
||||
}
|
||||
template <typename T>
|
||||
static auto value(const std::string& key)
|
||||
{
|
||||
return I.Descriptor::value<T>(key);
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user