![]() |
Vault
4.1
|
VSocketStream is a concrete VStream class that knows how to do i/o on a VSocket. More...
#include <vsocketstream.h>
Public Member Functions | |
VSocketStream (const VString &name) | |
Empty constructor for use with a subsequent call to setSocket(). | |
VSocketStream (VSocket *socket, const VString &name) | |
Constructs a VSocketStream to use a specified VSocket. | |
VSocketStream (const VSocketStream &other) | |
Copy constructor. | |
virtual | ~VSocketStream () |
Destructor. | |
VSocketStream & | operator= (const VSocketStream &other) |
Assignment operator. | |
VSocket * | getSocket () const |
Returns a pointer to the VSocket object used by this VSocketStream. | |
void | setSocket (VSocket *socket) |
Assigns a new VSocket object for this stream to do i/o on. | |
virtual Vs64 | read (Vu8 *targetBuffer, Vs64 numBytesToRead) |
Reads bytes from the stream into a buffer. | |
virtual Vs64 | write (const Vu8 *buffer, Vs64 numBytesToWrite) |
Writes bytes from a buffer into the stream. | |
virtual void | flush () |
Flushes any pending write data to the underlying stream. | |
virtual bool | skip (Vs64 numBytesToSkip) |
Skips over a number of bytes in the input (read) stream. | |
virtual bool | seek (Vs64 offset, int whence) |
Seeks in the stream; note that VSocketStream only supports seeking forward (offset >= 0, whence = SEEK_CUR) and will throw a VException if the caller requests an illegal seek operation. | |
virtual Vs64 | getIOOffset () const |
Returns the current offset in the stream. | |
virtual Vs64 | available () const |
Returns the number of bytes that are available to be read from this stream. |
VSocketStream is a concrete VStream class that knows how to do i/o on a VSocket.
It is recommended to use a VIOStream object rather than read/write on a VSocketStream directly.
Definition at line 32 of file vsocketstream.h.
VSocketStream::VSocketStream | ( | const VString & | name | ) |
Empty constructor for use with a subsequent call to setSocket().
name | an arbitrary name given to this stream |
Definition at line 15 of file vsocketstream.cpp.
Constructs a VSocketStream to use a specified VSocket.
socket | the socket to do i/o on |
name | an arbitrary name given to this stream |
Definition at line 21 of file vsocketstream.cpp.
VSocketStream::VSocketStream | ( | const VSocketStream & | other | ) |
Copy constructor.
Both streams will share the same socket unless a call to setSocket() is subsequently made on one of them.
Definition at line 27 of file vsocketstream.cpp.
VSocketStream & VSocketStream::operator= | ( | const VSocketStream & | other | ) |
Assignment operator.
Both streams will share the same socket unless a call to setSocket() is subsequently made on one of them.
Definition at line 33 of file vsocketstream.cpp.
References VStream::mName.
VSocket * VSocketStream::getSocket | ( | ) | const |
Returns a pointer to the VSocket object used by this VSocketStream.
Definition at line 39 of file vsocketstream.cpp.
void VSocketStream::setSocket | ( | VSocket * | socket | ) |
Assigns a new VSocket object for this stream to do i/o on.
socket | the stream to do subsequent i/o on |
Definition at line 43 of file vsocketstream.cpp.
Reads bytes from the stream into a buffer.
targetBuffer | the buffer to read into |
numBytesToRead | the number of bytes to read |
Implements VStream.
Definition at line 47 of file vsocketstream.cpp.
References VSocket::read().
Writes bytes from a buffer into the stream.
buffer | the buffer to read from |
numBytesToWrite | the number of bytes to write |
Implements VStream.
Definition at line 51 of file vsocketstream.cpp.
References VSocket::write().
bool VSocketStream::skip | ( | Vs64 | numBytesToSkip | ) | [virtual] |
Skips over a number of bytes in the input (read) stream.
numBytesToSkip | the number of bytes to skip over |
Implements VStream.
Definition at line 59 of file vsocketstream.cpp.
References read().
bool VSocketStream::seek | ( | Vs64 | offset, |
int | whence | ||
) | [virtual] |
Seeks in the stream; note that VSocketStream only supports seeking forward (offset >= 0, whence = SEEK_CUR) and will throw a VException if the caller requests an illegal seek operation.
offset | the offset (meaning depends on whence param) |
whence | SEEK_SET, SEEK_CUR, or SEEK_END |
Implements VStream.
Definition at line 75 of file vsocketstream.cpp.
References skip().
Vs64 VSocketStream::getIOOffset | ( | ) | const [virtual] |
Returns the current offset in the stream.
For file streams, this returns the number of accumulated bytes read and/or written.
Implements VStream.
Definition at line 83 of file vsocketstream.cpp.
References VSocket::numBytesRead().
Vs64 VSocketStream::available | ( | ) | const [virtual] |
Returns the number of bytes that are available to be read from this stream.
For file and memory streams, this means the number of bytes from the current i/o mark until the end of the file or buffer. For socket streams, this means the number of bytes that can be read without blocking (that is, the number of bytes that are waiting to be read on the socket at this time).
Implements VStream.
Definition at line 87 of file vsocketstream.cpp.
References VSocket::available().