MemoryStream

class MemoryStream

Methods

Make

MakeCopy

MakeDirect

MakeFromFile

Attempts to open the specified file as a stream, returns nullptr on failure.

__init__

__init__(*args, **kwargs) Overloaded function.

asData

duplicate

fork

getAtPos

getLength

Returns the total length of the stream.

getMemoryBase

Returns the starting address for the data.

getPosition

Returns the current position in the stream.

hasLength

Returns true if this stream can report it’s total length.

hasPosition

Returns true if this stream can report it’s current position.

isAtEnd

Returns true when all the bytes in the stream have been read.

move

Seeks to an relative offset in the stream.

peek

Attempt to peek at size bytes.

read

Reads or skips size number of bytes.

readBool

readPackedUInt

readS16

readS32

readS8

readScalar

readU16

readU32

readU8

rewind

Rewinds to the beginning of the stream.

seek

Seeks to an absolute position in the stream.

setData

setMemory

skip

Skip size number of bytes.

skipToAlign4

Methods

static MemoryStream.Make(data: skia.Data) skia.MemoryStream
static MemoryStream.MakeCopy(data: buffer) skia.MemoryStream
static MemoryStream.MakeDirect(data: buffer) skia.MemoryStream
static MemoryStream.MakeFromFile(path: str) SkStreamAsset

Attempts to open the specified file as a stream, returns nullptr on failure.

MemoryStream.__init__(*args, **kwargs)

__init__(*args, **kwargs) Overloaded function.

  1. __init__(self: skia.MemoryStream) -> None

  2. __init__(self: skia.MemoryStream, length: int) -> None

  3. __init__(self: skia.MemoryStream, data: buffer, copyData: bool = False) -> None

  4. __init__(self: skia.MemoryStream, data: skia.Data) -> None

MemoryStream.asData(self: skia.MemoryStream) skia.Data
MemoryStream.duplicate(self: skia.StreamMemory) skia.StreamSeekable
MemoryStream.fork(self: skia.StreamMemory) skia.StreamSeekable
MemoryStream.getAtPos(self: skia.MemoryStream) capsule
MemoryStream.getLength(self: skia.Stream) int

Returns the total length of the stream.

If this cannot be done, returns 0.

Reimplemented in MemoryStream, FILEStream, and StreamAsset.

MemoryStream.getMemoryBase(self: skia.Stream) capsule

Returns the starting address for the data.

If this cannot be done, returns NULL.

Reimplemented in MemoryStream, and StreamMemory.

MemoryStream.getPosition(self: skia.Stream) int

Returns the current position in the stream.

If this cannot be done, returns 0.

Reimplemented in MemoryStream, FILEStream, and StreamSeekable.

MemoryStream.hasLength(self: skia.Stream) bool

Returns true if this stream can report it’s total length.

Reimplemented in StreamAsset.

MemoryStream.hasPosition(self: skia.Stream) bool

Returns true if this stream can report it’s current position.

Reimplemented in StreamSeekable.

MemoryStream.isAtEnd(self: skia.Stream) bool

Returns true when all the bytes in the stream 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 MemoryStream, and FILEStream.

MemoryStream.move(self: skia.Stream, offset: int) bool

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 MemoryStream, FILEStream, and StreamSeekable.

MemoryStream.peek(self: skia.Stream, buffer: buffer) int

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.

Parameters
  • buffer – Must not be NULL, and must be at least size bytes. Destination to copy bytes.

  • size – Number of bytes to copy.

Returns

The number of bytes peeked/copied.

Reimplemented in MemoryStream.

MemoryStream.read(self: skia.Stream, buffer: buffer, size: int = 0) int

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.

Parameters
  • buffer – when NULL skip size bytes, otherwise copy size bytes into buffer

  • size – the number of bytes to skip or copy; may be nullptr

Returns

the number of bytes actually read.

Implemented in MemoryStream, and FILEStream.

MemoryStream.readBool(self: skia.Stream) bool
MemoryStream.readPackedUInt(self: skia.Stream) int
MemoryStream.readS16(self: skia.Stream) int
MemoryStream.readS32(self: skia.Stream) int
MemoryStream.readS8(self: skia.Stream) int
MemoryStream.readScalar(self: skia.Stream) float
MemoryStream.readU16(self: skia.Stream) int
MemoryStream.readU32(self: skia.Stream) int
MemoryStream.readU8(self: skia.Stream) int
MemoryStream.rewind(self: skia.Stream) bool

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 MemoryStream, FILEStream, and StreamRewindable.

MemoryStream.seek(self: skia.Stream, position: int) bool

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 MemoryStream, FILEStream, and StreamSeekable.

MemoryStream.setData(self: skia.MemoryStream, data: skia.Data) None
MemoryStream.setMemory(self: skia.MemoryStream, data: buffer, copyData: bool = False) None
MemoryStream.skip(self: skia.Stream, size: int) int

Skip size number of bytes.

Returns

the actual number bytes that could be skipped.

MemoryStream.skipToAlign4(self: skia.MemoryStream) None