diff options
Diffstat (limited to 'serialize/binary-serializer.hpp')
-rw-r--r-- | serialize/binary-serializer.hpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/serialize/binary-serializer.hpp b/serialize/binary-serializer.hpp index bab729f4..7ac665be 100644 --- a/serialize/binary-serializer.hpp +++ b/serialize/binary-serializer.hpp @@ -7,6 +7,13 @@ #include <concepts> #include <type_traits> +namespace Corrade::Containers { + +template<typename T> class BasicStringView; +using StringView = BasicStringView<const char>; + +} // namespace Corrade::Containers + namespace floormat::Serialize { static_assert(std::endian::native == std::endian::big || std::endian::native == std::endian::little); @@ -92,14 +99,18 @@ binary_reader(Array&& array) -> binary_reader<std::decay_t<decltype(std::begin(a template<std::output_iterator<char> It> struct binary_writer final { explicit constexpr binary_writer(It it) noexcept; - template<integer T> void write(T x) noexcept; + template<integer T> constexpr void write(T x) noexcept; template<std::floating_point T> void write(T x) noexcept; + constexpr void write_asciiz_string(StringView str) noexcept; + + constexpr std::size_t bytes_written() const noexcept { return _bytes_written; } private: It it; + std::size_t _bytes_written; }; template<std::output_iterator<char> It, serializable T> -binary_writer<It>& operator<<(binary_writer<It>& writer, T x) noexcept; +constexpr binary_writer<It>& operator<<(binary_writer<It>& writer, T x) noexcept; } // namespace floormat::Serialize |