BinaryWriter: allow writing string literals.

This commit is contained in:
Guillaume Jacquemin 2022-02-12 11:21:23 +01:00
parent a6c0614979
commit 8f1e3668a3
2 changed files with 6 additions and 2 deletions

View file

@ -102,7 +102,7 @@ auto BinaryWriter::writeDouble(Double value) -> bool {
return std::fwrite(&value, sizeof(Double), 1, _file) == 1; return std::fwrite(&value, sizeof(Double), 1, _file) == 1;
} }
auto BinaryWriter::writeArray(Containers::ArrayView<char> array) -> bool { auto BinaryWriter::writeArray(Containers::ArrayView<const char> array) -> bool {
if(array.size() == 0) { if(array.size() == 0) {
return false; return false;
} }

View file

@ -59,7 +59,11 @@ class BinaryWriter {
auto writeUnsignedLong(UnsignedLong value) -> bool; auto writeUnsignedLong(UnsignedLong value) -> bool;
auto writeFloat(Float value) -> bool; auto writeFloat(Float value) -> bool;
auto writeDouble(Double value) -> bool; auto writeDouble(Double value) -> bool;
auto writeArray(Containers::ArrayView<char> array) -> bool; auto writeArray(Containers::ArrayView<const char> array) -> bool;
template<std::size_t size>
auto writeString(const char(&str)[size]) -> bool {
return writeArray({str, size - 1});
}
template<std::size_t S> template<std::size_t S>
auto writeStaticArray(Containers::StaticArrayView<S, const char> array) -> bool { auto writeStaticArray(Containers::StaticArrayView<S, const char> array) -> bool {