summaryrefslogtreecommitdiffhomepage
path: root/serialize/binary-reader.inl
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2022-10-29 00:54:19 +0200
committerStanislaw Halik <sthalik@misaki.pl>2022-10-29 00:54:19 +0200
commitb6a42cc53f808c86342d1bcd400ea95e6e7f5762 (patch)
treecd65334638415d037e5544c9af5142eab3d6bc7a /serialize/binary-reader.inl
parent9954b8b4f5fb95470e127a4f24a0c73289dd49a9 (diff)
serializer work
Diffstat (limited to 'serialize/binary-reader.inl')
-rw-r--r--serialize/binary-reader.inl25
1 files changed, 19 insertions, 6 deletions
diff --git a/serialize/binary-reader.inl b/serialize/binary-reader.inl
index ad2d59bc..b3d04109 100644
--- a/serialize/binary-reader.inl
+++ b/serialize/binary-reader.inl
@@ -84,13 +84,26 @@ binary_reader<It>& operator>>(binary_reader<It>& reader, T& x) noexcept
}
template<string_input_iterator It>
-constexpr StringView binary_reader<It>::read_asciiz_string() noexcept
+template<std::size_t MAX>
+auto binary_reader<It>::read_asciiz_string() noexcept
{
- const It pos = it;
- while (it != end)
- if (char c = *it++; c == '\0')
- return StringView{pos, (std::size_t)std::distance(pos, end), StringViewFlag::NullTerminated};
- fm_abort("unexpected EOF while reading a string");
+ struct fixed_string final {
+ char buf[MAX];
+ std::size_t len;
+ };
+
+ fixed_string ret;
+ for (std::size_t i = 0; i < MAX-1 && it != end; i++)
+ {
+ const char c = *it++;
+ ret.buf[i] = c;
+ if (c == '\0')
+ {
+ ret.len = i;
+ return ret;
+ }
+ }
+ fm_abort("can't find string terminator");
}
} // namespace floormat::Serialize