69 class DeserializeError;
116 static_assert(codec_always_false_v<T>,
117 "Specialize StormByte::Detail::Codec<T> instead of Serializable<T>");
128 static_assert(codec_always_false_v<T>,
129 "Specialize StormByte::Detail::Codec<T> instead of Serializable<T>");
140 static_assert(codec_always_false_v<T>,
141 "Specialize StormByte::Detail::Codec<T> instead of Serializable<T>");
143 return Unexpected<DeserializeError>(
"Codec<T> is not specialized");
378 using DecayedT = std::remove_cvref_t<T>;
440 const DecayedT& m_data;
454 template<typename U = T>
456 requires
Type::TriviallyCopyable<U>;
463 template<typename U = T>
464 BinaryData SerializeContainer() const noexcept
465 requires
Type::Container<U>;
472 template<typename U = T>
474 requires
Type::Pair<U>;
484 template<typename U = T>
486 requires
Type::Optional<U>;
494 template<typename U = T>
495 static
ByteSize SizeContainer(const DecayedT& data) noexcept
496 requires
Type::Container<U>;
504 template<typename U = T>
505 static
ByteSize SizePair(const DecayedT& data) noexcept
506 requires
Type::Pair<U>;
514 template<typename U = T>
515 static
ByteSize SizeOptional(const DecayedT& data) noexcept
516 requires
Type::Optional<U>;
528 template<typename U = T>
530 requires
Type::TriviallyCopyable<U>;
538 template<typename U = T>
540 requires
Type::Container<U>;
548 template<typename U = T>
550 requires
Type::Pair<U>;
558 template<typename U = T>
560 requires
Type::Optional<U>;
605#include <StormByte/serializable.txx>
DLL-boundary-safe owned byte sequence for the StormByte suite.
IEC octet length (uint64_t), implicit only to std::size_t.
DLL-boundary-safe owned contiguous sequence of std::byte.
Definition binary_data.hxx:106
Count of octets (uint64_t storage).
Definition byte_size.hxx:103
Thrown when deserialization fails.
Definition exception.hxx:196
Owned NUL-terminated buffer, safe to use across a DLL boundary.
Definition cstring.hxx:103
Owned UTF-8 text composed of StormByte::Safe::CString.
Definition string.hxx:97
Owned NUL-terminated wide buffer, safe to use across a DLL boundary.
Definition wcstring.hxx:104
Wide counterpart of String.
Definition wstring.hxx:96
Encodes and decodes one value of type T.
Definition serializable.hxx:377
Serializable(const DecayedT &data) noexcept
Binds data for a later StormByte::Serializable::Serialize.
Definition serializable.hxx:385
Serializable(const Serializable &other) noexcept=delete
Copy is deleted: the wrapper only holds a reference.
static Expected< T, DeserializeError > Deserialize(std::span< const std::byte > data) noexcept
Decodes one T from the start of data.
Serializable(Serializable &&other) noexcept=delete
Move is deleted: the wrapper only holds a reference.
BinaryData Serialize() const noexcept
Encodes the bound value to a little-endian blob.
~Serializable() noexcept=default
Destructor.
Count of abstract units (uint64_t storage).
Definition size.hxx:105
constexpr bool codec_always_false_v
Compile-time false dependent on T.
Definition serializable.hxx:84
Root namespace of the StormByte suite.
std::conditional_t< Type::Reference< T >, std::expected< std::reference_wrapper< std::remove_reference_t< T > >, Safe::Shared< E > >, std::expected< T, Safe::Shared< E > > > Expected
std::expected alias with reference and shared-error handling.
Definition expected.hxx:66
Octet count. Defined in byte_size.hxx. Forwarded so Type::Numeral can name it.
static BinaryData Write(const Safe::CString &data) noexcept
Encodes data.
static Expected< Safe::CString, DeserializeError > Read(std::span< const std::byte > data) noexcept
Decodes a StormByte::Safe::CString from the start of data.
static ByteSize Size(const Safe::CString &data) noexcept
Serialized size of data.
static Expected< Safe::String, DeserializeError > Read(std::span< const std::byte > data) noexcept
Decodes text.
static BinaryData Write(const Safe::String &data) noexcept
Encodes data.
static ByteSize Size(const Safe::String &data) noexcept
Serialized size of data.
static Expected< Safe::WCString, DeserializeError > Read(std::span< const std::byte > data) noexcept
Decodes a StormByte::Safe::WCString from the start of data.
static ByteSize Size(const Safe::WCString &data) noexcept
Serialized size of data.
static BinaryData Write(const Safe::WCString &data) noexcept
Encodes data.
static Expected< Safe::WString, DeserializeError > Read(std::span< const std::byte > data) noexcept
Decodes text.
static ByteSize Size(const Safe::WString &data) noexcept
Serialized size of data.
static BinaryData Write(const Safe::WString &data) noexcept
Encodes data.
static Expected< std::string, DeserializeError > Read(std::span< const std::byte > data) noexcept
Decodes a string from the start of data.
static BinaryData Write(const std::string &data) noexcept
Encodes data.
static ByteSize Size(const std::string &data) noexcept
Serialized size of data.
static BinaryData Write(const std::u16string &data) noexcept
Encodes data.
static Expected< std::u16string, DeserializeError > Read(std::span< const std::byte > data) noexcept
Decodes a UTF-16 string from the start of data.
static ByteSize Size(const std::u16string &data) noexcept
Serialized size of data.
static BinaryData Write(const std::u32string &data) noexcept
Encodes data.
static ByteSize Size(const std::u32string &data) noexcept
Serialized size of data.
static Expected< std::u32string, DeserializeError > Read(std::span< const std::byte > data) noexcept
Decodes a UTF-32 string from the start of data.
static Expected< std::wstring, DeserializeError > Read(std::span< const std::byte > data) noexcept
Decodes a wide string from the start of data.
static ByteSize Size(const std::wstring &data) noexcept
Serialized size of data.
static BinaryData Write(const std::wstring &data) noexcept
Encodes data.
Size / write / read for one type T.
Definition serializable.hxx:109
static ByteSize Size(const T &data) noexcept
Serialized size of data.
Definition serializable.hxx:115
static BinaryData Write(const T &data) noexcept
Encodes data to a little-endian blob.
Definition serializable.hxx:127
static Expected< T, DeserializeError > Read(std::span< const std::byte > data) noexcept
Decodes T from the start of data.
Definition serializable.hxx:139
#define STORMBYTE_PUBLIC
Definition visibility.h:52