18 template<
typename... Args>
20 : _val(
std::forward<Args>(args)...)
30 return std::make_unique<Value<T>>(*this);
80 if constexpr (std::is_same_v<T, std::string>)
82 return sizeof(size_t) + _val.
size();
91 if constexpr (std::is_same_v<T, std::string>)
93 std::getline(in, _val,
'\0');
94 }
else if constexpr (std::is_same_v<T, bool>) {
97 std::transform(s.begin(), s.end(), s.begin(), ::tolower);
99 if (s ==
"true" || s ==
"1" || s ==
"yes" || s ==
"on")
102 }
else if (s ==
"false" || s ==
"0" || s ==
"no" || s ==
"off") {
105 in.setstate(std::ios::failbit);
123 return Infinity::Types::getTypeID<Value<T>>();
Template wrapper for primitive types to integrate with the Infinity type system.
Definition Value.hpp:89
size_t size() const
Gets the size of the underlying value in bytes.
Definition Value.inl:78
virtual const Infinity::Types::TypeID & typeId() const override
Gets the runtime type identifier for this Value<T> specialization.
Definition Value.inl:121
void set(const T &value)
Sets the underlying value.
Definition Value.inl:72
T & get()
Gets a mutable reference to the underlying value.
Definition Value.inl:60
virtual ~Value()
Virtual destructor.
Definition Value.inl:24
virtual std::istream & legibleDataRead(std::istream &in) override
Reads the Value from a single-line text representation.
Definition Value.inl:89
std::unique_ptr< Base > clone() const override
Definition Value.inl:28
virtual std::ostream & legibleDataWrite(std::ostream &out) const override
Writes the Value to a single-line text representation.
Definition Value.inl:114
Value & operator=(const Value &rhs)
Copy assignment from another Value.
Definition Value.inl:46
Value()
Default constructor.
Definition Value.inl:8
Runtime type identifier for the Infinity type system.
Definition TypeID.hpp:71