Infinity Engine v0.6.20
C++ API Documentation
Loading...
Searching...
No Matches
PropertyValue.hpp
1#pragma once
2
3#include <Infinity/api.h>
4
5#include <iostream>
6#include <cstdint>
7#include <type_traits>
8
10{
11 class Data;
12
13 class INFINITY_API_PUBLIC PropertyValue
14 {
15 public:
16 enum Type : uint8_t {
22 DATA
23 };
24
25 private:
26 Type _type = NIL;
27
28 union {
29 bool as_bool;
30 int as_int;
31 float as_float;
32 double as_double;
34 };
35
36 public:
38
41 PropertyValue(float v);
42 PropertyValue(double v);
43
44 template<typename T, typename = std::enable_if_t<
45 !std::is_same_v<std::decay_t<T>, bool> &&
46 !std::is_same_v<std::decay_t<T>, int> &&
47 !std::is_same_v<std::decay_t<T>, float> &&
48 !std::is_same_v<std::decay_t<T>, double> &&
49 !std::is_same_v<std::decay_t<T>, std::nullptr_t> &&
50 !std::is_pointer_v<std::decay_t<T>> &&
51 !std::is_same_v<std::decay_t<T>, PropertyValue>>>
52 PropertyValue(T&& v);
53
55
57
58 PropertyValue(PropertyValue&& other) noexcept;
59
62
63 Type type() const;
64
65 template<typename T>
66 T* as();
67
68 template<typename T>
69 const T* as() const;
70
71 void read(std::istream& in);
72 void write(std::ostream& out) const;
73
74 size_t wrap(const std::byte* data);
75 size_t size_bytes() const noexcept;
76
77 private:
78 void destroy();
79 };
80}
81
82#include <Infinity/Types/Core/PropertyValue.inl>
Base class for complex data types with memory wrapping and property support.
Definition Data.hpp:49
Definition PropertyValue.hpp:14
PropertyValue(const PropertyValue &other)
size_t size_bytes() const noexcept
int as_int
Definition PropertyValue.hpp:30
PropertyValue & operator=(PropertyValue &&other) noexcept
size_t wrap(const std::byte *data)
Type
Definition PropertyValue.hpp:16
@ DOUBLE
Definition PropertyValue.hpp:21
@ NIL
Definition PropertyValue.hpp:17
@ BOOL
Definition PropertyValue.hpp:18
@ FLOAT
Definition PropertyValue.hpp:20
@ INT
Definition PropertyValue.hpp:19
bool as_bool
Definition PropertyValue.hpp:29
PropertyValue & operator=(const PropertyValue &other)
float as_float
Definition PropertyValue.hpp:31
void write(std::ostream &out) const
double as_double
Definition PropertyValue.hpp:32
PropertyValue(PropertyValue &&other) noexcept
Data * as_object
Definition PropertyValue.hpp:33
Definition Base.hpp:12