diff options
author | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-28 18:08:13 +0200 |
---|---|---|
committer | Stanislaw Halik <sthalik@misaki.pl> | 2022-10-28 18:08:13 +0200 |
commit | 7c02d3b8f1e6ec4ee82bdf1220da431b1cd1231e (patch) | |
tree | eea6effd759fdc9cd81f33b732979854eb226e39 /serialize/binary-writer.hpp | |
parent | fa07c1fd19e7fbd3b2757583708c4691c79025ed (diff) |
serializer work
Diffstat (limited to 'serialize/binary-writer.hpp')
-rw-r--r-- | serialize/binary-writer.hpp | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/serialize/binary-writer.hpp b/serialize/binary-writer.hpp new file mode 100644 index 00000000..ead0824d --- /dev/null +++ b/serialize/binary-writer.hpp @@ -0,0 +1,25 @@ +#pragma once
+#include "binary-serializer.hpp"
+#include <iterator>
+#include <Corrade/Containers/StringView.h>
+
+namespace floormat::Serialize {
+
+template<std::output_iterator<char> It>
+struct binary_writer final {
+ explicit constexpr binary_writer(It it) 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>
+constexpr binary_writer<It>& operator<<(binary_writer<It>& writer, T x) noexcept;
+
+} // namespace floormat::Serialize
|