Inheritance diagram for ConsoleWriter:
Public Attributes | |
DeviceConduit | conduit |
Private Types | |
typedef DisplayWriter put | put |
Private Member Functions | |
this (int device) | |
IWriter | put (char[] s) |
IWriter | put (IWritable x) |
this (IBuffer buffer) | |
this (IConduit conduit) | |
this (IBuffer buffer, char[] workspace=null, Format.DblFormat df=&Double.format) |
char[] msg = "on the console"; Stdout ("print ") (1) (' ') ("message ") (msg) (CR);
An alternative is to use put() notation like so:
char[] msg = "on the console"; Stdout.put ("print ") .put (1) .put (' ') .put ("message ") .put (msg) .put (CR);
Another alternative is to use the C++ iostream operators like so:
char[] msg = "on the console"; Stdout << "print " << 1 << ' ' << "message " << msg << CR;
Since console idioms are based upon Conduit, you can use them as direct targets for stream-oriented operations. For example, the code:
FileConduit from = new FileConduit ("myfile.txt"); Stdout.conduit.copy (from);
copies a text file directly to the console. Likewise, you can copy console input directly to a FileConduit or a SocketConduit. Input via Stdin is similar in nature, but uses the Token classes to isolate and parse each token on an input line:
Stdout automatically flushes the output when it sees a CR, so you may need to flush the output manually where a CR is not desired. This is the case in the above example, so we use the empty () to request a flush (which is actually an alias for the flush method).
Note that Stdin awaits a carriage-return before parsing the input into the targets. Note also that the Stdout and Stderr are not written to be thread-safe. As such you may find that output from two threads intersect across each other. If this is a problem you should wrap a synchronized block around the offending entity, like so:
Alternatively, please consider using the mango.log (Logger) package to provide detailed runtime diagnostics from your application. The functionality exposed there is likely sufficient for most application needs.
Redirecting the standard IO handles (via a shell) operates as one would expect.
Definition at line 142 of file Stdout.d.
|
Reimplemented in TextWriter. Definition at line 53 of file FlushWriter.d. |
|
Prohibit instantiation of this class Definition at line 158 of file Stdout.d. References conduit. |
|
look for a trailing ' Reimplemented from Writer. Reimplemented in TextWriter. Definition at line 83 of file FlushWriter.d. References Writer::flush(), and IWriter::put(). |
|
Intercept the IWritable method to catch newlines, and flush the buffer whenever one is emitted Reimplemented from Writer. Reimplemented in TextWriter. Definition at line 98 of file FlushWriter.d. References Writer::flush(), and IWriter::put(). |
|
Construct a FlushWriter upon the specified IBuffer Reimplemented from Writer. Definition at line 61 of file FlushWriter.d. |
|
Construct a FlushWriter upon the specified IConduit Reimplemented from DisplayWriter. Definition at line 72 of file FlushWriter.d. |
|
Construct a DisplayWriter upon the specified IBuffer. One can override the default floating-point formatting by providing an appropriate handler to this constructor. For example, one might configure the DGDouble.format() function instead. Definition at line 95 of file DisplayWriter.d. References Writer::enableArrayPrefix(), DisplayWriter::style, DisplayWriter::utf8(), and DisplayWriter::workspace. |
|
Standard output conduits. Definition at line 150 of file Stdout.d. Referenced by this(). |