#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);
    }
    static void unset(const std::string& key)
    {
        I.Descriptor::unset(key);
    }
    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);
    }
    template <typename T, typename D = decltype(T::value)>
    static D value_or(const std::string& key, D def)
    {
        return I.Descriptor::value_or<T, D>(key, def);
    }
};
