diff options
author | Aki <please@ignore.pl> | 2024-03-18 23:41:20 +0100 |
---|---|---|
committer | Aki <please@ignore.pl> | 2024-03-18 23:41:20 +0100 |
commit | 2066e4911948d11cac5a234d2f7773dc5f06ba96 (patch) | |
tree | 27c7672aad884d1307736b3d15e704d7d786b314 /FoundationEx/src/reader/buffer.inl.h | |
parent | 3df6ccddcbd881c2474746f5f1758b095c866a67 (diff) | |
download | starshatter-2066e4911948d11cac5a234d2f7773dc5f06ba96.zip starshatter-2066e4911948d11cac5a234d2f7773dc5f06ba96.tar.gz starshatter-2066e4911948d11cac5a234d2f7773dc5f06ba96.tar.bz2 |
Added filesystem-only starshatter::data DataLoader replacement
Step by step. The intent is to find a good spot between current data
representations and the standard library and put the intermediate
stage there. After it matures a bit, we can move further away.
Diffstat (limited to 'FoundationEx/src/reader/buffer.inl.h')
-rw-r--r-- | FoundationEx/src/reader/buffer.inl.h | 16 |
1 files changed, 11 insertions, 5 deletions
diff --git a/FoundationEx/src/reader/buffer.inl.h b/FoundationEx/src/reader/buffer.inl.h index 3b739e4..c452878 100644 --- a/FoundationEx/src/reader/buffer.inl.h +++ b/FoundationEx/src/reader/buffer.inl.h @@ -8,8 +8,9 @@ #include <cstring> #include <memory> #include <utility> +#include <vector> -#include <starshatter/foundation/reader.h> +#include <Text.h> namespace starshatter @@ -124,16 +125,21 @@ Count BufferReader<Source>::peek(char* dest, Count bytes) const { bytes = std::min(bytes, available()); - std::copy(data(), data() + bytes, dest); + std::copy(at(buffer) + position, at(buffer) + position + bytes, dest); return bytes; } template <typename Source> -const char* -BufferReader<Source>::data() const +Text +BufferReader<Source>::more() { - return at(buffer) + position; + const auto size = available(); + if (size < 1) + return Text(); + std::vector<char> tmp(size); + read(tmp.data(), size); + return Text(tmp.data(), size); } |