mirror-chatterino2/src/singletons/helper/ChatterinoSetting.hpp

45 lines
1.1 KiB
C++
Raw Normal View History

2017-12-31 00:50:07 +01:00
#pragma once
namespace chatterino {
void _registerSetting(std::weak_ptr<pajlada::Settings::ISettingData> setting);
2017-12-31 00:50:07 +01:00
template <typename Type>
class ChatterinoSetting : public pajlada::Settings::Setting<Type>
{
public:
ChatterinoSetting(const std::string &_path)
: pajlada::Settings::Setting<Type>(_path)
{
_registerSetting(this->data);
}
2017-12-31 00:50:07 +01:00
ChatterinoSetting(const std::string &_path, const Type &_defaultValue)
: pajlada::Settings::Setting<Type>(_path, _defaultValue)
{
_registerSetting(this->data);
}
template <typename T2>
ChatterinoSetting &operator=(const T2 &newValue)
{
this->setValue(newValue);
return *this;
}
ChatterinoSetting &operator=(Type &&newValue) noexcept
{
2018-04-22 14:09:38 +02:00
pajlada::Settings::Setting<Type>::operator=(newValue);
2017-12-31 00:50:07 +01:00
return *this;
}
2018-04-22 14:09:38 +02:00
using pajlada::Settings::Setting<Type>::operator==;
using pajlada::Settings::Setting<Type>::operator!=;
2017-12-31 00:50:07 +01:00
2018-04-22 14:09:38 +02:00
using pajlada::Settings::Setting<Type>::operator const Type;
2017-12-31 00:50:07 +01:00
};
} // namespace chatterino