5 #ifndef TILESON_PROPERTY_HPP
6 #define TILESON_PROPERTY_HPP
14 #include "../common/Enums.hpp"
37 inline Property(std::string name, std::any value,
Type type);
39 inline void setValue(
const std::any &value);
41 inline void setName(
const std::string &name);
43 [[nodiscard]]
inline const std::type_info&
getValueType()
const;
45 [[nodiscard]]
inline const std::any &
getValue()
const;
48 [[nodiscard]]
inline const std::string &
getName()
const;
63 bool isCorrectType = (
m_value.type() ==
typeid(T));
67 T value = std::any_cast<T>(
m_value);
72 static T defaultValue;
85 setTypeByString(json[
"type"].get<std::string>());
86 setValueByType(json[
"value"]);
87 m_name = json[
"name"].
get<std::string>();
135 return m_value.type();
148 return m_value.type().name();
160 else if(str ==
"file")
162 else if(str ==
"int")
164 else if(str ==
"bool")
166 else if(str ==
"float")
168 else if(str ==
"string")
179 m_value =
Colori(json.
get<std::string>());
183 m_value = fs::path(json.
get<std::string>());
187 m_value = json.
get<
int>();
191 m_value = json.
get<
bool>();
195 m_value = json.
get<
float>();
199 setStrValue(json.
get<std::string>());
203 setStrValue(json.
get<std::string>());
T get(std::string_view key)
Definition: IJson.hpp:72
Definition: Property.hpp:21
Property()
Definition: Property.hpp:78
void setTypeByString(const std::string &str)
Definition: Property.hpp:156
std::any m_value
Definition: Property.hpp:57
void setValue(const std::any &value)
Definition: Property.hpp:95
std::string getValueTypeInfo()
Definition: Property.hpp:146
const std::any & getValue() const
Definition: Property.hpp:111
const std::string & getName() const
Definition: Property.hpp:121
Type m_type
Definition: Property.hpp:55
void setValueByType(IJson &json)
Definition: Property.hpp:174
const std::type_info & getValueType() const
Definition: Property.hpp:133
void setStrValue(const std::string &value)
Definition: Property.hpp:106
Type getType() const
Definition: Property.hpp:151
void setName(const std::string &name)
Definition: Property.hpp:116
std::string m_name
Definition: Property.hpp:56
Definition: Base64.hpp:12
Type
Definition: Enums.hpp:16
Color< uint8_t > Colori
Definition: Color.hpp:89