TextStream & Command Line Interface

Global IO Functions

Convenience functions for simple console I/O.

BasicStream

Interface as base for Text*Stream and Byte*Stream.

TextStream

Interface for input / output of text, derived from TextInStream and TextOutStream.

TextOutStream

Interface for writing text, derived from BasicStream.

Cache:

Operator <<

Output stream operator <<, similar to C++ iostreams:

cout << "Text"

Int value = 1
cout << value

But TextStreams are stateless only, i.e. there are no “state manipulators”.

endl does not flush, you need to flush explicitly:

Using output descriptors to control the behaviour:

cout << Hex(address)
cout << Quoted(name)
cout << Escaped(text)

TextInStream

Interface for reading text, derived from BasicStream.

Operator >>

Input stream operators >>, similar to C++ iostreams:

Int i
cin >> i

Float f
cin >> f

Char32 codePoint
cin >> codePoint

String word
cin >> word

But TextStreams are stateless only, i.e. there are no “state manipulators”.

Using input descriptors to control the behaviour:

UInt address
cin >> Hex(address)

String grapheme
cin >> GraphemeCluster(grapheme)

String line
cin >> Line(line)

Technically realized as:

class GraphemeCluster {
    String& storage
}
operator (TextInStream stream) >> (GraphemeCluster graphemeCluster) {
    graphemeCluster.storage = stream.readGraphemeCluster()
}
class Line {
    String& storage
}
operator (TextInStream stream) >> (Line line) {
    line.storage = stream.readLine()
}

TextFile

Class derived from TextStream:

StringStream

Class derived from TextStream: