C++ Utilities 5.26.1
Useful C++ classes and routines such as argument parser, IO and conversion utilities
Loading...
Searching...
No Matches
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.
 
void copy (std::istream &input, std::ostream &output, std::uint64_t count)
 Copies count bytes from input to output.
 
void callbackCopy (std::istream &input, std::ostream &output, std::uint64_t count, const std::function< bool(void)> &isAborted, const std::function< void(double)> &callback)
 Copies count bytes from input to output.
 
void copy (NativeFileStream &input, NativeFileStream &output, std::uint64_t count)
 Copies count bytes from input to output.
 
void callbackCopy (NativeFileStream &input, NativeFileStream &output, std::uint64_t count, const std::function< bool(void)> &isAborted, const std::function< void(double)> &callback)
 Copies count bytes from input to output.
 
char * buffer ()
 Returns the internal buffer.
 

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 chunk/buffer size.

Definition at line 30 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 48 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 196 of file copy.h.

◆ callbackCopy() [1/2]

template<std::size_t bufferSize>
void CppUtilities::CopyHelper< bufferSize >::callbackCopy ( NativeFileStream & input,
NativeFileStream & output,
std::uint64_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.

Before processing the next chunk isAborted is checked and the copying aborted if it returns true. Before processing the next chunk callback is invoked to report the current progress.

  • 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.

Definition at line 151 of file copy.h.

◆ callbackCopy() [2/2]

template<std::size_t bufferSize>
void CppUtilities::CopyHelper< bufferSize >::callbackCopy ( std::istream & input,
std::ostream & output,
std::uint64_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.

Before processing the next chunk isAborted is checked and the copying aborted if it returns true. Before processing the next chunk callback is invoked to report the current progress.

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 79 of file copy.h.

◆ copy() [1/2]

template<std::size_t bufferSize>
void CppUtilities::CopyHelper< bufferSize >::copy ( NativeFileStream & input,
NativeFileStream & output,
std::uint64_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.

Definition at line 104 of file copy.h.

◆ copy() [2/2]

template<std::size_t bufferSize>
void CppUtilities::CopyHelper< bufferSize >::copy ( std::istream & input,
std::ostream & output,
std::uint64_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 57 of file copy.h.


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