Panda3D
Public Member Functions | Public Attributes | List of all members
StreamReader Class Reference

A class to read sequential binary data directly from an istream. More...

Public Member Functions

 __init__ (const StreamReader copy)
 The copy constructor does not copy ownership of the stream. More...
 
 __init__ (Istream in, bool owns_stream)
 If owns_stream is true, the stream pointer will be deleted when the StreamReader destructs. More...
 
object extractBytes (int size)
 Extracts the indicated number of bytes in the stream and returns them as a string. More...
 
float getBeFloat32 ()
 Extracts a 32-bit single-precision big-endian floating-point number. More...
 
PNFloat64 getBeFloat64 ()
 Extracts a 64-bit big-endian floating-point number. More...
 
int16_t getBeInt16 ()
 Extracts a signed big-endian 16-bit integer. More...
 
int32_t getBeInt32 ()
 Extracts a signed big-endian 32-bit integer. More...
 
int64_t getBeInt64 ()
 Extracts a signed big-endian 64-bit integer. More...
 
uint16_t getBeUint16 ()
 Extracts an unsigned big-endian 16-bit integer. More...
 
uint32_t getBeUint32 ()
 Extracts an unsigned big-endian 32-bit integer. More...
 
uint64_t getBeUint64 ()
 Extracts an unsigned big-endian 64-bit integer. More...
 
bool getBool ()
 Extracts a boolean value. More...
 
str getFixedString (int size)
 Extracts a fixed-length string. More...
 
float getFloat32 ()
 Extracts a 32-bit single-precision floating-point number. More...
 
PNFloat64 getFloat64 ()
 Extracts a 64-bit floating-point number. More...
 
int16_t getInt16 ()
 Extracts a signed 16-bit integer. More...
 
int32_t getInt32 ()
 Extracts a signed 32-bit integer. More...
 
int64_t getInt64 ()
 Extracts a signed 64-bit integer. More...
 
int8_t getInt8 ()
 Extracts a signed 8-bit integer. More...
 
Istream getIstream ()
 Returns the stream in use. More...
 
str getString ()
 Extracts a variable-length string. More...
 
str getString32 ()
 Extracts a variable-length string with a 32-bit length field. More...
 
uint16_t getUint16 ()
 Extracts an unsigned 16-bit integer. More...
 
uint32_t getUint32 ()
 Extracts an unsigned 32-bit integer. More...
 
uint64_t getUint64 ()
 Extracts an unsigned 64-bit integer. More...
 
uint8_t getUint8 ()
 Extracts an unsigned 8-bit integer. More...
 
str getZString ()
 Extracts a variable-length string, as a NULL-terminated string. More...
 
StreamReader operator= (const StreamReader copy)
 
object readline ()
 Assumes the stream represents a text file, and extracts one line up to and including the trailing newline character. More...
 
object readlines ()
 
 skipBytes (int size)
 Skips over the indicated number of bytes in the stream. More...
 

Public Attributes

Istream istream
 Returns the istream this object is wrapping. More...
 

Detailed Description

A class to read sequential binary data directly from an istream.

Its interface is similar to DatagramIterator by design; see also StreamWriter.

Member Function Documentation

◆ __init__() [1/2]

__init__ ( const StreamReader  copy)

The copy constructor does not copy ownership of the stream.

◆ __init__() [2/2]

__init__ ( Istream  in,
bool  owns_stream 
)

If owns_stream is true, the stream pointer will be deleted when the StreamReader destructs.

◆ extractBytes()

object extractBytes ( int  size)

Extracts the indicated number of bytes in the stream and returns them as a string.

Returns empty string at end-of-file.

◆ getBeFloat32()

float getBeFloat32 ( )

Extracts a 32-bit single-precision big-endian floating-point number.

Since this kind of float is not necessarily portable across different architectures, special care is required.

◆ getBeFloat64()

PNFloat64 getBeFloat64 ( )

Extracts a 64-bit big-endian floating-point number.

◆ getBeInt16()

int16_t getBeInt16 ( )

Extracts a signed big-endian 16-bit integer.

◆ getBeInt32()

int32_t getBeInt32 ( )

Extracts a signed big-endian 32-bit integer.

◆ getBeInt64()

int64_t getBeInt64 ( )

Extracts a signed big-endian 64-bit integer.

◆ getBeUint16()

uint16_t getBeUint16 ( )

Extracts an unsigned big-endian 16-bit integer.

◆ getBeUint32()

uint32_t getBeUint32 ( )

Extracts an unsigned big-endian 32-bit integer.

◆ getBeUint64()

uint64_t getBeUint64 ( )

Extracts an unsigned big-endian 64-bit integer.

◆ getBool()

bool getBool ( )

Extracts a boolean value.

◆ getFixedString()

str getFixedString ( int  size)

Extracts a fixed-length string.

However, if a zero byte occurs within the string, it marks the end of the string.

◆ getFloat32()

float getFloat32 ( )

Extracts a 32-bit single-precision floating-point number.

Since this kind of float is not necessarily portable across different architectures, special care is required.

◆ getFloat64()

PNFloat64 getFloat64 ( )

Extracts a 64-bit floating-point number.

◆ getInt16()

int16_t getInt16 ( )

Extracts a signed 16-bit integer.

◆ getInt32()

int32_t getInt32 ( )

Extracts a signed 32-bit integer.

◆ getInt64()

int64_t getInt64 ( )

Extracts a signed 64-bit integer.

◆ getInt8()

int8_t getInt8 ( )

Extracts a signed 8-bit integer.

◆ getIstream()

Istream getIstream ( )

Returns the stream in use.

◆ getString()

str getString ( )

Extracts a variable-length string.

◆ getString32()

str getString32 ( )

Extracts a variable-length string with a 32-bit length field.

◆ getUint16()

uint16_t getUint16 ( )

Extracts an unsigned 16-bit integer.

◆ getUint32()

uint32_t getUint32 ( )

Extracts an unsigned 32-bit integer.

◆ getUint64()

uint64_t getUint64 ( )

Extracts an unsigned 64-bit integer.

◆ getUint8()

uint8_t getUint8 ( )

Extracts an unsigned 8-bit integer.

◆ getZString()

str getZString ( )

Extracts a variable-length string, as a NULL-terminated string.

◆ operator=()

StreamReader operator= ( const StreamReader  copy)

◆ readline()

object readline ( )

Assumes the stream represents a text file, and extracts one line up to and including the trailing newline character.

Returns empty string when the end of file is reached.

The interface here is intentionally designed to be similar to that for Python's File.readline() function.

◆ readlines()

object readlines ( )

◆ skipBytes()

skipBytes ( int  size)

Skips over the indicated number of bytes in the stream.

Member Data Documentation

◆ istream

Istream istream

Returns the istream this object is wrapping.