class Stream

An abstract stream class capable of reading and writing. More...

Contains pure virtuals
Full nameTelEngine::Stream
Definition#include <yateclass.h>
Inherited byFile, MemoryStream, SctpSocket, Socket
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Types

Public Methods

Public Static Methods

Protected Methods

Protected Members


Detailed Description

Base class for encapsulating system dependent stream capable objects

enum SeekPos { SeekBegin, SeekEnd, SeekCurrent }

SeekPos

Enumerate seek start position

 ~Stream ()

~Stream

[virtual]

Destructor, terminates the stream

inline int  error ()

error

[const]

Get the error code of the last operation on this stream

Returns: Error code generated by the last operation on this stream

bool  terminate ()

terminate

[pure virtual]

Closes the stream

Returns: True if the stream was (already) closed, false if an error occured

bool  canRetry ()

canRetry

[const virtual]

Check if the last error code indicates a retryable condition

Returns: True if error was temporary and operation should be retried

bool  inProgress ()

inProgress

[const virtual]

Check if the last error code indicates a non blocking operation in progress

Returns: True if a non blocking operation is in progress

bool  valid ()

valid

[const pure virtual]

Check if this stream is valid

Returns: True if the stream is valid, false if it's invalid or closed

bool  setBlocking (bool block = true)

setBlocking

[virtual]

Set the blocking or non-blocking operation mode of the stream

Parameters:
blockTrue if I/O operations should block, false for non-blocking

Returns: True if operation was successfull, false if an error occured

int  writeData (const void* buffer, int length)

writeData

[pure virtual]

Write data to a connected stream

Parameters:
bufferBuffer for data transfer
lengthLength of the buffer

Returns: Number of bytes transferred, negative if an error occurred

int  writeData (const char* str)

writeData

Write a C string to a connected stream

Parameters:
strString to send over the stream

Returns: Number of bytes transferred, negative if an error occurred

inline int  writeData (const String& str)

writeData

Write a String to a connected stream

Parameters:
strString to send over the stream

Returns: Number of bytes transferred, negative if an error occurred

inline int  writeData (const DataBlock& buf)

writeData

Write a Data block to a connected stream

Parameters:
bufDataBlock to send over the stream

Returns: Number of bytes transferred, negative if an error occurred

int  readData (void* buffer, int length)

readData

[pure virtual]

Receive data from a connected stream

Parameters:
bufferBuffer for data transfer
lengthLength of the buffer

Returns: Number of bytes transferred, negative if an error occurred

int64_t  length ()

length

[virtual]

Find the length of the stream if it has one

Returns: Length of the stream or zero if length is not defined

int64_t  seek (SeekPos pos, int64_t offset = 0)

seek

[virtual]

Set the stream read/write pointer

Parameters:
posThe seek start as enumeration
offsetThe number of bytes to move the pointer from starting position

Returns: The new position of the stream read/write pointer. Negative on failure

inline int64_t  seek (int64_t offset)

seek

Set the read/write pointer from begin of stream

Parameters:
offsetThe position in stream to move the pointer

Returns: The new position of the stream read/write pointer. Negative on failure

bool  allocPipe (Stream*& reader, Stream*& writer)

allocPipe

[static]

Allocate a new pair of unidirectionally pipe connected streams

Parameters:
readerReference of a pointer receiving the newly allocated reading side of the pipe
writerReference of a pointer receiving the newly allocated writing side of the pipe

Returns: True is the stream pipe was created successfully

bool  allocPair (Stream*& str1, Stream*& str2)

allocPair

[static]

Allocate a new pair of bidirectionally connected streams

Parameters:
str1Reference of a pointer receiving the newly allocated 1st end of the pair
str2Reference of a pointer receiving the newly allocated 2nd end of the pair

Returns: True is the stream pair was created successfully

bool  supportsPipes ()

supportsPipes

[static]

Check if operating system supports unidirectional stream pairs

Returns: True if unidirectional pipes can be created

bool  supportsPairs ()

supportsPairs

[static]

Check if operating system supports bidirectional stream pairs

Returns: True if bidirectional pairs can be created

inline  Stream ()

Stream

[protected]

Default constructor

inline void  clearError ()

clearError

[protected]

Clear the last error code

int m_error

m_error

[protected]


Generated by: paulc on bussard on Fri Dec 21 16:28:34 2012, using kdoc 2.0a54.