|
OpenTop 1.5 | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | Cross-Platform C++ | ||||||
| SUMMARY: CONSTRUCTOR | METHOD | DETAIL: CONSTRUCTOR | METHOD | |||||||
#include "ot/io/Console.h"
Class module providing access to the standard console i/o streams: In (stdin), Out (stdout) and Err (stderr).
Instances of this class cannot be instantiated - all methods are static.
The streams provided by the Console class are created with a default encoding. If this does not match the encoding of the console terminal, the application can configure the Console's encoding via the SetEncoding() method.
| 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 String |
GetEncoding()Returns the name of the encoding used to encode and decode Unicode characters when written to or read from the console. |
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. |
static void |
SetEncoding(const String& encoding)Configures the console to encode and decode Unicode characters using a specified encoding name. |
| Method Detail |
static PrintWriter& cerr()
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.
static InputStreamReader& cin()
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.
static PrintWriter& cout()
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.
static RefPtr< PrintWriter > Err()
static String GetEncoding()
static RefPtr< InputStreamReader > In()
static RefPtr< PrintWriter > Out()
static void SetEncoding(const String& encoding)
encoding - UnsupportedEncodingException -
|
OpenTop 1.5 | |||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | Cross-Platform C++ | ||||||
| SUMMARY: CONSTRUCTOR | METHOD | DETAIL: CONSTRUCTOR | METHOD | |||||||