TextStream

BasicStream

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

TextStream

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

TextInStream

Interface for reading text, derived from BasicStream.

Cache:

Operator >>

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

Int i
in >> i

Float f
in >> f

Char32 codePoint
in >> codePoint

String word
in >> word

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

Using input descriptors to control the behaviour:

UInt address
in >> Hex(address)

String grapheme
in >> GraphemeCluster(grapheme)

String line
in >> 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()
}

TextOutStream

Interface for writing text, derived from BasicStream.

Cache:

Operator <<

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

out << "Text"

Int value = 1
out << 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:

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

TextFile

Class derived from TextStream:

StringStream

Class derived from TextStream: