83 using base_type = std::int64_t;
92 void AddEnumMember(
const std::string& name, base_type value);
93 const std::string& GetName(base_type value)
const;
94 base_type GetValue(
const std::string& name)
const;
95 const std::vector<std::string>& GetNames()
const;
96 bool HasNameFor(base_type value)
const;
97 bool HasValueFor(
const std::string& name)
const;
107 void AddEnumMember(
const std::string& name,
E value)
109 const auto val =
static_cast<base_type
>(value);
110 this->AddEnumMember(name, val);
114 std::map<std::string, base_type> m_forwardMap;
115 std::map<base_type, std::string> m_backwardMap;
116 std::vector<std::string> m_names;
121 friend class impl::PreferenceBuilder;
124 using PreferenceValue =
125 typename std::aligned_union<
128 sizeof(std::int64_t),
133 sizeof(FontDescription)
144 std::string m_identifier;
146 std::string m_description;
147 PreferenceType m_type;
148 PreferenceValue m_value;
149 PreferenceValue m_defaultValue;
150 bool m_isVisible{
true};
151 Unit m_unit{Unit::UNIT_COUNTS};
152 bool m_hasValue{
false};
157 : m_identifier{std::move(
identifier)}, m_type{type}
183 const std::string& GetIdentifier()
const;
184 const std::string& GetLabel()
const;
185 const std::string& GetDescription()
const;
186 void SetFont(
const FontDescription&
font);
187 FontDescription GetFont()
const;
188 std::int64_t GetEnumRaw()
const;
189 void SetEnumRaw(std::int64_t value);
190 PreferenceType GetType()
const;
191 bool GetBool()
const;
192 double GetReal()
const;
193 std::int64_t GetInt()
const;
194 const std::string& GetString()
const;
195 std::string ToString()
const;
196 bool GetIsVisible()
const;
197 ImU32 GetColor()
const;
199 void SetBool(
bool value);
200 void SetReal(
double value);
201 void SetInt(std::int64_t value);
202 void SetString(
const std::string& value);
203 void SetColor(
const ImU32& value);
205 void SetLabel(std::string label);
206 void SetDescription(std::string description);
208 void ResetToDefault();
212 template<
typename E >
215 return static_cast<E>(this->GetEnumRaw());
218 template<
typename E >
219 void SetEnum(
E value)
221 this->SetEnumRaw(
static_cast<std::int64_t
>(value));
233 template<
typename E >
241 const T& GetValueRaw()
const
243 return *
reinterpret_cast<const T*
>(&m_value);
249 return *
reinterpret_cast<T*
>(&m_value);
255 void Construct(
T value)
257 new (&m_value)
T(std::move(value));