ot::io
class PrintWriter
#include "ot/io/PrintWriter.h"
A Writer with the capability to do basic output formatting for a variety of built-in types, Characters and Strings.
Unlike its namesake in the Java API, this class does throw exceptions whenever an I/O error occurs.
Constructor/Destructor Summary |
PrintWriter(OutputStream* pOut, bool bAutoFlush)
Creates a PrintWriter for an existing byte output stream. |
PrintWriter(Writer* pWriter, bool bAutoFlush)
Creates a PrintWriter using an existing Writer as the character sink. |
~PrintWriter()
Flushes characters to the underlying output stream before destroying this PrintWriter. |
Method Summary
|
virtual void |
close()
Closes the character stream, flushing it first. |
virtual void |
flush()
Flushes any output buffers before forcing the output to its final destination. |
virtual void |
flushBuffers()
If this Writer maintains an output buffer, the buffer is emptied and written to the output destination without requesting the final destination to flush the output. |
PrintWriter& |
operator<<(PrintWriter&(*)(PrintWriter &) func)
Output operator that takes a function pointer as its parameter. |
PrintWriter& |
operator<<(Character c)
Output operator that prints a Unicode character. |
PrintWriter& |
operator<<(const CharType* pString)
Output operator that prints a null-terminated string. |
PrintWriter& |
operator<<(double d)
Output operator that prints a double-precision floating point value. |
PrintWriter& |
operator<<(float f)
Output operator that prints a floating-point value. |
PrintWriter& |
operator<<(unsigned long l)
Output operator that prints an unsigned long integer value;. |
PrintWriter& |
operator<<(long l)
Output operator that prints a long integer value. |
PrintWriter& |
operator<<(unsigned int i)
Output operator that prints an unsigned integer value. |
PrintWriter& |
operator<<(int i)
Output operator that prints an integer value. |
PrintWriter& |
operator<<(const String& s)
Output operator that prints a String value. |
PrintWriter& |
operator<<(bool x)
Output operator that prints a boolean value. |
void |
print(bool b)
Prints a boolean value as 'true' or 'false'. |
void |
print(Character c)
Prints the single Unicode character c. |
void |
print(const CharType* pStr)
Prints a null-terminated array of CharType characters. |
void |
print(double d)
Prints a double-precision floating-point number. |
void |
print(float f)
Prints a floating-point number. |
void |
print(unsigned long l)
Prints an unsigned long integer. |
void |
print(long l)
Prints a long integer. |
void |
print(unsigned int i)
Prints an unsigned integer. |
void |
print(int i)
Prints an integer. |
void |
print(const String& s)
Prints a String containing a sequence of CharType characters. |
void |
println()
Prints a line separator string as returned from System::GetLineEnding(). |
void |
println(bool x)
Prints a boolean value and then terminates the line. |
void |
println(Character c)
Prints a character and then terminates the line. |
void |
println(const CharType* pStr)
Prints a null-terminated array of CharType characters and then terminates the line. |
void |
println(double d)
Prints a double-precision floating-point number and then terminates the line. |
void |
println(float f)
Prints a floating-point number and then terminates the line. |
void |
println(int i)
Prints an integer and then terminates the line. |
void |
println(unsigned int i)
Prints an unsigned integer and then terminates the line. |
void |
println(long l)
Prints a long integer and then terminates the line. |
void |
println(unsigned long l)
Prints an unsigned long integer and then terminates the line. |
void |
println(const String& s)
Prints a String and then terminates the line. |
virtual void |
write(const CharType* pStr, size_t len)
Writes an array of CharType characters. |
Constructor/Destructor Detail |
PrintWriter
PrintWriter(OutputStream* pOut,
bool bAutoFlush)
-
Creates a PrintWriter for an existing byte output stream.
The system's default encoding will be used to translate from Unicode characters into bytes.
- Parameters:
pOut
-
the underlying OutputStream
bAutoFlush
-
when true, the stream will be flushed after each println() call
- Exceptions:
NullPointerException
-
if pOut is null
PrintWriter
PrintWriter(Writer* pWriter,
bool bAutoFlush)
-
Creates a PrintWriter using an existing Writer as the character sink.
The encoding of the existing Writer will be used to translate from Unicode characters into bytes.
- Parameters:
pWriter
-
the existing Writer to use
bAutoFlush
-
when true, the stream will be flushed after each println() call
- Exceptions:
NullPointerException
-
if pWriter is null
- Multi-threaded considerations:
-
The existing Writer is used as the lock object for synchronized methods.
~PrintWriter
virtual ~PrintWriter()
-
Flushes characters to the underlying output stream before destroying this PrintWriter.
close
virtual void close()
-
Closes the character stream, flushing it first.
- Multi-threaded considerations:
-
Synchronized for safe access from multiple concurrent threads.
flush
virtual void flush()
-
Flushes any output buffers before forcing the output to its final destination.
- Exceptions:
IOException
-
if an I/O error occurs.
- See also:
-
flushBuffers()
- Multi-threaded considerations:
-
Synchronized for safe access from multiple concurrent threads.
flushBuffers
virtual void flushBuffers()
-
If this Writer maintains an output buffer, the buffer is emptied and written to the output destination without requesting the final destination to flush the output.
The base class implementation does nothing.
- See also:
-
flush()
- Multi-threaded considerations:
-
Synchronized for safe access from multiple concurrent threads.
operator<<
PrintWriter& operator<<(PrintWriter&(*)(PrintWriter &) func)
-
Output operator that takes a function pointer as its parameter.
This is required to enable the IO manipulator mechanism to work correctly.
operator<<
PrintWriter& operator<<(Character c)
-
Output operator that prints a Unicode character.
operator<<
PrintWriter& operator<<(const CharType* pString)
-
Output operator that prints a null-terminated string.
operator<<
PrintWriter& operator<<(double d)
-
Output operator that prints a double-precision floating point value.
operator<<
PrintWriter& operator<<(float f)
-
Output operator that prints a floating-point value.
operator<<
PrintWriter& operator<<(unsigned long l)
-
Output operator that prints an unsigned long integer value;.
operator<<
PrintWriter& operator<<(long l)
-
Output operator that prints a long integer value.
operator<<
PrintWriter& operator<<(unsigned int i)
-
Output operator that prints an unsigned integer value.
operator<<
PrintWriter& operator<<(int i)
-
Output operator that prints an integer value.
operator<<
PrintWriter& operator<<(const String& s)
-
Output operator that prints a String value.
operator<<
PrintWriter& operator<<(bool x)
-
Output operator that prints a boolean value.
print
void print(bool b)
-
Prints a boolean value as 'true' or 'false'.
- Multi-threaded considerations:
-
Synchronized for safe access from multiple concurrent threads.
print
void print(Character c)
-
Prints the single Unicode character c.
The character is translated into bytes using the encoding of the underlying Writer.
- Multi-threaded considerations:
-
Synchronized for safe access from multiple concurrent threads.
print
void print(const CharType* pStr)
-
Prints a null-terminated array of CharType characters.
The character array is translated into bytes using the encoding of the underlying Writer.
- Multi-threaded considerations:
-
Synchronized for safe access from multiple concurrent threads.
print
void print(double d)
-
Prints a double-precision floating-point number.
The number is first converted into a String using NumUtils::ToString() before being converted into bytes using the encoding of the underlying Writer.
- See also:
-
NumUtils::ToString()
- Multi-threaded considerations:
-
Synchronized for safe access from multiple concurrent threads.
print
void print(float f)
-
Prints a floating-point number.
The number is first converted into a String using NumUtils::ToString() before being converted into bytes using the encoding of the underlying Writer.
- See also:
-
NumUtils::ToString()
- Multi-threaded considerations:
-
Synchronized for safe access from multiple concurrent threads.
print
void print(unsigned long l)
-
Prints an unsigned long integer.
The unsigned integer is first converted into a String using NumUtils::ToString() before being converted into bytes using the encoding of the underlying Writer.
- See also:
-
NumUtils::ToString()
- Multi-threaded considerations:
-
Synchronized for safe access from multiple concurrent threads.
print
void print(long l)
-
Prints a long integer.
The long integer is first converted into a String using NumUtils::ToString() before being converted into bytes using the encoding of the underlying Writer.
- See also:
-
NumUtils::ToString()
- Multi-threaded considerations:
-
Synchronized for safe access from multiple concurrent threads.
print
void print(unsigned int i)
-
Prints an unsigned integer.
The unsigned integer is first converted into a String using NumUtils::ToString() before being converted into bytes using the encoding of the underlying Writer.
- See also:
-
NumUtils::ToString()
- Multi-threaded considerations:
-
Synchronized for safe access from multiple concurrent threads.
print
void print(int i)
-
Prints an integer.
The integer is first converted into a String using NumUtils::ToString() before being converted into bytes using the encoding of the underlying Writer.
- See also:
-
NumUtils::ToString()
- Multi-threaded considerations:
-
Synchronized for safe access from multiple concurrent threads.
print
void print(const String& s)
-
Prints a String containing a sequence of CharType characters.
The characters are converted into bytes using the encoding of the underlying Writer.
- Multi-threaded considerations:
-
Synchronized for safe access from multiple concurrent threads.
println
void println()
-
Prints a line separator string as returned from System::GetLineEnding().
- See also:
-
System::GetLineEnding()
- Multi-threaded considerations:
-
Synchronized for safe access from multiple concurrent threads.
println
void println(bool x)
-
Prints a boolean value and then terminates the line.
- Multi-threaded considerations:
-
Synchronized for safe access from multiple concurrent threads.
println
void println(Character c)
-
Prints a character and then terminates the line.
- Multi-threaded considerations:
-
Synchronized for safe access from multiple concurrent threads.
println
void println(const CharType* pStr)
-
Prints a null-terminated array of CharType characters and then terminates the line.
- Multi-threaded considerations:
-
Synchronized for safe access from multiple concurrent threads.
println
void println(double d)
-
Prints a double-precision floating-point number and then terminates the line.
- Multi-threaded considerations:
-
Synchronized for safe access from multiple concurrent threads.
println
void println(float f)
-
Prints a floating-point number and then terminates the line.
- Multi-threaded considerations:
-
Synchronized for safe access from multiple concurrent threads.
println
void println(int i)
-
Prints an integer and then terminates the line.
- Multi-threaded considerations:
-
Synchronized for safe access from multiple concurrent threads.
println
void println(unsigned int i)
-
Prints an unsigned integer and then terminates the line.
- Multi-threaded considerations:
-
Synchronized for safe access from multiple concurrent threads.
println
void println(long l)
-
Prints a long integer and then terminates the line.
- Multi-threaded considerations:
-
Synchronized for safe access from multiple concurrent threads.
println
void println(unsigned long l)
-
Prints an unsigned long integer and then terminates the line.
- Multi-threaded considerations:
-
Synchronized for safe access from multiple concurrent threads.
println
void println(const String& s)
-
Prints a String and then terminates the line.
- Multi-threaded considerations:
-
Synchronized for safe access from multiple concurrent threads.
write
virtual void write(const CharType* pStr,
size_t len)
-
Writes an array of CharType characters.
- Parameters:
pStr
-
a pointer to the first CharType character in the array
len
-
the number of CharType characters to write
- Exceptions:
IOException
-
if an I/O error occurs.
- Multi-threaded considerations:
-
Synchronized for safe access from multiple concurrent threads.
Found a bug or missing feature? Please email us at support@elcel.com