1 #ifndef IOUTILITIES_COPY_H 2 #define IOUTILITIES_COPY_H 19 void copy(std::istream &input, std::ostream &output, std::size_t count);
20 void callbackCopy(std::istream &input, std::ostream &output, std::size_t count,
const std::function<
bool(
void)> &isAborted,
21 const std::function<
void(
double)> &callback);
25 char m_buffer[bufferSize];
42 while (count > bufferSize) {
43 input.read(m_buffer, bufferSize);
44 output.write(m_buffer, bufferSize);
47 input.read(m_buffer, count);
48 output.write(m_buffer, count);
61 template <std::
size_t bufferSize>
63 const std::function<
void(
double)> &callback)
65 const std::size_t totalBytes = count;
66 while (count > bufferSize) {
67 input.read(m_buffer, bufferSize);
68 output.write(m_buffer, bufferSize);
73 callback(static_cast<double>(totalBytes - count) / totalBytes);
75 input.read(m_buffer, count);
76 output.write(m_buffer, count);
89 #endif // IOUTILITIES_COPY_H #define CPP_UTILITIES_EXPORT
char * buffer()
Returns the internal buffer.
The CopyHelper class helps to copy bytes from one stream to another.
void callbackCopy(std::istream &input, std::ostream &output, std::size_t count, const std::function< bool(void)> &isAborted, const std::function< void(double)> &callback)
Copies count bytes from input to output.
Contains utility classes helping to read and write streams.
void copy(std::istream &input, std::ostream &output, std::size_t count)
Copies count bytes from input to output.
CopyHelper()
Constructs a new copy helper.