Static Public Member Functions | |
this () | |
Static Public Attributes | |
FileConduit | stdin |
FileConduit | stdout |
FileConduit | stderr |
Private Member Functions | |
this () |
char[] msg = "on the console"; Stdout.put ("print ") .put (1) .put (' ') .put ("message ") .put (msg) .cr ();
An alternative is to use the C++ stream operator like so:
char[] msg = "on the console"; Stdout << "print " << 1 << ' ' << "message " << msg << Stdout.newline;
Since console idioms are based upon FileConduit, you can use them as direct targets for Conduit operations. For example, the code:
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:
int x; Stdout.put ("please input a number: "); Stdin.get(x); // or Stdin >> x;
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:
synchronized (Stdout) Stdout << "this is " << "'atomic' " << " output".cr();
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 131 of file Stdio.d.
|
Create a set of Stdio conduits and readers/writers Definition at line 150 of file Stdio.d. References FileConduit::createBuffer(), DisplayWriter, FileConduit, stderr, stdin, stdout, and TextReader. |
|
Prohibit instantiation of this class |
|
Standard IO conduits. These are inside the Stdio namespace since I prefer their usage to be explicit. Definition at line 140 of file Stdio.d. Referenced by this(). |
|
Standard IO conduits. These are inside the Stdio namespace since I prefer their usage to be explicit. Definition at line 140 of file Stdio.d. Referenced by this(). |
|
Standard IO conduits. These are inside the Stdio namespace since I prefer their usage to be explicit. Definition at line 140 of file Stdio.d. Referenced by this(). |