Inheritance diagram for ConsoleReader:
Public Attributes | |
DeviceConduit | conduit |
Private Types | |
typedef Reader get | get |
Private Member Functions | |
this (int device) | |
IReader | get (inout char[] x, uint elements=uint.max) |
IReader | get (inout wchar[] x, uint elements=uint.max) |
IReader | get (inout dchar[] x, uint elements=uint.max) |
this (IBuffer buffer, ITokenizer tokenizer=Tokenizers.line) | |
this (IConduit conduit, ITokenizer tokenizer=Tokenizers.line) | |
this (IBuffer buffer) | |
this (IConduit conduit) | |
uint | read (void *src, uint bytes, uint type) |
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 fc = new FileConduit ("myfile.txt"); Stdout.conduit.copy (fc);
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:
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 132 of file Stdin.d.
|
Definition at line 59 of file TextReader.d. |
|
Prohibit instantiation of this class Definition at line 149 of file Stdin.d. References conduit. |
|
Reimplemented from Reader. Definition at line 163 of file TextReader.d. References TextReader::nextToken(), and Token::toString(). |
|
Reimplemented from Reader. Definition at line 177 of file TextReader.d. References assert(). |
|
Reimplemented from Reader. Definition at line 190 of file TextReader.d. References assert(). |
|
Construct a TextReader on the provided buffer, using the specified Tokenizer instead of the default one. Definition at line 76 of file TextReader.d. References TextReader::tokenizer. |
|
Construct a TextReader upon the buffer associated with the given conduit. Definition at line 90 of file TextReader.d. References TextReader::tokenizer. |
|
Construct a Reader upon the provided buffer Reimplemented in HttpReader, and EndianReader. Definition at line 164 of file Reader.d. References Reader::buffer, Reader::Decoder::char16, Reader::Decoder::char32, Reader::Decoder::char8, Reader::decode, Reader::read(), and Reader::setAllocator(). |
|
Construct a Reader upon the buffer associated with the given conduit. |
|
Reimplemented from Reader. Definition at line 99 of file TextReader.d. References TextReader::error(), TextReader::next(), Token::toInt(), Token::toLong(), Token::toReal(), and Token::toString(). |
|
Standard output conduit. This is inside the namespace to reduce clutter Definition at line 141 of file Stdin.d. Referenced by this(). |