Infinity Engine v0.6.20
C++ API Documentation
Loading...
Searching...
No Matches
Value.hpp
1// INFINITY_API_PUBLIC
2
3#pragma once
4
5#include <Infinity/Types/Core/Data.hpp>
6
7#include <string>
8#include <vector>
9#include <algorithm>
10#include <iostream>
11#include <cstdint>
12#include <cassert>
13
14namespace Infinity::IO::Data
15{
17 template<typename T>
18 class ValueSerializer;
20}
21
23{
87 template<typename T>
88 class INFINITY_API_TEMPLATE Value : public Data
89 {
90 public:
97 Value();
98
111 Value(T& value);
112
127 template<typename... Args>
128 explicit Value(Args&&... args);
129
136 virtual ~Value();
137
138 std::unique_ptr<Base> clone() const override;
139
153 operator T&();
154
167 operator const T&() const;
168
175 Value& operator=(const Value& rhs);
176
188 Value& operator=(const T& rhs);
189
200 T& get();
201
212 const T& get() const;
213
224 void set(const T& value);
225
237 size_t size() const;
238
256 virtual std::istream& legibleDataRead(std::istream& in) override;
257
277 virtual std::ostream& legibleDataWrite(std::ostream& out) const override;
278
293 virtual const Infinity::Types::TypeID& typeId() const override;
294
295 private:
301 T _val;
302
303 friend class Infinity::IO::Data::ValueSerializer<T>;
304 };
305
322 template<typename T>
323 INFINITY_API_TEMPLATE std::ostream& operator<<(std::ostream& out, const Value<T>& v)
324 {
325 out << v.get();
326 return out;
327 }
328
346 template<typename T>
347 INFINITY_API_TEMPLATE std::istream& operator>>(std::istream& in, Value<T>& v)
348 {
349 in >> v.get();
350 return in;
351 }
352}
353
354#include <Infinity/Types/Core/Value.inl>
355
356// Register common Value specializations in the type system
Base class for complex data types with memory wrapping and property support.
Definition Data.hpp:49
Template wrapper for primitive types to integrate with the Infinity type system.
Definition Value.hpp:89
T & get()
Gets a mutable reference to the underlying value.
Definition Value.inl:60
Definition Array.hpp:17
Definition Base.hpp:12
std::ostream & operator<<(std::ostream &out, const Infinity::Types::Core::Base *&v)
Stream insertion operator for Base pointers.
Definition Base.hpp:197
std::istream & operator>>(std::istream &in, Infinity::Types::Core::Base *&v)
Stream extraction operator for Base pointers.
Definition Base.hpp:211
Runtime type identifier for the Infinity type system.
Definition TypeID.hpp:71