Ceylan::System::OutputStream Class Reference

Abstract output stream class used in IPC. More...

#include <CeylanOutputStream.h>

Inheritance diagram for Ceylan::System::OutputStream:
Inheritance graph
[legend]
Collaboration diagram for Ceylan::System::OutputStream:
Collaboration graph
[legend]

List of all members.

Classes

class  OutputStreamException
 Exception thrown when an operation on an OutputStream failed. More...
class  WriteFailedException
 Exception thrown when a write operation failed. More...

Public Types

enum  TextOutputFormat { rawText, html }
 

Defines what text output formats for TextDisplayable instances are available.

More...

Public Member Functions

 OutputStream (bool blocking=true)
 Basic constructor for OutputStream.
virtual ~OutputStream () throw ()
 Basic destructor.
virtual StreamID getOutputStreamID () const =0
 Returns the output stream's unique ID.
virtual Size write (const std::string &message)
 Writes message to this OutputStream.
virtual Size write (const Ceylan::Byte *buffer, Size length)
 Writes up to maxLength bytes from the specified buffer to this OutputStream.
virtual void writeSint8 (Ceylan::Sint8 toWrite)
 Writes a Ceylan::Sint8 to this output stream.
virtual void writeUint8 (Ceylan::Uint8 toWrite)
 Writes a Ceylan::Uint8 to this output stream.
virtual void writeSint16 (Ceylan::Sint16 toWrite)
 Writes a Ceylan::Sint16 to this output stream.
virtual void writeUint16 (Ceylan::Uint16 toWrite)
 Writes a Ceylan::Uint16 to this output stream.
virtual void writeSint32 (Ceylan::Sint32 toWrite)
 Writes a Ceylan::Sint32 to this output stream.
virtual void writeUint32 (Ceylan::Uint32 toWrite)
 Writes a Ceylan::Uint32 to this output stream.
virtual void writeFloat32 (Ceylan::Float32 toWrite)
 Writes a Ceylan::Uint32 to this output stream.
virtual void writeFloat64 (Ceylan::Float64 toWrite)
 Writes a Ceylan::Uint32 to this output stream.
virtual void writeString (const std::string &toWrite)
 Writes a string to this output stream.
virtual const std::string toString (Ceylan::VerbosityLevels level=Ceylan::high) const
 Returns an user-friendly description of the state of this object.
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 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 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

 OutputStream (const OutputStream &source)
 Copy constructor made private to ensure that it will be never called.
OutputStreamoperator= (const OutputStream &source)
 Assignment operator made private to ensure that it will be never called.

Detailed Description

Abstract output stream class used in IPC.

See also:
Socket, Pipe, File, AnonymousInputStream, InputStream
Note:
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 57 of file CeylanOutputStream.h.


Member Enumeration Documentation

Defines what text output formats for TextDisplayable instances are available.

Enumerator:
rawText 
html 

Definition at line 124 of file CeylanTextDisplayable.h.


Constructor & Destructor Documentation

OutputStream::OutputStream ( bool  blocking = true  )  [explicit]

Basic constructor for OutputStream.

Parameters:
blocking tells whether this output stream should be created in blocking mode (the default) or in non-blocking mode (if supported).

Definition at line 52 of file CeylanOutputStream.cc.

OutputStream::~OutputStream (  )  throw () [virtual]

Basic destructor.

Definition at line 60 of file CeylanOutputStream.cc.

Ceylan::System::OutputStream::OutputStream ( const OutputStream 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.


Member Function Documentation

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.

Returns:
true iff an operation had to be performed.
Exceptions:
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.

Returns:
true iff an operation had to be performed.
Exceptions:
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().

TextDisplayable::TextOutputFormat TextDisplayable::GetOutputFormat (  )  [static, inherited]
virtual StreamID Ceylan::System::OutputStream::getOutputStreamID (  )  const [pure virtual]

Returns the output stream's unique ID.

Exceptions:
OutputStreamException if the operation failed, for example if this output stream has not received a valid identifier yet.

Implemented in Ceylan::Network::Socket, Ceylan::System::File, Ceylan::System::MemoryStream, and Ceylan::System::Pipe.

Referenced by Ceylan::System::Process::RedirectStderr(), Ceylan::System::Process::RedirectStdout(), and toString().

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().

OutputStream& Ceylan::System::OutputStream::operator= ( const OutputStream 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.

void Stream::setBlocking ( bool  newStatus  )  [protected, virtual, inherited]

Sets the blocking mode of this stream.

Parameters:
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.
Exceptions:
NonBlockingNotSupportedException if the operation failed or is not supported.
Note:
This default implementation always raises its exception, streams that supports non-blocking access have to override it.

Reimplemented in Ceylan::Network::Socket, and Ceylan::Network::StreamSocket.

Definition at line 175 of file CeylanStream.cc.

void TextDisplayable::SetOutputFormat ( TextOutputFormat  newOutputFormat  )  [static, inherited]

Sets the current overall text format to be used by TextDisplayable instances.

Parameters:
newOutputFormat the new output format.

Definition at line 72 of file CeylanTextDisplayable.cc.

References Ceylan::TextDisplayable::_OutputFormat.

Referenced by Ceylan::Log::LogHolder::LogHolder().

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.

Parameters:
displayables a list of pointers to TextDisplayable instances/
level the requested verbosity level.
Note:
Text output format is determined from overall settings.
See also:
toString, Ceylan::VerbosityLevels

Definition at line 45 of file CeylanTextDisplayable.cc.

References Ceylan::formatStringList().

const std::string OutputStream::toString ( Ceylan::VerbosityLevels  level = Ceylan::high  )  const [virtual]
Size OutputStream::write ( const Ceylan::Byte buffer,
Size  length 
) [virtual]

Writes up to maxLength bytes from the specified buffer to this OutputStream.

Parameters:
buffer the buffer where to find bytes that must be written. Its size must be at least 'length' bytes.
length the maximum number of bytes that should be read.
Returns:
The number of bytes actually written, which should be equal to 'length'.
Exceptions:
WriteFailedException if a write error occurred.
Note:
This method is not pure virtual so that other methods using it can be defined here. However its OutputStream implementation just throws a WriteFailedException to remember it has to be overloaded.

Reimplemented in Ceylan::Network::Socket, Ceylan::System::File, Ceylan::System::LibfatFile, Ceylan::System::MemoryStream, Ceylan::System::Pipe, and Ceylan::System::StandardFile.

Definition at line 78 of file CeylanOutputStream.cc.

Size OutputStream::write ( const std::string &  message  )  [virtual]

Writes message to this OutputStream.

Parameters:
message the message to write.
Returns:
The number of bytes actually written, which should be equal to the size of the string or lower.
Exceptions:
WriteFailed if a write error occurred.
Note:
This method is not pure virtual so that other methods using it can be defined here. However its OutputStream implementation just throws a WriteFailedException to remember it has to be overloaded.

Reimplemented in Ceylan::Network::Socket, Ceylan::System::File, Ceylan::System::LibfatFile, Ceylan::System::MemoryStream, Ceylan::System::Pipe, and Ceylan::System::StandardFile.

Definition at line 67 of file CeylanOutputStream.cc.

Referenced by Ceylan::XML::XMLSavingVisitor::decrementHeight(), Ceylan::XML::XMLText::saveTo(), Ceylan::XML::XMLMarkup::saveTo(), Ceylan::XML::XMLSavingVisitor::visit(), writeFloat32(), writeFloat64(), writeSint16(), writeSint32(), writeSint8(), writeString(), writeUint16(), writeUint32(), and writeUint8().

void OutputStream::writeFloat32 ( Ceylan::Float32  toWrite  )  [virtual]

Writes a Ceylan::Uint32 to this output stream.

Exceptions:
WriteFailedException in case a system error occured.

Definition at line 219 of file CeylanOutputStream.cc.

References ceylan_bswap_32, and write().

Referenced by Ceylan::Middleware::LightWeightMarshaller::encodeFloat32().

void OutputStream::writeFloat64 ( Ceylan::Float64  toWrite  )  [virtual]

Writes a Ceylan::Uint32 to this output stream.

Exceptions:
WriteFailedException in case a system error occured.

Definition at line 247 of file CeylanOutputStream.cc.

References Ceylan::byteswap(), ceylan_bswap_64, and write().

Referenced by Ceylan::Middleware::LightWeightMarshaller::encodeFloat64().

void OutputStream::writeSint16 ( Ceylan::Sint16  toWrite  )  [virtual]

Writes a Ceylan::Sint16 to this output stream.

Exceptions:
WriteFailedException in case a system error occured.

Definition at line 119 of file CeylanOutputStream.cc.

References ceylan_bswap_16, and write().

Referenced by Ceylan::Middleware::LightWeightMarshaller::encodeSint16().

void OutputStream::writeSint32 ( Ceylan::Sint32  toWrite  )  [virtual]

Writes a Ceylan::Sint32 to this output stream.

Exceptions:
WriteFailedException in case a system error occured.

Definition at line 169 of file CeylanOutputStream.cc.

References ceylan_bswap_32, and write().

Referenced by Ceylan::Middleware::LightWeightMarshaller::encodeSint32().

void OutputStream::writeSint8 ( Ceylan::Sint8  toWrite  )  [virtual]

Writes a Ceylan::Sint8 to this output stream.

Exceptions:
WriteFailedException in case a system error occured.

Definition at line 89 of file CeylanOutputStream.cc.

References write().

Referenced by Ceylan::Middleware::LightWeightMarshaller::encodeSint8().

void OutputStream::writeString ( const std::string &  toWrite  )  [virtual]

Writes a string to this output stream.

Note:
Written strings cannot have more than 65535 characters.
Parameters:
toWrite the string to write to this output stream.
Exceptions:
WriteFailedException in case a system error occured.

Definition at line 286 of file CeylanOutputStream.cc.

References Ceylan::Log::LogPlug::debug(), Ceylan::toString(), Ceylan::Uint16Max, write(), and writeUint16().

Referenced by Ceylan::Middleware::LightWeightMarshaller::encodeString().

void OutputStream::writeUint16 ( Ceylan::Uint16  toWrite  )  [virtual]

Writes a Ceylan::Uint16 to this output stream.

Exceptions:
WriteFailedException in case a system error occured.

Definition at line 144 of file CeylanOutputStream.cc.

References ceylan_bswap_16, and write().

Referenced by Ceylan::Middleware::LightWeightMarshaller::encodeUint16(), and writeString().

void OutputStream::writeUint32 ( Ceylan::Uint32  toWrite  )  [virtual]

Writes a Ceylan::Uint32 to this output stream.

Exceptions:
WriteFailedException in case a system error occured.

Definition at line 194 of file CeylanOutputStream.cc.

References ceylan_bswap_32, and write().

Referenced by Ceylan::Middleware::LightWeightMarshaller::encodeUint32().

void OutputStream::writeUint8 ( Ceylan::Uint8  toWrite  )  [virtual]

Writes a Ceylan::Uint8 to this output stream.

Exceptions:
WriteFailedException in case a system error occured.

Definition at line 104 of file CeylanOutputStream.cc.

References write().

Referenced by Ceylan::Middleware::LightWeightMarshaller::encodeUint8(), and Ceylan::XML::XMLSavingVisitor::visit().


Member Data Documentation

bool Ceylan::System::Stream::_isBlocking [protected, inherited]
TextDisplayable::TextOutputFormat TextDisplayable::_OutputFormat = rawText [static, protected, inherited]

The text format to be used currently by TextDisplayable instances.

Note:
Defaults to raw text.

Definition at line 158 of file CeylanTextDisplayable.h.

Referenced by Ceylan::TextDisplayable::GetOutputFormat(), and Ceylan::TextDisplayable::SetOutputFormat().


The documentation for this class was generated from the following files:
Generated on Mon Nov 29 13:42:54 2010 for Ceylan by  doxygen 1.6.3