pollymc/launcher/DefaultVariable.h

36 lines
687 B
C
Raw Normal View History

2014-07-16 05:33:52 +05:30
#pragma once
template <typename T>
class DefaultVariable
{
public:
2018-07-15 18:21:05 +05:30
DefaultVariable(const T & value)
{
defaultValue = value;
}
DefaultVariable<T> & operator =(const T & value)
{
currentValue = value;
is_default = currentValue == defaultValue;
is_explicit = true;
return *this;
}
operator const T &() const
{
return is_default ? defaultValue : currentValue;
}
bool isDefault() const
{
return is_default;
}
bool isExplicit() const
{
return is_explicit;
}
2014-07-16 05:33:52 +05:30
private:
2018-07-15 18:21:05 +05:30
T currentValue;
T defaultValue;
bool is_default = true;
bool is_explicit = false;
2014-07-16 05:33:52 +05:30
};