20#include <AUI/Common/SharedPtr.h>
25template<
typename T,
typename T2 =
void>
35 static_assert(is_serializable<T>,
"T is not serializable");
41 static_assert(is_serializable<T>,
"T is not serializable");
46 inline T deserialize(aui::no_escape<IInputStream> from) {
48 deserialize<T>(from, t);
53#include <AUI/IO/IInputStream.h>
54#include <AUI/IO/IOutputStream.h>
60 os.
write(
reinterpret_cast<const char*
>(&value),
sizeof(value));
63 is.
readExact(
reinterpret_cast<char*
>(&t),
sizeof(T));
69 struct serialize_sized {
72 serialize_sized(T& value): value(&value) {}
73 serialize_sized(T&& value): value(&value) {}
76 struct serialize_raw {
79 serialize_raw(T& value): value(&value) {}
80 serialize_raw(T&& value): value(&value) {}
93 aui::serialize(os, *value);
96 t = _new<T>(std::move(aui::deserialize<T>(is)));
103 static void write(
IOutputStream& os,
const std::string& value) {
104 os.
write(value.data(), value.length());
110struct ASerializable<T, std::enable_if_t<std::is_base_of_v<IInputStream, T>>> {
113 for (
size_t r; (r =
const_cast<T&
>(value).read(buf,
sizeof(buf))) != 0;) {
123 os.
write(value, L - 1);
131 os.
write(value, std::strlen(value));
139 aui::serialize(os, value.toStdString());
147 os << std::uint32_t(t.value->size());
148 os.
write(
reinterpret_cast<const char*
>(t.value->data()),
sizeof(*t.value->data()) * t.value->size());
154 is.
read(
reinterpret_cast<char*
>(t.value->data()),
sizeof(*t.value->data()) * t.value->size());
161 os.
write(
reinterpret_cast<const char*
>(t.value),
sizeof(T));
164 is.
read(
reinterpret_cast<char*
>(t.value),
sizeof(T));
Represents a Unicode character string.
Definition AString.h:37
Definition IOutputStream.h:18
virtual void write(const char *src, size_t size)=0
Writes exact size bytes to stream. Blocking (waiting for write all data) is allowed.
An std::weak_ptr with AUI extensions.
Definition SharedPtrTypes.h:178
type_of< T > t
Selects views that are of the specified C++ types.
Definition type_of.h:71
constexpr bool is_complete
Determines whether T is complete or not.
Definition types.h:23
Definition serializable.h:26
Does not allow escaping, allowing to accept lvalue ref, rvalue ref, shared_ptr and etc without overhe...
Definition values.h:127
Definition serializable.h:58
Definition serializable.h:76
Definition serializable.h:69