#include <CeylanInputStream.h>
Classes | |
class | EOFException |
Exception thrown when an unexpected End-Of-File occured, i.e. More... | |
class | InputStreamException |
Exception thrown when an operation on an InputStream failed. More... | |
class | ReadFailedException |
Exception thrown when a read operation failed. More... | |
class | SelectFailedException |
Exception thrown when select() fails. More... | |
Public Types | |
enum | TextOutputFormat { rawText, html } |
Defines what text output formats for TextDisplayable instances are available. More... | |
Public Member Functions | |
InputStream (bool blocking=true) | |
Basic constructor for InputStream, created not selected. | |
virtual | ~InputStream () throw () |
Basic virtual destructor. | |
bool | isSelected () const |
Tells if the stream has data to read. | |
bool | isFaulty () const |
virtual StreamID | getInputStreamID () const =0 |
Returns the stream's unique ID. | |
virtual const std::string | toString (Ceylan::VerbosityLevels level=Ceylan::high) const |
Returns an user-friendly description of the state of this object. | |
virtual bool | hasAvailableData () const =0 |
Tells whether there is data available on input. | |
virtual Size | read (Ceylan::Byte *buffer, Size length) |
Reads up to maxLength bytes from this InputStream to specified buffer. | |
virtual void | clearInput () |
Clears the input stream. | |
virtual Ceylan::Sint8 | readSint8 () |
Returns a Ceylan::Sint8 read from this input stream. | |
virtual Ceylan::Uint8 | readUint8 () |
Returns a Ceylan::Uint8 read from this input stream. | |
virtual Ceylan::Sint16 | readSint16 () |
Returns a Ceylan::Sint16 read from this input stream. | |
virtual Ceylan::Uint16 | readUint16 () |
Returns a Ceylan::Uint16 read from this input stream. | |
virtual Ceylan::Sint32 | readSint32 () |
Returns a Ceylan::Sint32 read from this input stream. | |
virtual Ceylan::Uint32 | readUint32 () |
Returns a Ceylan::Uint32 read from this input stream. | |
virtual Ceylan::Float32 | readFloat32 () |
Returns a Ceylan::Float32 read from this input stream. | |
virtual Ceylan::Float64 | readFloat64 () |
Returns a Ceylan::Float64 read from this input stream. | |
virtual void | readString (std::string &result) |
Reads a string from this input stream, and stores it in the specified string. | |
virtual void | skipWhitespaces (Ceylan::Uint8 &firstNonSpace) |
Reads from this input stream as long as there are whitespaces to be read. | |
bool | isBlocking () const |
Tells whether this stream is in blocking mode (if true), or in non-blocking mode (if false). | |
virtual bool | close ()=0 |
Closes the stream. | |
Static Public Member Functions | |
static Ceylan::Uint16 | Select (std::list< InputStream * > &is) |
Blocks the calling thread until bytes become available on one or more streams in is. | |
static Ceylan::Uint16 | Test (std::list< InputStream * > &is) |
Checks whether bytes become available on one or more streams in is. | |
static bool | Close (FileDescriptor &fd) |
Closes and zeroes the specified file descriptor. | |
static const std::string | ToString (std::list< TextDisplayable * > displayables, Ceylan::VerbosityLevels level=Ceylan::high) |
Returns a user-friendly description of this list of pointers to text displayable instances. | |
static TextOutputFormat | GetOutputFormat () |
Returns the current overall text format to be used by TextDisplayable instances. | |
static void | SetOutputFormat (TextOutputFormat newOutputFormat) |
Sets the current overall text format to be used by TextDisplayable instances. | |
Protected Member Functions | |
virtual void | setSelected (bool newStatus) |
Used to set the selection status of this stream. | |
void | setFaulty (bool newFaultyState=true) |
Sets the faulty state of this stream. | |
virtual void | setStreamID (StreamID newInputStreamID) |
Sets this input stream's unique ID. | |
virtual void | setBlocking (bool newStatus) |
Sets the blocking mode of this stream. | |
Protected Attributes | |
bool | _isBlocking |
Stores whether the stream is in blocking mode. | |
Static Protected Attributes | |
static TextOutputFormat | _OutputFormat = rawText |
The text format to be used currently by TextDisplayable instances. | |
Private Member Functions | |
InputStream (const InputStream &source) | |
Copy constructor made private to ensure that it will be never called. | |
InputStream & | operator= (const InputStream &source) |
Assignment operator made private to ensure that it will be never called. | |
Private Attributes | |
bool | _isSelected |
Stores the selected status. | |
bool | _isFaulty |
Tells whether this InputStream is hopelessly faulty. |
The virtual inheritance has been set for classes such as System::File which are both input and output streams: had the Stream class a data member, it would not be duplicated in a System::File instance (it would be allocated only once).
Definition at line 65 of file CeylanInputStream.h.
enum Ceylan::TextDisplayable::TextOutputFormat [inherited] |
Defines what text output formats for TextDisplayable instances are available.
Definition at line 124 of file CeylanTextDisplayable.h.
InputStream::InputStream | ( | bool | blocking = true |
) | [explicit] |
Basic constructor for InputStream, created not selected.
blocking | tells whether this input stream should be created in blocking mode (the default) or in non-blocking mode (if supported). |
Definition at line 105 of file CeylanInputStream.cc.
InputStream::~InputStream | ( | ) | throw () [virtual] |
Ceylan::System::InputStream::InputStream | ( | const InputStream & | source | ) | [private] |
Copy constructor made private to ensure that it will be never called.
The compiler should complain whenever this undefined constructor is called, implicitly or not.
void InputStream::clearInput | ( | ) | [virtual] |
Clears the input stream.
InputStream::ReadFailedException | if the operation failed. |
Reimplemented in Ceylan::System::Pipe.
Definition at line 179 of file CeylanInputStream.cc.
References dataUtils::b, hasAvailableData(), and read().
bool Stream::Close | ( | FileDescriptor & | fd | ) | [static, inherited] |
Closes and zeroes the specified file descriptor.
It is passed by address so that this function can set it to zero on successful close.
CloseException | if the close operation failed. |
Definition at line 114 of file CeylanStream.cc.
References Ceylan::System::Stream::close(), generalUtils::false, Ceylan::toString(), and generalUtils::true.
Referenced by Ceylan::System::StandardFile::close(), Ceylan::Network::Socket::close(), Ceylan::System::Pipe::close(), and Ceylan::System::LibfatFile::close().
virtual bool Ceylan::System::Stream::close | ( | ) | [pure virtual, inherited] |
Closes the stream.
CloseException | if the close operation failed. |
Implemented in Ceylan::Network::Socket, Ceylan::System::File, Ceylan::System::LibfatFile, Ceylan::System::MemoryStream, Ceylan::System::Pipe, and Ceylan::System::StandardFile.
Referenced by Ceylan::System::Stream::Close().
virtual StreamID Ceylan::System::InputStream::getInputStreamID | ( | ) | const [pure virtual] |
Returns the stream's unique ID.
InputStreamException | if the operation failed, for example if this input stream has not received a valid identifier yet. |
Implemented in Ceylan::Network::Socket, Ceylan::System::AnonymousInputStream, Ceylan::System::File, Ceylan::System::MemoryStream, and Ceylan::System::Pipe.
Referenced by Ceylan::System::Process::RedirectStdin(), setSelected(), and toString().
TextDisplayable::TextOutputFormat TextDisplayable::GetOutputFormat | ( | ) | [static, inherited] |
Returns the current overall text format to be used by TextDisplayable instances.
Definition at line 63 of file CeylanTextDisplayable.cc.
References Ceylan::TextDisplayable::_OutputFormat.
Referenced by Ceylan::formatStringList(), Ceylan::formatStringMap(), Ceylan::XML::XMLMarkup::toString(), Ceylan::Maths::Linear::Vector3::toString(), Ceylan::Maths::Linear::Vector2::toString(), Ceylan::Maths::Linear::Tripoint::toString(), Ceylan::Module::toString(), Ceylan::Maths::Linear::Matrix3::toString(), Ceylan::Maths::Linear::Matrix2::toString(), Ceylan::Maths::Linear::HomogeneousMatrix3::toString(), and Ceylan::Maths::Linear::Bipoint::toString().
virtual bool Ceylan::System::InputStream::hasAvailableData | ( | ) | const [pure virtual] |
Tells whether there is data available on input.
Implemented in Ceylan::Network::Socket, Ceylan::System::File, Ceylan::System::MemoryStream, and Ceylan::System::Pipe.
Referenced by clearInput().
bool Stream::isBlocking | ( | ) | const [inherited] |
Tells whether this stream is in blocking mode (if true), or in non-blocking mode (if false).
Definition at line 93 of file CeylanStream.cc.
References Ceylan::System::Stream::_isBlocking.
Referenced by Ceylan::Network::StreamSocket::createSocket(), and Ceylan::Network::Socket::toString().
bool InputStream::isFaulty | ( | ) | const |
Definition at line 131 of file CeylanInputStream.cc.
References _isFaulty.
Referenced by toString().
bool InputStream::isSelected | ( | ) | const |
Tells if the stream has data to read.
Definition at line 122 of file CeylanInputStream.cc.
References _isSelected.
Referenced by toString().
InputStream& Ceylan::System::InputStream::operator= | ( | const InputStream & | source | ) | [private] |
Assignment operator made private to ensure that it will be never called.
The compiler should complain whenever this undefined operator is called, implicitly or not.
Size InputStream::read | ( | Ceylan::Byte * | buffer, | |
Size | length | |||
) | [virtual] |
Reads up to maxLength bytes from this InputStream to specified buffer.
buffer | the buffer where to store read bytes. Its size must be at least 'length' bytes. | |
length | the maximum number of bytes that should be read. |
ReadFailed | if a read error occurred, or if this default implementation has not been overriden. |
Each read method should set the selected status to false, after the actual reading.
Reimplemented in Ceylan::Network::Socket, Ceylan::System::File, Ceylan::System::LibfatFile, Ceylan::System::MemoryStream, Ceylan::System::Pipe, and Ceylan::System::StandardFile.
Definition at line 169 of file CeylanInputStream.cc.
Referenced by clearInput(), readFloat32(), readFloat64(), readSint16(), readSint32(), readSint8(), readString(), readUint16(), readUint32(), readUint8(), and Ceylan::Middleware::Marshaller::retrieveData().
Ceylan::Float32 InputStream::readFloat32 | ( | ) | [virtual] |
Returns a Ceylan::Float32 read from this input stream.
ReadFailedException | in case a system error occured, or EOFException is a protocol error occured, with fewer bytes available than expected. |
Definition at line 356 of file CeylanInputStream.cc.
References ceylan_bswap_32, and read().
Referenced by Ceylan::Middleware::LightWeightMarshaller::decodeFloat32().
Ceylan::Float64 InputStream::readFloat64 | ( | ) | [virtual] |
Returns a Ceylan::Float64 read from this input stream.
ReadFailedException | in case a system error occured, or EOFException is a protocol error occured, with fewer bytes available than expected. |
Definition at line 392 of file CeylanInputStream.cc.
References Ceylan::byteswap(), ceylan_bswap_64, and read().
Referenced by Ceylan::Middleware::LightWeightMarshaller::decodeFloat64().
Ceylan::Sint16 InputStream::readSint16 | ( | ) | [virtual] |
Returns a Ceylan::Sint16 read from this input stream.
ReadFailedException | in case a system error occured, or EOFException is a protocol error occured, with fewer bytes available than expected. |
Definition at line 239 of file CeylanInputStream.cc.
References ceylan_bswap_16, and read().
Referenced by Ceylan::Middleware::LightWeightMarshaller::decodeSint16().
Ceylan::Sint32 InputStream::readSint32 | ( | ) | [virtual] |
Returns a Ceylan::Sint32 read from this input stream.
ReadFailedException | in case a system error occured, or EOFException is a protocol error occured, with fewer bytes available than expected. |
Definition at line 298 of file CeylanInputStream.cc.
References ceylan_bswap_32, and read().
Referenced by Ceylan::Middleware::LightWeightMarshaller::decodeSint32().
Ceylan::Sint8 InputStream::readSint8 | ( | ) | [virtual] |
Returns a Ceylan::Sint8 read from this input stream.
ReadFailedException | in case a system error occured, or EOFException is a protocol error occured, with fewer bytes available than expected. |
Definition at line 203 of file CeylanInputStream.cc.
References read().
Referenced by Ceylan::Middleware::LightWeightMarshaller::decodeSint8().
void InputStream::readString | ( | std::string & | result | ) | [virtual] |
Reads a string from this input stream, and stores it in the specified string.
result | the string to fill from this input stream. |
ReadFailedException | in case a system error occured, or EOFException is a protocol error occured, with fewer bytes available than expected. |
Definition at line 437 of file CeylanInputStream.cc.
References read(), readUint16(), and Ceylan::toString().
Referenced by Ceylan::Middleware::LightWeightMarshaller::decodeString().
Ceylan::Uint16 InputStream::readUint16 | ( | ) | [virtual] |
Returns a Ceylan::Uint16 read from this input stream.
ReadFailedException | in case a system error occured, or EOFException is a protocol error occured, with fewer bytes available than expected. |
Definition at line 268 of file CeylanInputStream.cc.
References ceylan_bswap_16, and read().
Referenced by Ceylan::Middleware::LightWeightMarshaller::decodeUint16(), and readString().
Ceylan::Uint32 InputStream::readUint32 | ( | ) | [virtual] |
Returns a Ceylan::Uint32 read from this input stream.
ReadFailedException | in case a system error occured, or EOFException is a protocol error occured, with fewer bytes available than expected. |
Definition at line 327 of file CeylanInputStream.cc.
References ceylan_bswap_32, and read().
Referenced by Ceylan::Middleware::LightWeightMarshaller::decodeUint32().
Ceylan::Uint8 InputStream::readUint8 | ( | ) | [virtual] |
Returns a Ceylan::Uint8 read from this input stream.
ReadFailedException | in case a system error occured, or EOFException is a protocol error occured, with fewer bytes available than expected. |
Definition at line 221 of file CeylanInputStream.cc.
References read().
Referenced by Ceylan::Middleware::LightWeightMarshaller::decodeUint8(), Ceylan::System::FileSystemManager::diff(), Ceylan::XML::XMLParser::handleNextElement(), Ceylan::XML::XMLParser::InterpretLowerThanSequence(), Ceylan::XML::XMLParser::InterpretXMLDeclaration(), and skipWhitespaces().
Ceylan::Uint16 InputStream::Select | ( | std::list< InputStream * > & | is | ) | [static] |
Blocks the calling thread until bytes become available on one or more streams in is.
To see which are selected, use the isSelected
method.
SelectFailedException | if the operation failed, for example if the file descriptor feature is not available on this platform. |
Definition at line 534 of file CeylanInputStream.cc.
References Ceylan::System::explainError(), Ceylan::Network::explainSocketError(), Ceylan::System::getError(), Ceylan::Network::getSocketError(), Ceylan::System::Thread::Sleep(), and Ceylan::toString().
Referenced by Ceylan::Network::MultiplexedServerStreamSocket::run().
void Stream::setBlocking | ( | bool | newStatus | ) | [protected, virtual, inherited] |
Sets the blocking mode of this stream.
newStatus | if true, sets the stream in blocking mode, if false set to non-blocking mode. If the stream is already in the target state, nothing is done. |
NonBlockingNotSupportedException | if the operation failed or is not supported. |
Reimplemented in Ceylan::Network::Socket, and Ceylan::Network::StreamSocket.
Definition at line 175 of file CeylanStream.cc.
void InputStream::setFaulty | ( | bool | newFaultyState = true |
) | [protected] |
Sets the faulty state of this stream.
newFaultyState | the new faulty state. |
Definition at line 1004 of file CeylanInputStream.cc.
References _isFaulty.
Referenced by Ceylan::Network::MultiplexedServerStreamSocket::run().
void TextDisplayable::SetOutputFormat | ( | TextOutputFormat | newOutputFormat | ) | [static, inherited] |
Sets the current overall text format to be used by TextDisplayable instances.
newOutputFormat | the new output format. |
Definition at line 72 of file CeylanTextDisplayable.cc.
References Ceylan::TextDisplayable::_OutputFormat.
Referenced by Ceylan::Log::LogHolder::LogHolder().
void InputStream::setSelected | ( | bool | newStatus | ) | [protected, virtual] |
Used to set the selection status of this stream.
Definition at line 989 of file CeylanInputStream.cc.
References _isSelected, getInputStreamID(), and Ceylan::toString().
Referenced by Ceylan::System::StandardFile::read(), Ceylan::System::Pipe::read(), and Ceylan::System::LibfatFile::read().
void InputStream::setStreamID | ( | StreamID | newInputStreamID | ) | [protected, virtual] |
Sets this input stream's unique ID.
InputStreamException | in all cases as long as not specifically overriden. |
Definition at line 1013 of file CeylanInputStream.cc.
void InputStream::skipWhitespaces | ( | Ceylan::Uint8 & | firstNonSpace | ) | [virtual] |
Reads from this input stream as long as there are whitespaces to be read.
firstNonSpace | the variable which will be set by this method to the value of the first non-whitespace character that is read. |
Definition at line 516 of file CeylanInputStream.cc.
References Ceylan::isWhitespace(), and readUint8().
Referenced by Ceylan::XML::XMLParser::handleNextElement().
Ceylan::Uint16 InputStream::Test | ( | std::list< InputStream * > & | is | ) | [static] |
Checks whether bytes become available on one or more streams in is.
To see which are selected, use the isSelected
method.
This method returns always immediatly.
SelectFailedException | if the operation failed, for example if the file descriptor feature is not available on this platform. |
Definition at line 863 of file CeylanInputStream.cc.
References Ceylan::System::explainError(), and Ceylan::System::getError().
const std::string TextDisplayable::ToString | ( | std::list< TextDisplayable * > | displayables, | |
Ceylan::VerbosityLevels | level = Ceylan::high | |||
) | [static, inherited] |
Returns a user-friendly description of this list of pointers to text displayable instances.
displayables | a list of pointers to TextDisplayable instances/ | |
level | the requested verbosity level. |
Definition at line 45 of file CeylanTextDisplayable.cc.
References Ceylan::formatStringList().
const std::string InputStream::toString | ( | Ceylan::VerbosityLevels | level = Ceylan::high |
) | const [virtual] |
Returns an user-friendly description of the state of this object.
level | the requested verbosity level. |
Implements Ceylan::System::Stream.
Reimplemented in Ceylan::Network::AnonymousProtocolAwareStreamSocket, Ceylan::Network::AnonymousStreamSocket, Ceylan::Network::ClientStreamSocket, Ceylan::Network::MultiplexedProtocolBasedStreamServer, Ceylan::Network::MultiplexedServerStreamSocket, Ceylan::Network::SequentialServerStreamSocket, Ceylan::Network::ServerStreamSocket, Ceylan::Network::Socket, Ceylan::Network::StreamSocket, Ceylan::System::AnonymousInputOutputStream, Ceylan::System::AnonymousInputStream, Ceylan::System::File, Ceylan::System::InputOutputStream, Ceylan::System::LibfatFile, Ceylan::System::MemoryStream, and Ceylan::System::StandardFile.
Definition at line 140 of file CeylanInputStream.cc.
References getInputStreamID(), isFaulty(), and isSelected().
bool Ceylan::System::Stream::_isBlocking [protected, inherited] |
Stores whether the stream is in blocking mode.
Definition at line 221 of file CeylanStream.h.
Referenced by Ceylan::System::Stream::isBlocking(), Ceylan::Network::StreamSocket::setBlocking(), Ceylan::Network::Socket::setBlocking(), and Ceylan::System::Stream::toString().
bool Ceylan::System::InputStream::_isFaulty [private] |
Tells whether this InputStream is hopelessly faulty.
Definition at line 482 of file CeylanInputStream.h.
Referenced by isFaulty(), and setFaulty().
bool Ceylan::System::InputStream::_isSelected [private] |
Stores the selected status.
Definition at line 478 of file CeylanInputStream.h.
Referenced by isSelected(), and setSelected().
TextDisplayable::TextOutputFormat TextDisplayable::_OutputFormat = rawText [static, protected, inherited] |
The text format to be used currently by TextDisplayable instances.
Definition at line 158 of file CeylanTextDisplayable.h.
Referenced by Ceylan::TextDisplayable::GetOutputFormat(), and Ceylan::TextDisplayable::SetOutputFormat().