27 #ifndef INNOEXTRACT_STREAM_RESTRICT_HPP 28 #define INNOEXTRACT_STREAM_RESTRICT_HPP 30 #include <boost/cstdint.hpp> 31 #include <boost/iostreams/concepts.hpp> 32 #include <boost/iostreams/read.hpp> 37 template <
typename BaseSource>
41 boost::uint64_t remaining;
46 : base(o.base), remaining(o.remaining) { }
49 : base(source), remaining(size) { }
51 std::streamsize
read(
char * buffer, std::streamsize bytes) {
58 bytes = std::streamsize(std::min(boost::uint64_t(bytes), remaining));
63 std::streamsize nread = boost::iostreams::read(base, buffer, bytes);
67 remaining -= std::min(boost::uint64_t(nread), remaining);
81 template <
typename BaseSource>
88 #endif // INNOEXTRACT_STREAM_RESTRICT_HPP std::streamsize read(char *buffer, std::streamsize bytes)
restricted_source< BaseSource > restrict(BaseSource &source, boost::uint64_t size)
Restricts a source to a specific size from the current position and makes it non-seekable.
restricted_source(const restricted_source &o)
restricted_source(BaseSource &source, boost::uint64_t size)
Like boost::iostreams::restriction, but always has a 64-bit counter.