Main Page | Class Hierarchy | Alphabetical List | Class List | File List | Class Members | File Members | Related Pages

ConsoleReader Class Reference

Inheritance diagram for ConsoleReader:

TextReader List of all members.

Public Attributes

FileConduit conduit

Private Types

typedef AbstractReader 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)
uint int1 (void *src, uint count)
uint int8 (void *src, uint count)
uint int16 (void *src, uint count)
uint int32 (void *src, uint count)
uint int64 (void *src, uint count)
uint float32 (void *src, uint count)
uint float64 (void *src, uint count)
uint float80 (void *src, uint count)

Detailed Description

The ubiquitous console IO support. These are standard FileConduit instances, with Reader/Writer wrappers applied appropriately. Note that the outputs use FlushBuffer to automatically flush data as it is added to the buffer. The basic usage of this module is illustrated below:

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 FileConduit, you can use them as direct targets for Conduit 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:

int x; Stdout ("please input a number: "); 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 130 of file Stdin.d.


Member Typedef Documentation

typedef AbstractReader get get [inherited]
 

Definition at line 57 of file TextReader.d.


Member Function Documentation

this int  device  )  [inline, private]
 

Prohibit instantiation of this class

Definition at line 147 of file Stdin.d.

References FileConduit.

IReader get inout char[]  x,
uint  elements = uint.max
[inline, inherited]
 

Reimplemented from AbstractReader.

Definition at line 234 of file TextReader.d.

References Token::toString().

IReader get inout wchar[]  x,
uint  elements = uint.max
[inline, inherited]
 

Todo:
  • Tokenizer needs to handle wchar[] before this will operate correctly

Reimplemented from AbstractReader.

Definition at line 248 of file TextReader.d.

References assert().

IReader get inout dchar[]  x,
uint  elements = uint.max
[inline, inherited]
 

Todo:
  • Tokenizer needs to handle dchar[] before this will operate correctly

Reimplemented from AbstractReader.

Definition at line 261 of file TextReader.d.

References assert().

this IBuffer  buffer,
ITokenizer  tokenizer = Tokenizers.line
[inline, inherited]
 

Construct a TextReader on the provided buffer, using the specified Tokenizer instead of the default one.

Definition at line 72 of file TextReader.d.

References TextReader::tokenizer.

this IConduit  conduit,
ITokenizer  tokenizer = Tokenizers.line
[inline, inherited]
 

Construct a TextReader upon the buffer associated with the given conduit.

Definition at line 100 of file TextReader.d.

References TextReader::tokenizer.

this IBuffer  buffer  )  [inline, inherited]
 

Return the buffer associated with this reader

Reimplemented in HttpReader, EndianReader, and Reader.

Definition at line 176 of file AbstractReader.d.

References AbstractReader::setAllocator().

uint int1 void *  src,
uint  count
[inline, inherited]
 

Definition at line 122 of file TextReader.d.

References Token::toString().

uint int8 void *  src,
uint  count
[inline, inherited]
 

Definition at line 136 of file TextReader.d.

References Token::toInt().

uint int16 void *  src,
uint  count
[inline, inherited]
 

Definition at line 150 of file TextReader.d.

References Token::toInt().

uint int32 void *  src,
uint  count
[inline, inherited]
 

Definition at line 164 of file TextReader.d.

References Token::toInt().

uint int64 void *  src,
uint  count
[inline, inherited]
 

Definition at line 178 of file TextReader.d.

References Token::toLong().

uint float32 void *  src,
uint  count
[inline, inherited]
 

Definition at line 192 of file TextReader.d.

References Token::toReal().

uint float64 void *  src,
uint  count
[inline, inherited]
 

Definition at line 206 of file TextReader.d.

References Token::toReal().

uint float80 void *  src,
uint  count
[inline, inherited]
 

Definition at line 220 of file TextReader.d.

References Token::toReal().


Member Data Documentation

FileConduit conduit
 

Standard output conduit. This is inside the namespace to reduce clutter

Definition at line 139 of file Stdin.d.


The documentation for this class was generated from the following file:
Generated on Sun Mar 6 00:31:07 2005 for Mango by doxygen 1.3.6