1 #ifndef IOUTILITIES_COPY_H 2 #define IOUTILITIES_COPY_H 16 template<std::
size_t bufferSize>
21 void copy(std::istream &input, std::ostream &output, std::size_t count);
22 void callbackCopy(std::istream &input, std::ostream &output, std::size_t count,
const std::function<
bool (
void)> &isAborted,
const std::function<
void (
double)> &callback);
25 char m_buffer[bufferSize];
31 template<std::
size_t bufferSize>
40 template<std::
size_t bufferSize>
43 while(count > bufferSize) {
44 input.read(m_buffer, bufferSize);
45 output.write(m_buffer, bufferSize);
48 input.read(m_buffer, count);
49 output.write(m_buffer, count);
63 template<std::
size_t bufferSize>
64 void CopyHelper<bufferSize>::callbackCopy(std::istream &input, std::ostream &output, std::size_t count,
const std::function<
bool (
void)> &isAborted,
const std::function<
void (
double)> &callback)
66 const std::size_t totalBytes = count;
67 while(count > bufferSize) {
68 input.read(m_buffer, bufferSize);
69 output.write(m_buffer, bufferSize);
74 callback(static_cast<double>(totalBytes - count) / totalBytes);
76 input.read(m_buffer, count);
77 output.write(m_buffer, count);
84 template<std::
size_t bufferSize>
92 #endif // IOUTILITIES_COPY_H 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.
#define CPP_UTILITIES_EXPORT
Marks the symbol to be exported by the c++utilities library.
CopyHelper()
Constructs a new copy helper.