C++ Utilities  5.10.5
Useful C++ classes and routines such as argument parser, IO and conversion utilities
Public Member Functions | List of all members
CppUtilities::CopyHelper< bufferSize > Class Template Reference

The CopyHelper class helps to copy bytes from one stream to another. More...

#include <copy.h>

Public Member Functions

 CopyHelper ()
 Constructs a new copy helper. More...
 
void copy (std::istream &input, std::ostream &output, std::size_t count)
 Copies count bytes from input to output. More...
 
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. More...
 
void copy (NativeFileStream &input, NativeFileStream &output, std::size_t count)
 Copies count bytes from input to output. More...
 
void callbackCopy (NativeFileStream &input, NativeFileStream &output, std::size_t count, const std::function< bool(void)> &isAborted, const std::function< void(double)> &callback)
 Copies count bytes from input to output. More...
 
char * buffer ()
 Returns the internal buffer. More...
 

Detailed Description

template<std::size_t bufferSize>
class CppUtilities::CopyHelper< bufferSize >

The CopyHelper class helps to copy bytes from one stream to another.

Template Parameters
Specifiesthe buffer size.

Definition at line 16 of file copy.h.

Constructor & Destructor Documentation

◆ CopyHelper()

template<std::size_t bufferSize>
CppUtilities::CopyHelper< bufferSize >::CopyHelper

Constructs a new copy helper.

Definition at line 34 of file copy.h.

Member Function Documentation

◆ buffer()

template<std::size_t bufferSize>
char * CppUtilities::CopyHelper< bufferSize >::buffer

Returns the internal buffer.

Definition at line 116 of file copy.h.

◆ callbackCopy() [1/2]

template<std::size_t bufferSize>
void CppUtilities::CopyHelper< bufferSize >::callbackCopy ( NativeFileStream input,
NativeFileStream output,
std::size_t  count,
const std::function< bool(void)> &  isAborted,
const std::function< void(double)> &  callback 
)

Copies count bytes from input to output.

The procedure might be aborted and progress updates will be reported.

Copying is aborted when isAborted returns true. The current progress is reported by calling the specified callback function.

  • Set an exception mask using std::ios::exceptions() to get a std::ios_base::failure exception when an IO error occurs.
  • Possibly uses native APIs such as POSIX sendfile() to improve the speed (not implemented yet).

Definition at line 107 of file copy.h.

◆ callbackCopy() [2/2]

template<std::size_t bufferSize>
void CppUtilities::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 
)

Copies count bytes from input to output.

The procedure might be aborted and progress updates will be reported.

Copying is aborted when isAborted returns true. The current progress is reported by calling the specified callback function.

Remarks
Set an exception mask using std::ios::exceptions() to get a std::ios_base::failure exception when an IO error occurs.

Definition at line 65 of file copy.h.

◆ copy() [1/2]

template<std::size_t bufferSize>
void CppUtilities::CopyHelper< bufferSize >::copy ( NativeFileStream input,
NativeFileStream output,
std::size_t  count 
)

Copies count bytes from input to output.

Remarks
  • Set an exception mask using std::ios::exceptions() to get a std::ios_base::failure exception when an IO error occurs.
  • Possibly uses native APIs such as POSIX sendfile() to improve the speed (not implemented yet).

Definition at line 90 of file copy.h.

◆ copy() [2/2]

template<std::size_t bufferSize>
void CppUtilities::CopyHelper< bufferSize >::copy ( std::istream &  input,
std::ostream &  output,
std::size_t  count 
)

Copies count bytes from input to output.

Remarks
Set an exception mask using std::ios::exceptions() to get a std::ios_base::failure exception when an IO error occurs.

Definition at line 43 of file copy.h.


The documentation for this class was generated from the following file: