![]() |
Vault
4.1
|
VStreamCopier is a helper class for certain kinds of stream copy operations. More...
#include <vstreamcopier.h>
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. |
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().
Definition at line 53 of file vstreamcopier.h.
VStreamCopier::VStreamCopier | ( | ) |
Default constructor.
You need to call init() later if you use this constructor.
Definition at line 14 of file vstreamcopier.cpp.
Constructor that takes two VStream objects.
chunkSize | the number of bytes to copy in each chunk |
from | the stream to copy from |
to | the stream to copy to |
Definition at line 22 of file vstreamcopier.cpp.
Constructor that takes two VIOStream objects.
chunkSize | the number of bytes to copy in each chunk |
from | the stream to copy from |
to | the stream to copy to |
Definition at line 30 of file vstreamcopier.cpp.
Constructor that takes a VStream and a VIOStream.
chunkSize | the number of bytes to copy in each chunk |
from | the stream to copy from |
to | the stream to copy to |
Definition at line 38 of file vstreamcopier.cpp.
Constructor that takes a VIOStream and a VStream.
chunkSize | the number of bytes to copy in each chunk |
from | the stream to copy from |
to | the stream to copy to |
Definition at line 46 of file vstreamcopier.cpp.
Init function that takes two VStream objects.
chunkSize | the number of bytes to copy in each chunk |
from | the stream to copy from |
to | the stream to copy to |
Definition at line 54 of file vstreamcopier.cpp.
Init function that takes two VIOStream objects.
chunkSize | the number of bytes to copy in each chunk |
from | the stream to copy from |
to | the stream to copy to |
Definition at line 61 of file vstreamcopier.cpp.
References VIOStream::getRawStream().
Init function that takes a VStream and a VIOStream.
chunkSize | the number of bytes to copy in each chunk |
from | the stream to copy from |
to | the stream to copy to |
Definition at line 68 of file vstreamcopier.cpp.
References VIOStream::getRawStream().
Init function that takes a VIOStream and a VStream.
chunkSize | the number of bytes to copy in each chunk |
from | the stream to copy from |
to | the 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.
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.
Definition at line 95 of file vstreamcopier.cpp.