Jive reference manual
List of all members | Public Member Functions | Related Functions
jem::io::TextOutput Class Referenceabstract

Provides an interface for writing text-based output. More...

#include <jem/io/TextOutput.h>

Inheritance diagram for jem::io::TextOutput:
Inheritance graph

Public Member Functions

virtual void write (int c)=0
 Writes a single character to this output stream. More...
 
virtual void write (int c, int n)=0
 Writes multiple copies of a character to this output stream. More...
 
virtual void write (const char *buf, int n)=0
 Writes an array of characters to this output stream. More...
 
virtual void printByte (byte b)=0
 Prints a formatted byte to this output stream. More...
 
virtual void printBool (bool b)=0
 Prints a formatted bool to this output stream. More...
 
virtual void printInt (long i)=0
 Prints a formatted integer to this output stream. More...
 
virtual void printFloat (double d)=0
 Prints a formatted double to this output stream. More...
 

Related Functions

(Note that these are not member functions.)

TextOutputoperator<< (TextOutput &out, bool b)
 Prints a boolean to a text output stream. More...
 
TextOutputoperator<< (TextOutput &out, byte b)
 Prints a byte to a text output stream. More...
 
TextOutputoperator<< (TextOutput &out, char c)
 Prints a character to a text output stream. More...
 
TextOutputoperator<< (TextOutput &out, short i)
 Prints a short integer to a text output stream. More...
 
TextOutputoperator<< (TextOutput &out, int i)
 Prints an integer to a text output stream. More...
 
TextOutputoperator<< (TextOutput &out, long i)
 Prints a long integer to a text output stream. More...
 
TextOutputoperator<< (TextOutput &out, float f)
 Prints a float to a text output stream. More...
 
TextOutputoperator<< (TextOutput &out, double d)
 Prints a double to a text output stream. More...
 
TextOutputoperator<< (TextOutput &out, const char *s)
 Prints a string to a text output stream. More...
 
TextOutputoperator<< (TextOutput &out, TextOutput &(*manip)(TextOutput &))
 Applies a manipulator function to a text output stream. More...
 
TextOutputendl (TextOutput &out)
 Writes a newline to a text output stream. More...
 

Additional Inherited Members

- Protected Member Functions inherited from jem::Interface
virtual ~Interface ()
 Empty destructor. More...
 

Detailed Description

The TextOutput interface provides a set of (abstract) functions for writing characters and numbers to an output stream. It is typically used to implement functions that write text output and do not care about the destination of the output.

Many classes in jem provide an overloaded version of the << operator that writes the contents of a class instance in a human-readable format to a text output stream. These so-called print operators can be very useful debugging aids.

See also
Writer, TextInput, DataOutput.
Examples:
game-of-life.cpp.

Member Function Documentation

virtual void jem::io::TextOutput::write ( int  c)
pure virtual

Writes the integer c, cast to an unsigned char, to this output stream.

Parameters
c- the character to be written.
Exceptions
IOException- if an I/O error occurs.

Implemented in jem::mt::ThreadSafeWriter, jem::io::PrintWriter, jem::StringBuffer, jem::io::PrefixWriter, jem::io::BufferedWriter, jem::io::OutputStreamWriter, jem::io::TeeWriter, jem::io::FilterWriter, jem::io::StringWriter, jem::io::StderrWriter, jem::io::StdoutWriter, and jem::io::NullWriter.

virtual void jem::io::TextOutput::write ( int  c,
int  n 
)
pure virtual

Writes n copies of the integer c, cast to an unsigned char, to this output stream.

Parameters
c- the character to be written.
n- the number of copies of the character c to be written.
Precondition
n >= 0
Exceptions
IOException- if an I/O error occurs.

Implemented in jem::io::Writer.

virtual void jem::io::TextOutput::write ( const char *  buf,
int  n 
)
pure virtual

Writes the first n characters stored in the array buf to this output stream.

Parameters
buf- a character array of which the length is at least n.
n- the number of characters to be written.
Precondition
n >= 0
and the array buf is at least n characters long.
Postcondition
The characters buf[0], ..., buf[n - 1] have been written to this output stream.
Exceptions
IOException- if an I/O error occurs.

Implemented in jem::io::Writer.

virtual void jem::io::TextOutput::printByte ( byte  b)
pure virtual

Prints the byte b, converted to a character string, to this output stream. You should normally not call this function directly, but use one of the overloaded print operators.

Parameters
b- the byte to be printed.
Exceptions
IOException- if an I/O error occurs.
See also
operator << ( TextOutput&, byte )

Implemented in jem::io::Writer, jem::StringBuffer, and jem::io::NullWriter.

virtual void jem::io::TextOutput::printBool ( bool  b)
pure virtual

Prints the bool b, converted to a character string, to this output stream. You should normally not call this function directly, but use one of the overloaded print operators.

Parameters
b- the bool to be printed.
Exceptions
IOException- if an I/O error occurs.
See also
operator << ( TextOutput&, bool )

Implemented in jem::io::Writer, jem::io::PrintWriter, jem::StringBuffer, and jem::io::NullWriter.

virtual void jem::io::TextOutput::printInt ( long  i)
pure virtual

Prints the long integer i, converted to a character string, to this output stream. You should normally not call this function directly, but use one of the overloaded print operators.

Parameters
i- the integer to be printed.
Exceptions
IOException- if an I/O error occurs.
See also
operator << ( TextOutput&, long )

Implemented in jem::io::Writer.

virtual void jem::io::TextOutput::printFloat ( double  d)
pure virtual

Prints the double d, converted to a character string, to this output stream. You should normally not call this function directly, but use one of the overloaded print operators.

Parameters
d- the double to be printed.
Exceptions
IOException- if an I/O error occurs.
See also
operator << ( TextOutput&, double )

Implemented in jem::io::Writer, jem::io::PrintWriter, jem::StringBuffer, and jem::io::NullWriter.

Friends And Related Function Documentation

TextOutput & operator<< ( TextOutput out,
bool  b 
)
related

Prints the boolean b to the text output stream out by calling out.printBool(b).

Parameters
out- a text output stream.
b- the boolean to be printed.
Returns
out
Exceptions
IOException- if an I/O error occurs.
TextOutput & operator<< ( TextOutput out,
byte  b 
)
related

Prints the byte b to the text output stream out by calling out.printByte(b).

Parameters
out- a text output stream.
b- the byte to be printed.
Returns
out
Exceptions
IOException- if an I/O error occurs.
TextOutput & operator<< ( TextOutput out,
char  c 
)
related

Prints the character c to the text output stream out by calling out.write(c).

Parameters
out- a text output stream.
c- the character to be printed.
Returns
out
Exceptions
IOException- if an I/O error occurs.
TextOutput & operator<< ( TextOutput out,
short  i 
)
related

Prints the short integer i to the text output stream out by calling out.printInt(s).

Parameters
out- a text output stream.
i- the short integer to be printed.
Returns
out
Exceptions
IOException- if an I/O error occurs.
TextOutput & operator<< ( TextOutput out,
int  i 
)
related

Prints the integer i to the text output stream out by calling out.printInt(i).

Parameters
out- a text output stream.
i- the integer to be printed.
Returns
out
Exceptions
IOException- if an I/O error occurs.
TextOutput & operator<< ( TextOutput out,
long  i 
)
related

Prints the long integer i to the text output stream out by calling out.printInt(i).

Parameters
out- a text output stream.
i- the long integer to be printed.
Returns
out
Exceptions
IOException- if an I/O error occurs.
TextOutput & operator<< ( TextOutput out,
float  f 
)
related

Prints the float f to the text output stream out by calling out.printFloat(f).

Parameters
out- a text output stream.
f- the float to be printed.
Returns
out
Exceptions
IOException- if an I/O error occurs.
TextOutput & operator<< ( TextOutput out,
double  d 
)
related

Prints the double d to the text output stream out by calling out.printFloat(d).

Parameters
out- a text output stream.
d- the double to be printed.
Returns
out
Exceptions
IOException- if an I/O error occurs.
TextOutput & operator<< ( TextOutput out,
const char *  s 
)
related

Prints the null-terminated character array s to the text output stream out.

Parameters
out- a text output stream.
s- a null-terminated character array, or NULL.
Returns
out
Exceptions
IOException- if an I/O error occurs.
TextOutput & operator<< ( TextOutput out,
TextOutput &(*)(TextOutput &)  manip 
)
related

Applies the manipulator function manip to the text output stream out. This operator is equivalent with:

return manip( out );

Parameters
out- a text output stream.
manip- a text output manipulator function.
Returns
out
Exceptions
IOException- if an I/O error occurs.
TextOutput & endl ( TextOutput out)
related

A manipulator function that writes the newline '\n' character to the text output stream out.

Parameters
out- a text output stream.
Returns
out
Exceptions
IOException- if an I/O error occurs.