Vault  4.1
Public Member Functions
VStreamCopier Class Reference

VStreamCopier is a helper class for certain kinds of stream copy operations. More...

#include <vstreamcopier.h>

List of all members.

Public Member Functions

 VStreamCopier ()
 Default constructor.
 VStreamCopier (int chunkSize, VStream *from, VStream *to)
 Constructor that takes two VStream objects.
 VStreamCopier (int chunkSize, VIOStream *from, VIOStream *to)
 Constructor that takes two VIOStream objects.
 VStreamCopier (int chunkSize, VStream *from, VIOStream *to)
 Constructor that takes a VStream and a VIOStream.
 VStreamCopier (int chunkSize, VIOStream *from, VStream *to)
 Constructor that takes a VIOStream and a VStream.
virtual ~VStreamCopier ()
 Destructor.
void init (int chunkSize, VStream *from, VStream *to)
 Init function that takes two VStream objects.
void init (int chunkSize, VIOStream *from, VIOStream *to)
 Init function that takes two VIOStream objects.
void init (int chunkSize, VStream *from, VIOStream *to)
 Init function that takes a VStream and a VIOStream.
void init (int chunkSize, VIOStream *from, VStream *to)
 Init function that takes a VIOStream and a VStream.
bool copyChunk ()
 Copies a chunk between the streams, and returns false if less than a complete chunk was available to copy.
Vs64 numBytesCopied () const
 Returns the number of bytes copied so far.

Detailed Description

VStreamCopier is a helper class for certain kinds of stream copy operations.

In many cases you can just call streamCopy(), which is defined in vstream.h and viostream.h for use with any pair of VStream or VIOStream objects. It is a trivially easy way to perform stream-to-stream copies.

VStreamCopier allows you to do a bulk stream-to-stream copy operation, but unlike streamCopy(), which does it in a single call, VStreamCopier lets you perform the copy iteratively, in chunks. This is useful if you need to monitor the progress of a large copy. An example is when you are providing user feedback and want to update the progress. If you were to just use streamCopy() in a single call, you'd not be able to see the progress until the copy is complete.

You can supply any pair of streams in the constructor, either VStream-based or VIOStream-based, in any combination. You also supply the chunk size.

Then you repeatedly call copyChunk() in a while loop until it returns false. A return value of true indicates that the copy has not run out of data yet, although it's possible that the next copy will discover that there are no more bytes left to copy (EOF), but that's not an error. To check the actual byte count progress, call numBytesCopied().

See also:
VIOStream
VStream

Definition at line 53 of file vstreamcopier.h.


Constructor & Destructor Documentation

VStreamCopier::VStreamCopier ( )

Default constructor.

You need to call init() later if you use this constructor.

Definition at line 14 of file vstreamcopier.cpp.

VStreamCopier::VStreamCopier ( int  chunkSize,
VStream from,
VStream to 
)

Constructor that takes two VStream objects.

Parameters:
chunkSizethe number of bytes to copy in each chunk
fromthe stream to copy from
tothe stream to copy to

Definition at line 22 of file vstreamcopier.cpp.

VStreamCopier::VStreamCopier ( int  chunkSize,
VIOStream from,
VIOStream to 
)

Constructor that takes two VIOStream objects.

Parameters:
chunkSizethe number of bytes to copy in each chunk
fromthe stream to copy from
tothe stream to copy to

Definition at line 30 of file vstreamcopier.cpp.

VStreamCopier::VStreamCopier ( int  chunkSize,
VStream from,
VIOStream to 
)

Constructor that takes a VStream and a VIOStream.

Parameters:
chunkSizethe number of bytes to copy in each chunk
fromthe stream to copy from
tothe stream to copy to

Definition at line 38 of file vstreamcopier.cpp.

VStreamCopier::VStreamCopier ( int  chunkSize,
VIOStream from,
VStream to 
)

Constructor that takes a VIOStream and a VStream.

Parameters:
chunkSizethe number of bytes to copy in each chunk
fromthe stream to copy from
tothe stream to copy to

Definition at line 46 of file vstreamcopier.cpp.


Member Function Documentation

void VStreamCopier::init ( int  chunkSize,
VStream from,
VStream to 
)

Init function that takes two VStream objects.

Parameters:
chunkSizethe number of bytes to copy in each chunk
fromthe stream to copy from
tothe stream to copy to

Definition at line 54 of file vstreamcopier.cpp.

void VStreamCopier::init ( int  chunkSize,
VIOStream from,
VIOStream to 
)

Init function that takes two VIOStream objects.

Parameters:
chunkSizethe number of bytes to copy in each chunk
fromthe stream to copy from
tothe stream to copy to

Definition at line 61 of file vstreamcopier.cpp.

References VIOStream::getRawStream().

void VStreamCopier::init ( int  chunkSize,
VStream from,
VIOStream to 
)

Init function that takes a VStream and a VIOStream.

Parameters:
chunkSizethe number of bytes to copy in each chunk
fromthe stream to copy from
tothe stream to copy to

Definition at line 68 of file vstreamcopier.cpp.

References VIOStream::getRawStream().

void VStreamCopier::init ( int  chunkSize,
VIOStream from,
VStream to 
)

Init function that takes a VIOStream and a VStream.

Parameters:
chunkSizethe number of bytes to copy in each chunk
fromthe stream to copy from
tothe stream to copy to

Definition at line 75 of file vstreamcopier.cpp.

References VIOStream::getRawStream().

bool VStreamCopier::copyChunk ( )

Copies a chunk between the streams, and returns false if less than a complete chunk was available to copy.

That is, true indicates that you should call this function again, and false indicates that the copy operation is complete.

Returns:
true if there is more data to copy

Definition at line 82 of file vstreamcopier.cpp.

References NULL, and VStream::streamCopy().

Vs64 VStreamCopier::numBytesCopied ( ) const

Returns the number of bytes copied so far.

Returns:
the number of bytes copied so far

Definition at line 95 of file vstreamcopier.cpp.


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

Copyright ©1997-2014 Trygve Isaacson. All rights reserved. This documentation was generated with Doxygen.