#include <SkStream.h>
Inherits SkStream.
Public Member Functions | |
SkBufferStream (SkStream *proxy, size_t bufferSize=0) | |
SkBufferStream (SkStream *proxy, void *buffer, size_t bufferSize) | |
virtual | ~SkBufferStream () |
virtual bool | rewind () |
virtual const char * | getFileName () |
virtual size_t | read (void *buffer, size_t size) |
virtual const void * | getMemoryBase () |
This is a wrapper class that adds buffering to another stream. The caller can provide the buffer, or ask SkBufferStream to allocated/free it automatically.
Definition at line 198 of file SkStream.h.
SkBufferStream::SkBufferStream | ( | SkStream * | proxy, | |
size_t | bufferSize = 0 | |||
) |
Provide the stream to be buffered (proxy), and the size of the buffer that should be used. This will be allocated and freed automatically. If bufferSize is 0, a default buffer size will be used. The proxy stream is referenced, and will be unreferenced in when the bufferstream is destroyed.
SkBufferStream::SkBufferStream | ( | SkStream * | proxy, | |
void * | buffer, | |||
size_t | bufferSize | |||
) |
Provide the stream to be buffered (proxy), and a buffer and size to be used. This buffer is owned by the caller, and must be at least bufferSize bytes big. Passing NULL for buffer will cause the buffer to be allocated/freed automatically. If buffer is not NULL, it is an error for bufferSize to be 0. The proxy stream is referenced, and will be unreferenced in when the bufferstream is destroyed.
virtual SkBufferStream::~SkBufferStream | ( | ) | [virtual] |
virtual const char* SkBufferStream::getFileName | ( | ) | [virtual] |
If this stream represents a file, this method returns the file's name. If it does not, it returns NULL (the default behavior).
Reimplemented from SkStream.
virtual const void* SkBufferStream::getMemoryBase | ( | ) | [virtual] |
If the stream is backed by RAM, this method returns the starting address for the data. If not (i.e. it is backed by a file or other structure), this method returns NULL. The default implementation returns NULL.
Reimplemented from SkStream.
virtual size_t SkBufferStream::read | ( | void * | buffer, | |
size_t | size | |||
) | [virtual] |
Called to read or skip size number of bytes. If buffer is NULL and size > 0, skip that many bytes, returning how many were skipped. If buffer is NULL and size == 0, return the total length of the stream. If buffer != NULL, copy the requested number of bytes into buffer, returning how many were copied.
buffer | If buffer is NULL, ignore and just skip size bytes, otherwise copy size bytes into buffer | |
size | The number of bytes to skip or copy |
Implements SkStream.
virtual bool SkBufferStream::rewind | ( | ) | [virtual] |
Called to rewind to the beginning of the stream. If this cannot be done, return false.
Implements SkStream.