Gnash  0.8.11dev
Public Member Functions | List of all members
gnash::IOChannel Class Referenceabstract

A virtual IO channel. More...

#include <IOChannel.h>

Inheritance diagram for gnash::IOChannel:
gnash::Socket

Public Member Functions

virtual ~IOChannel ()
 
std::uint32_t read_le32 ()
 Read a 32-bit word from a little-endian stream. returning it as a native-endian word. More...
 
std::uint16_t read_le16 ()
 Read a 16-bit word from a little-endian stream. More...
 
std::uint8_t read_byte ()
 Read a single byte from the stream. More...
 
virtual std::streamsize read (void *dst, std::streamsize num)=0
 Read the given number of bytes from the stream. More...
 
virtual std::streamsize readNonBlocking (void *dst, std::streamsize num)
 Read at most the given number of bytes w/out blocking. More...
 
virtual std::streamsize write (const void *src, std::streamsize num)
 Write the given number of bytes to the stream. More...
 
int read_string (char *dst, int max_length)
 Read up to max_length characters, returns the number of characters read, or -1 if the string length is longer than max_length. More...
 
virtual std::streampos tell () const =0
 Return current stream position. More...
 
virtual bool seek (std::streampos p)=0
 Seek to the specified position. More...
 
virtual void go_to_end ()=0
 Seek to the end of the stream. More...
 
virtual bool eof () const =0
 Return true if the end of the stream has been reached. More...
 
virtual bool bad () const =0
 Return true if the stream is in an error state. More...
 
virtual size_t size () const
 Get the size of the stream (unreliably). More...
 

Detailed Description

A virtual IO channel.

Constructor & Destructor Documentation

§ ~IOChannel()

virtual gnash::IOChannel::~IOChannel ( )
inlinevirtual

Member Function Documentation

§ bad()

virtual bool gnash::IOChannel::bad ( ) const
pure virtual

Return true if the stream is in an error state.

When the stream is in an error state there's nothing you can do about it, just delete it and log the error.

Implemented in gnash::Socket.

§ eof()

virtual bool gnash::IOChannel::eof ( ) const
pure virtual

Return true if the end of the stream has been reached.

Throw IOException on error

Implemented in gnash::Socket.

Referenced by gnash::MovieFactory::clear().

§ go_to_end()

virtual void gnash::IOChannel::go_to_end ( )
pure virtual

Seek to the end of the stream.

Throw IOException on error

Implemented in gnash::Socket.

Referenced by gnash::SWFStream::consumeInput().

§ read()

virtual std::streamsize gnash::IOChannel::read ( void *  dst,
std::streamsize  num 
)
pure virtual

Read the given number of bytes from the stream.

Return the number of bytes actually read. EOF might cause it to be < num.

Throw IOException on error

Implemented in gnash::Socket.

Referenced by gnash::MovieFactory::clear(), gnash::media::MediaHandler::isFLV(), read_byte(), and gnash::SWFStream::read_uint().

§ read_byte()

std::uint8_t gnash::IOChannel::read_byte ( )

§ read_le16()

std::uint16_t gnash::IOChannel::read_le16 ( )

Read a 16-bit word from a little-endian stream.

Throw IOException on error

References read_byte().

Referenced by gnash::SWFStream::read_u16().

§ read_le32()

std::uint32_t gnash::IOChannel::read_le32 ( )

Read a 32-bit word from a little-endian stream. returning it as a native-endian word.

Throw IOException on error

References read_byte().

Referenced by gnash::SWFStream::read_u32().

§ read_string()

int gnash::IOChannel::read_string ( char *  dst,
int  max_length 
)

Read up to max_length characters, returns the number of characters read, or -1 if the string length is longer than max_length.

Stops at the first \0 character if it comes before max_length.

Guarantees termination of the string.

Returns
the number of characters read, or -1 no null-termination was found within max_length

Throw IOException on error

References gnash::key::i, and read_byte().

§ readNonBlocking()

virtual std::streamsize gnash::IOChannel::readNonBlocking ( void *  dst,
std::streamsize  num 
)
inlinevirtual

Read at most the given number of bytes w/out blocking.

Throw IOException on error

Returns
The number of bytes actually read. A short count may mean EOF was hit or data didn't arrive yet.

Default implementation proxies the call to the blocking version.

Reimplemented in gnash::Socket.

References gnash::key::p, and gnash::amf::write().

§ seek()

virtual bool gnash::IOChannel::seek ( std::streampos  p)
pure virtual

Seek to the specified position.

Throw IOException on error

Returns
true on success, or false on failure.

Implemented in gnash::Socket.

Referenced by gnash::MovieFactory::clear(), and gnash::media::MediaHandler::isFLV().

§ size()

virtual size_t gnash::IOChannel::size ( ) const
inlinevirtual

Get the size of the stream (unreliably).

Size of stream is unreliable as not all input channels have a mechanism to advertise size, and some have one but isn't necessarely truthful (a few HTTP severs are bogus in this reguard).

Returns
unreliable input size, (size_t)-1 if not known.

§ tell()

virtual std::streampos gnash::IOChannel::tell ( ) const
pure virtual

Return current stream position.

Throw IOException on error

Implemented in gnash::Socket.

Referenced by gnash::MovieFactory::clear(), and gnash::SWFStream::tell().

§ write()

std::streamsize gnash::IOChannel::write ( const void *  src,
std::streamsize  num 
)
virtual

Write the given number of bytes to the stream.

Throw IOException on error/unsupported op.

Reimplemented in gnash::Socket.


The documentation for this class was generated from the following files: