abstract class Writer
Typical use is to use the
Writer factory function to instantiate an
object of an appropriate derived class based on the file extension of the
let writer <- Writer(path);
A write of a single buffer can then be performed with:
A write of a sequence of buffers can be performed with:
writer.startSequence(); writer.print(buffer1); writer.print(buffer2); writer.print(buffer3); writer.endSequence();
which is useful for not keeping the entire contents of the file, to be written, in memory.
Finally, close the file:
A file may not be valid until the writer is closed, depending on the file format.
|Writer||Create a writer for a file.|
|open||Open a file.|
|Write the contents of a buffer into the file.|
|flush||Flush accumulated writes to the file.|
|close||Close the file.|
|startMapping||Start a mapping.|
|endMapping||End a mapping.|
|startSequence||Start a sequence.|
|endSequence||End a sequence.|
Factory Function Details
function Writer(path:String) -> Writer
Create a writer for a file.
- path: Path of the file.
Returns: the writer.
The file extension of
path is used to determine the precise type of the
returned object. Supported file extension are
Member Function Details
abstract function close()
Close the file.
abstract function endMapping()
End a mapping.
abstract function endSequence()
End a sequence.
abstract function flush()
Flush accumulated writes to the file.
abstract function open(path:String)
Open a file.
- path : Path of the file.
abstract function print(buffer:Buffer)
Write the contents of a buffer into the file.
- buffer: Buffer to write.
abstract function startMapping()
Start a mapping.
abstract function startSequence()
Start a sequence.