# class Stream | An abstract stream class capable of reading and writing. More...
Contains pure virtuals
Full name | `TelEngine::Stream`
Definition | `#include <yateclass.h>`
Inherited by | File, MemoryStream, SctpSocket, Socket
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

#### Public Types

- enum SeekPos { SeekBegin, SeekEnd, SeekCurrent }

#### Public Methods

- virtual ~Stream ()
- inline int error () const
- virtual bool terminate ()
- virtual bool canRetry () const
- virtual bool inProgress () const
- virtual bool valid () const
- virtual bool setBlocking (bool block = true)
- virtual int writeData (const void* buffer, int length)
- int writeData (const char* str)
- inline int writeData (const String& str)
- inline int writeData (const DataBlock& buf)
- virtual int readData (void* buffer, int length)
- virtual int64_t length ()
- virtual int64_t seek (SeekPos pos, int64_t offset = 0)
- inline int64_t seek (int64_t offset)

#### Public Static Methods

- static bool allocPipe (Stream*& reader, Stream*& writer)
- static bool allocPair (Stream*& str1, Stream*& str2)
- static bool supportsPipes ()
- static bool supportsPairs ()

#### Protected Methods

- inline Stream ()
- inline void clearError ()

#### Protected Members

- int m_error

## 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:

block | True 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:

buffer | Buffer for data transfer
length | Length 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:

str | String 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:

str | String 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:

buf | DataBlock 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:

buffer | Buffer for data transfer
length | Length 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:

pos | The seek start as enumeration
offset | The 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:

offset | The 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:

reader | Reference of a pointer receiving the newly allocated reading side of the pipe
writer | Reference 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:

str1 | Reference of a pointer receiving the newly allocated 1st end of the pair
str2 | Reference 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 Mon Feb 10 13:15:47 2014, using kdoc 2.0a54.