#include <dashel.h>
Inheritance diagram for Dashel::Stream:

Public Member Functions | |
| Stream (const std::string &targetName) | |
| Constructor. | |
| virtual | ~Stream () |
| Virtual destructor, to ensure calls to destructors of sub-classes. | |
| void | fail (DashelException::Source s, int se, const char *reason) |
| Set stream to failed state. | |
| bool | failed () const |
| Query failed state of stream. | |
| const std::string & | getFailReason () const |
| Returns the reason the stream has failed. | |
| const std::string & | getTargetName () const |
| Returns the name of the target. | |
| virtual void | write (const void *data, const size_t size)=0 |
| Write data to the stream. | |
| template<typename T> | |
| void | write (T v) |
| Write a variable of basic type to the stream. | |
| virtual void | flush ()=0 |
| Flushes stream. | |
| virtual void | read (void *data, size_t size)=0 |
| Reads data from the stream. | |
| template<typename T> | |
| T | read () |
| Read a variable of basic type from the stream. | |
Protected Attributes | |
| std::string | targetName |
| The target name. | |
| void Dashel::Stream::fail | ( | DashelException::Source | s, | |
| int | se, | |||
| const char * | reason | |||
| ) |
Set stream to failed state.
| s | Source of failure | |
| se | System error code | |
| reason | The logical reason as a human readable string. |
| bool Dashel::Stream::failed | ( | ) | const [inline] |
Query failed state of stream.
| const std::string& Dashel::Stream::getFailReason | ( | ) | const [inline] |
Returns the reason the stream has failed.
| const std::string& Dashel::Stream::getTargetName | ( | ) | const [inline] |
Returns the name of the target.
The name of the target contains all parameters and the protocol name.
| virtual void Dashel::Stream::write | ( | const void * | data, | |
| const size_t | size | |||
| ) | [pure virtual] |
Write data to the stream.
Writes all requested data to the stream, blocking until all the data has been written, or some error occurs. Errors are signaled by throwing a DashelException exception. This function does not flush devices, therefore the data may not really have been written on return, but only been buffered. In order to flush the stream, call flush().
| data | Pointer to the data to write. | |
| size | Amount of data to write in bytes. |
| void Dashel::Stream::write | ( | T | v | ) | [inline] |
Write a variable of basic type to the stream.
This function does not perform any endian conversion.
| v | variable to write. |
| virtual void Dashel::Stream::flush | ( | ) | [pure virtual] |
Flushes stream.
Calling this function requests the stream to be flushed, this may ensure that data is written to physical media or actually sent over a wire. The exact performed function depends on the stream type and operating system.
| virtual void Dashel::Stream::read | ( | void * | data, | |
| size_t | size | |||
| ) | [pure virtual] |
Reads data from the stream.
Reads all requested data from the stream, blocking until all the data has been read, or some error occurs. Errors are signaled by throwing a DashelException exception, which may be caused either by device errors or reaching the end of file.
| data | Pointer to the memory where the read data should be stored. | |
| size | Amount of data to read in bytes. |
| T Dashel::Stream::read | ( | ) | [inline] |
Read a variable of basic type from the stream.
This function does not perform any endian conversion.
1.5.1