Infinity Engine v0.6.20
C++ API Documentation
Loading...
Searching...
No Matches
Data.inl
1// INFINITY_API_PUBLIC
2
3#pragma once
4
5#include <Infinity/Types/Core/Value.hpp>
6#include <Infinity/Types/Core/PropertyValue.inl>
7
9{
10 template<typename T>
11 void Data::setProperty(const std::string& key, T&& value)
12 {
13 properties[key] = PropertyValue(std::forward<T>(value));
14 }
15
16 template<typename T>
17 void Data::setProperty(const std::string& key, const T& value)
18 {
19 properties[key] = PropertyValue(value);
20 }
21
22 template<typename T>
23 const T& Data::getProperty(const std::string& key) const
24 {
25 auto it = properties.find(key);
26 if (it != properties.end())
27 {
28 return *it->second.as<T>();
29 } else {
30 throw std::runtime_error("Property key not found");
31 }
32 }
33}
std::unordered_map< std::string, PropertyValue > properties
Property storage for arbitrary metadata.
Definition Data.hpp:81
void setProperty(const std::string &key, T &&value)
Sets a typed property value.
Definition Data.inl:11
const PropertyValue & getProperty(const std::string &key) const
Gets a property value without type checking.
Definition PropertyValue.hpp:14
T * as()
Definition PropertyValue.inl:26
Definition Base.hpp:12