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

Stdio Class Reference

List of all members.

Static Public Member Functions

 this ()

Static Public Attributes

FileConduit stdin
FileConduit stdout
FileConduit stderr

Private Member Functions

 this ()

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.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:

FileConduit fc = new FileConduit ("myfile.txt", FileStyle.Read); Stdio.stdout.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.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.


Member Function Documentation

this  )  [inline, static]
 

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.

this  )  [inline, private]
 

Prohibit instantiation of this class

Definition at line 167 of file Stdio.d.


Member Data Documentation

FileConduit stdin [static]
 

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().

FileConduit stdout [static]
 

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().

FileConduit stderr [static]
 

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().


The documentation for this class was generated from the following file:
Generated on Sun Nov 7 19:07:11 2004 for Mango by doxygen 1.3.6