Bond 0.9
Bond Standard Library API Documentation
Loading...
Searching...
No Matches
io.bond

API for performing I/O operations. More...

Namespaces

namespace  Bond::IO

Classes

struct  Bond::InputStream
 An abstract interface for performing both unformatted and formatted input operations. More...
struct  Bond::OutputStream
 An abstract interface for performing both unformatted and formatted output operations. More...

Functions

InputStream * Bond::StdIn ()
 Returns the virtual machine's standard input stream.
OutputStream * Bond::StdOut ()
 Returns the virtual machine's standard output stream.
OutputStream * Bond::StdErr ()
 Returns the virtual machine's standard error stream.
InputStream * Bond::CreateInputStream (const char *fileName)
 Opens a file for reading. The stream must be freed manually.
InputStream * Bond::CreateInputStreamCollected (const char *fileName)
 Opens a file for reading. The stream is closed and freed automatically when the calling function returns.
InputStream * Bond::CreateInputStreamWithCollector (Collector *collector, const char *fileName)
 Opens a file for reading. The stream is closed and freed automatically along with a given Collector.
void Bond::FreeInputStream (InputStream *stream)
 Closes and frees a stream returned by CreateInputStream.
OutputStream * Bond::CreateOutputStream (const char *fileName, bool append)
 Opens a file for writing. The stream must be freed manually.
OutputStream * Bond::CreateOutputStreamCollected (const char *fileName, bool append)
 Opens a file for writing. The stream is flushed, closed and freed automatically when the calling function returns.
OutputStream * Bond::CreateOutputStreamWithCollector (Collector *collector, const char *fileName, bool append)
 Opens a file for writing. The stream is flushed, closed and freed automatically along with a given Collector.
void Bond::FreeOutputStream (OutputStream *stream)
 Flushes, closes and frees a stream returned by CreateOutputStream.

Detailed Description

API for performing I/O operations.

include "io.bond";

Function Documentation

◆ CreateInputStream()

InputStream * Bond::CreateInputStream ( const char * fileName)

Opens a file for reading. The stream must be freed manually.

Parameters
fileNameThe name of the file to open, which is resolved by the virtual machine's stream factory.
Returns
The opened stream, which must be freed with FreeInputStream, or null if the file could not be opened.

◆ CreateInputStreamCollected()

InputStream * Bond::CreateInputStreamCollected ( const char * fileName)

Opens a file for reading. The stream is closed and freed automatically when the calling function returns.

Parameters
fileNameThe name of the file to open, which is resolved by the virtual machine's stream factory.
Returns
The opened stream, which must not be freed manually, or null if the file could not be opened.

◆ CreateInputStreamWithCollector()

InputStream * Bond::CreateInputStreamWithCollector ( Collector * collector,
const char * fileName )

Opens a file for reading. The stream is closed and freed automatically along with a given Collector.

Parameters
collectorThe Collector with which the stream is registered. If null, the Collector of the calling function is used.
fileNameThe name of the file to open, which is resolved by the virtual machine's stream factory.
Returns
The opened stream, which must not be freed manually, or null if the file could not be opened.

◆ CreateOutputStream()

OutputStream * Bond::CreateOutputStream ( const char * fileName,
bool append )

Opens a file for writing. The stream must be freed manually.

Parameters
fileNameThe name of the file to open, which is resolved by the virtual machine's stream factory.
appendWhether output is appended to the end of an existing file. Otherwise, an existing file is truncated.
Returns
The opened stream, which must be freed with FreeOutputStream, or null if the file could not be opened.

◆ CreateOutputStreamCollected()

OutputStream * Bond::CreateOutputStreamCollected ( const char * fileName,
bool append )

Opens a file for writing. The stream is flushed, closed and freed automatically when the calling function returns.

Parameters
fileNameThe name of the file to open, which is resolved by the virtual machine's stream factory.
appendWhether output is appended to the end of an existing file. Otherwise, an existing file is truncated.
Returns
The opened stream, which must not be freed manually, or null if the file could not be opened.

◆ CreateOutputStreamWithCollector()

OutputStream * Bond::CreateOutputStreamWithCollector ( Collector * collector,
const char * fileName,
bool append )

Opens a file for writing. The stream is flushed, closed and freed automatically along with a given Collector.

Parameters
collectorThe Collector with which the stream is registered. If null, the Collector of the calling function is used.
fileNameThe name of the file to open, which is resolved by the virtual machine's stream factory.
appendWhether output is appended to the end of an existing file. Otherwise, an existing file is truncated.
Returns
The opened stream, which must not be freed manually, or null if the file could not be opened.

◆ FreeInputStream()

void Bond::FreeInputStream ( InputStream * stream)

Closes and frees a stream returned by CreateInputStream.

The stream must not have been returned by StdIn or by one of the collected creation functions.

Parameters
streamThe stream to free.

◆ FreeOutputStream()

void Bond::FreeOutputStream ( OutputStream * stream)

Flushes, closes and frees a stream returned by CreateOutputStream.

The stream must not have been returned by StdOut, StdErr or by one of the collected creation functions.

Parameters
streamThe stream to free.

◆ StdErr()

OutputStream * Bond::StdErr ( )

Returns the virtual machine's standard error stream.

This stream must not be passed to the FreeOutputStream function.

◆ StdIn()

InputStream * Bond::StdIn ( )

Returns the virtual machine's standard input stream.

This stream must not be passed to the FreeInputStream function.

◆ StdOut()

OutputStream * Bond::StdOut ( )

Returns the virtual machine's standard output stream.

This stream must not be passed to the FreeOutputStream function.