![]() |
Vault
4.1
|
VReadOnlyMemoryStream is a convenience class that lets you share a single buffer between multiple memory streams. More...
#include <vmemorystream.h>
Public Member Functions | |
VReadOnlyMemoryStream (Vu8 *buffer, Vs64 suppliedEOFOffset) | |
Constructs the object with an existing buffer. | |
VReadOnlyMemoryStream (const VReadOnlyMemoryStream &other) | |
Copy constructor. | |
virtual | ~VReadOnlyMemoryStream () |
Destructor. | |
VReadOnlyMemoryStream & | operator= (const VReadOnlyMemoryStream &other) |
Assignment operator. | |
void | adoptBuffer (Vu8 *buffer, BufferAllocationType allocationType, Vs64 suppliedBufferSize, Vs64 suppliedEOFOffset) |
Makes the object use a specified buffer instead of the one it is currently using. | |
virtual Vs64 | write (const Vu8 *buffer, Vs64 numBytesToWrite) |
Throws a VEOFException because this class is a read-only stream. | |
virtual void | flush () |
Throws a VEOFException because this class is a read-only stream. |
VReadOnlyMemoryStream is a convenience class that lets you share a single buffer between multiple memory streams.
To do this, you can instantiate multiple VReadOnlyMemoryStream objects, supplying them all the same buffer. They will all prevent writing (throwing an exception for any write method), and will not "own" the buffer and so will not delete/free it. The various streams can be independently used to seek and read the stream without affecting the point of view of other readers. This facility even allows you to supply a pointer to a location inside an arbitrary actual buffer (heap or stack) because the VReadOnlyMemoryStream object will never use the pointer for memory managment purposes such as delete or free.
Definition at line 278 of file vmemorystream.h.
Constructs the object with an existing buffer.
buffer | the buffer that the VMemoryStream will work on |
suppliedEOFOffset | the offset of the end of the "valid" data in the supplied buffer |
Definition at line 495 of file vmemorystream.cpp.
void VReadOnlyMemoryStream::adoptBuffer | ( | Vu8 * | buffer, |
BufferAllocationType | allocationType, | ||
Vs64 | suppliedBufferSize, | ||
Vs64 | suppliedEOFOffset | ||
) |
Makes the object use a specified buffer instead of the one it is currently using.
The existing buffer will be deleted/freed if the existing buffer is owned by the VMemoryStream.
buffer | the buffer that the VMemoryStream will work on |
allocationType | how the buffer was allocated, so that VMemoryStream knows the proper way to reallocate it and to delete/free it |
suppliedBufferSize | the size of the supplied buffer |
suppliedEOFOffset | the offset of the end of the "valid" data in the supplied buffer |
Definition at line 508 of file vmemorystream.cpp.