24 #ifndef STATICLIB_IO_LIMITED_SOURCE_HPP
25 #define STATICLIB_IO_LIMITED_SOURCE_HPP
29 #include "staticlib/config.hpp"
43 template<
typename Source>
66 limit_bytes(limit_bytes) { }
89 src(std::move(other.src)),
90 limit_bytes(other.limit_bytes) {
91 other.limit_bytes = 0;
101 src = std::move(other.src);
102 limit_bytes = other.limit_bytes;
103 other.limit_bytes = 0;
114 if (src.get_count() < limit_bytes) {
115 size_t ulen = origin_span.
size();
116 auto remaining_bytes = limit_bytes - src.get_count();
117 auto read_length = (ulen < remaining_bytes) ? ulen : remaining_bytes;
118 return src.read(
span<char> {origin_span.
data(),
static_cast<uint32_t
>(read_length)});
120 return std::char_traits<char>::eof();
130 return src.get_count();
139 return src.get_source();
152 template <
typename Source,
153 class =
typename std::enable_if<!std::is_lvalue_reference<Source>::value>::type>
166 template <
typename Source>