Cross-Platform C++

ot::io
class Console

#include "ot/io/Console.h"

Class module providing access to the standard console i/o streams: In (stdin), Out (stdout) and Err (stderr). It cannot be instantiated - all methods are static.

Multi-threaded considerations:
All methods can safely be called from multiple concurrent threads.



Method Summary
static PrintWriter& cerr()
         Returns a raw C++ reference to the PrintWriter which is connected to the stderr file handle.
static InputStreamReader& cin()
         Returns a raw C++ reference to the InputStreamReader which is connected to the stdin file handle.
static PrintWriter& cout()
         Returns a raw C++ reference to the PrintWriter which is connected to the stdout file handle.
static RefPtr< PrintWriter > Err()
         Returns a PrintWriter connected to the stderr file handle.
static RefPtr< InputStreamReader > In()
         Returns an InputStreamReader connected to the stdin file handle.
static RefPtr< PrintWriter > Out()
         Returns a PrintWriter connected to the stdout file handle.

Method Detail

cerr

static PrintWritercerr()
Returns a raw C++ reference to the PrintWriter which is connected to the stderr file handle. This function has been provided to make it more convenient to use the C++ IO operators on the standard output streams.

   try
   {
       ...
   }
   catch(Exception& e)
   {
       Console::cerr() << e.toString() << endl;
   }

It is unusual for a OpenTop function to return a raw C++ reference to a ManagedObject. However, in this case, OpenTop will ensure that the PrintWriter object exists for the lifetime of the application, thereby removing the need for application code to maintain the reference count.

This function is also remarkable because it deviates from the OpenTop convention of starting static member functions with upper case. This is to be consistent with the standard C++ ostream called cerr.


cin

static InputStreamReadercin()
Returns a raw C++ reference to the InputStreamReader which is connected to the stdin file handle. It is unusual for a OpenTop function to return a raw C++ reference to a ManagedObject. However, in this case, OpenTop will ensure that the InputStreamReader object exists for the lifetime of the application, thereby removing the need for application code to maintain the reference count.

This function is also remarkable because it deviates from the OpenTop convention of starting static member functions with upper case. This is to be consistent with the standard C++ ostream called cin.


cout

static PrintWritercout()
Returns a raw C++ reference to the PrintWriter which is connected to the stdout file handle. This function has been provided to make it more convenient to use the C++ IO operators on the standard output streams.

   int age = 5;
   Console::cout() << OT_T("I am ") << age
                   << OT_T(" years old") << endl;

It is unusual for a OpenTop function to return a raw C++ reference to a ManagedObject. However, in this case, OpenTop will ensure that the PrintWriter object exists for the lifetime of the application, thereby removing the need for application code to maintain the reference count.

This function is also remarkable because it deviates from the OpenTop convention of starting static member functions with upper case. This is to be consistent with the standard C++ ostream called cout.


Err

static RefPtr< PrintWriterErr()
Returns a PrintWriter connected to the stderr file handle.

Multi-threaded considerations:
Can safely be called from multiple concurrent threads.

In

static RefPtr< InputStreamReaderIn()
Returns an InputStreamReader connected to the stdin file handle.

Multi-threaded considerations:
Can safely be called from multiple concurrent threads.

Out

static RefPtr< PrintWriterOut()
Returns a PrintWriter connected to the stdout file handle.

Multi-threaded considerations:
Can safely be called from multiple concurrent threads.


Cross-Platform C++

Found a bug or missing feature? Please email us at support@elcel.com

Copyright © 2000-2003 ElCel Technology   Trademark Acknowledgements