12 #ifndef DOCWIRE_MEMORY_STREAM_H
13 #define DOCWIRE_MEMORY_STREAM_H
39 std::span<const std::byte> m_source;
50 char* p =
const_cast<char*
>(
reinterpret_cast<const char*
>(m_source.data()));
51 setg(p, p, p + m_source.size());
61 std::streampos
seekpos(std::streampos sp, std::ios_base::openmode which = std::ios_base::in)
override
63 if (which != std::ios_base::in || sp < 0 || sp > m_source.size())
65 char* p =
const_cast<char*
>(
reinterpret_cast<const char*
>(m_source.data()));
66 setg(p, p + sp, p + m_source.size());
78 std::streampos
seekoff(std::streamoff off, std::ios_base::seekdir way, std::ios_base::openmode which = std::ios_base::in)
override
80 if (which != std::ios_base::in)
84 case std::ios_base::beg:
86 case std::ios_base::cur:
87 return seekpos(gptr() - eback() + off, which);
88 case std::ios_base::end:
89 return seekpos(m_source.size() + off , which);
121 : std::istream(&m_streambuf), m_streambuf(source)
imemorystream is a stream that wraps a std::span of const std::byte and provides a compatible interfa...
imemorystream(std::span< const std::byte > source)
Construct a new imemorystream object.
imemorystreambuf is a stream buffer that wraps std::span<const std::byte> and provides a compatible i...
std::streampos seekoff(std::streamoff off, std::ios_base::seekdir way, std::ios_base::openmode which=std::ios_base::in) override
Move the position of the stream buffer.
imemorystreambuf(std::span< const std::byte > source)
Construct a new imemorystreambuf object.
std::streampos seekpos(std::streampos sp, std::ios_base::openmode which=std::ios_base::in) override
Set the position of the stream buffer.
The main namespace for the DocWire SDK.