Skia
2D Graphics Library
|
SkStream – abstraction for a source of bytes. More...
#include <SkStream.h>
Public Member Functions | |
virtual | ~SkStream () |
SkStream () | |
virtual size_t | read (void *buffer, size_t size)=0 |
Reads or skips size number of bytes. More... | |
size_t | skip (size_t size) |
Skip size number of bytes. More... | |
virtual size_t | peek (void *, size_t) const |
Attempt to peek at size bytes. More... | |
virtual bool | isAtEnd () const =0 |
Returns true when all the bytes in the stream have been read. More... | |
bool | readS8 (int8_t *) |
bool | readS16 (int16_t *) |
bool | readS32 (int32_t *) |
bool | readU8 (uint8_t *i) |
bool | readU16 (uint16_t *i) |
bool | readU32 (uint32_t *i) |
bool | readBool (bool *b) |
bool | readScalar (SkScalar *) |
bool | readPackedUInt (size_t *) |
virtual bool | rewind () |
Rewinds to the beginning of the stream. More... | |
std::unique_ptr< SkStream > | duplicate () const |
Duplicates this stream. More... | |
std::unique_ptr< SkStream > | fork () const |
Duplicates this stream. More... | |
virtual bool | hasPosition () const |
Returns true if this stream can report its current position. More... | |
virtual size_t | getPosition () const |
Returns the current position in the stream. More... | |
virtual bool | seek (size_t) |
Seeks to an absolute position in the stream. More... | |
virtual bool | move (long) |
Seeks to an relative offset in the stream. More... | |
virtual bool | hasLength () const |
Returns true if this stream can report its total length. More... | |
virtual size_t | getLength () const |
Returns the total length of the stream. More... | |
virtual const void * | getMemoryBase () |
Returns the starting address for the data. More... | |
Static Public Member Functions | |
static std::unique_ptr< SkStreamAsset > | MakeFromFile (const char path[]) |
Attempts to open the specified file as a stream, returns nullptr on failure. More... | |
SkStream – abstraction for a source of bytes.
Subclasses can be backed by memory, or a file, or something else.
|
inlinevirtual |
|
inline |
|
inline |
Duplicates this stream.
If this cannot be done, returns NULL. The returned stream will be positioned at the beginning of its data.
|
inline |
Duplicates this stream.
If this cannot be done, returns NULL. The returned stream will be positioned the same as this stream.
|
inlinevirtual |
Returns the total length of the stream.
If this cannot be done, returns 0.
Reimplemented in SkStreamAsset, SkMemoryStream, and SkFILEStream.
|
inlinevirtual |
Returns the starting address for the data.
If this cannot be done, returns NULL.
Reimplemented in SkStreamMemory, and SkMemoryStream.
|
inlinevirtual |
Returns the current position in the stream.
If this cannot be done, returns 0.
Reimplemented in SkStreamSeekable, SkMemoryStream, and SkFILEStream.
|
inlinevirtual |
Returns true if this stream can report its total length.
Reimplemented in SkStreamAsset.
|
inlinevirtual |
Returns true if this stream can report its current position.
Reimplemented in SkStreamSeekable.
|
pure virtual |
Returns true when all the bytes in the stream have been read.
As SkStream represents synchronous I/O, isAtEnd returns false when the final stream length isn't known yet, even when all the bytes available so far have been read. This may return true early (when there are no more bytes to be read) or late (after the first unsuccessful read).
Implemented in SkMemoryStream, and SkFILEStream.
|
static |
Attempts to open the specified file as a stream, returns nullptr on failure.
|
inlinevirtual |
Seeks to an relative offset in the stream.
If this cannot be done, returns false. If an attempt is made to move to a position outside the stream, the position will be set to the closest point within the stream (beginning or end).
Reimplemented in SkStreamSeekable, SkMemoryStream, and SkFILEStream.
|
inlinevirtual |
Attempt to peek at size bytes.
If this stream supports peeking, copy min(size, peekable bytes) into buffer, and return the number of bytes copied. If the stream does not support peeking, or cannot peek any bytes, return 0 and leave buffer unchanged. The stream is guaranteed to be in the same visible state after this call, regardless of success or failure.
buffer | Must not be NULL, and must be at least size bytes. Destination to copy bytes. |
size | Number of bytes to copy. |
Reimplemented in SkMemoryStream.
|
pure virtual |
Reads or skips size number of bytes.
If buffer == NULL, skip size bytes, return how many were skipped. If buffer != NULL, copy size bytes into buffer, return how many were copied.
buffer | when NULL skip size bytes, otherwise copy size bytes into buffer |
size | the number of bytes to skip or copy |
Implemented in SkMemoryStream, and SkFILEStream.
|
inline |
bool SkStream::readPackedUInt | ( | size_t * | ) |
bool SkStream::readS16 | ( | int16_t * | ) |
bool SkStream::readS32 | ( | int32_t * | ) |
bool SkStream::readS8 | ( | int8_t * | ) |
bool SkStream::readScalar | ( | SkScalar * | ) |
|
inline |
|
inline |
|
inline |
|
inlinevirtual |
Rewinds to the beginning of the stream.
Returns true if the stream is known to be at the beginning after this call returns.
Reimplemented in SkStreamRewindable, SkMemoryStream, and SkFILEStream.
|
inlinevirtual |
Seeks to an absolute position in the stream.
If this cannot be done, returns false. If an attempt is made to seek past the end of the stream, the position will be set to the end of the stream.
Reimplemented in SkStreamSeekable, SkMemoryStream, and SkFILEStream.
|
inline |
Skip size number of bytes.