20#include <AUI/Common/SharedPtr.h>
25template<
typename T,
typename T2 =
void>
31 constexpr bool is_serializable = aui::is_complete<ASerializable<T>>;
35 static_assert(is_serializable<T>,
"T is not serializable");
41 static_assert(is_serializable<T>,
"T is not serializable");
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));
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:20
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:177
void API_AUI_XML read(const _< IInputStream > &is, const _< IXmlDocumentVisitor > &visitor)
Parses xml from the input stream to the IXmlDocumentVisitor.
Definition: AXml.cpp:20
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