24 #ifndef STATICLIB_IO_OPERATIONS_HPP
25 #define STATICLIB_IO_OPERATIONS_HPP
36 #include "staticlib/config.hpp"
55 template<
typename Sink>
57 size_t ulen = span.
size();
59 while (result < ulen) {
60 std::streamsize amt = sink.write({span.
data() + result,
static_cast<std::streamsize
>(ulen - result)});
61 if (!sl::support::is_sizet(amt))
throw io_exception(TRACEMSG(
62 "Invalid result returned by underlying 'write' operation: [" + sl::support::to_string(amt) +
"]"));
63 result +=
static_cast<size_t>(amt);
75 template<
typename Source>
77 size_t ulen = span.
size();
79 while (result < ulen) {
80 std::streamsize amt = src.read({span.
data() + result,
static_cast<std::streamsize
> (ulen - result)});
81 if (std::char_traits<char>::eof() != amt) {
82 if (!sl::support::is_sizet(amt))
throw io_exception(TRACEMSG(
83 "Invalid result returned by underlying 'read' operation: [" + sl::support::to_string(amt) +
"]"));
84 result +=
static_cast<size_t> (amt);
97 template<
typename Source>
101 "Read amount: [" + sl::support::to_string(res) +
"]" +
102 " of expected: [" + sl::support::to_string(span.
size()) +
"]"));
114 template<
typename Source,
typename Sink>
116 size_t ulen = span.
size();
119 while (ulen == (amt =
read_all(src, span))) {
139 template<
typename Source,
typename Sink, u
int16_t BufferSize = 4096>
141 std::array<char, BufferSize> buf;
154 template<
typename Source,
typename IntTypeSkip>
156 if (!(sl::support::is_sizet(to_skip) && sl::support::is_streamsize(to_skip)))
throw io_exception(TRACEMSG(
157 "Invalid 'skip' parameter specified, to_skip: [" + sl::support::to_string(to_skip) +
"]"));
158 size_t ulen = span.
size();
159 size_t uskip =
static_cast<size_t>(to_skip);
161 size_t chunklen = uskip <= ulen ? uskip : ulen;
174 inline std::string
str_replace(
const std::string& input, std::map<std::string, std::string> values) {
180 return sink.get_string();