Skip to content

FileSource

#include <tpau-cpp-kernal/FileSource.h>

INCLUDE FILE
#include <tpau-cpp-kernal/FileSource.h>

class FileSource

Represents a source of characters from a file, with support for lookahead and seeking.

DEFINITION
class FileSource;

constructor FileSource

DEFINITION
FileSource ( Symbol  filename );
PARAMETERDESCRIPTION
filename

method expand_locationconst

Expand a location within the file to include the current location.

If the location is not within the file, it will be left unchanged.

DEFINITION
void  expand_location ( Location & location ) const;
PARAMETERDESCRIPTION
location

The location to expand.

method filenameconst

Get the name of the file.

DEFINITION
Symbol  filename ( ) const;
RETURNSDESCRIPTION
Symbol

The name of the file.

method get

Get the next character from the file. Returns EOF if the end of the file is reached.

DEFINITION
int  get ( );
RETURNSDESCRIPTION
int

The next character from the file, or EOF if the end of the file is reached.

method locationconst

Get the current location in the file.

DEFINITION
Location  location ( ) const;
RETURNSDESCRIPTION
Location

The current location in the file.

method reset_to

Reset the current position to a new location.

DEFINITION
void  reset_to ( const Location & new_location );
PARAMETERDESCRIPTION
new_location

The new location to reset to.

THROWSDESCRIPTION
Exception

If the new location is not within the file.

method unget

Unget the last character read from the file. The next call to get() will return the same character again.

DEFINITION
void  unget ( );
THROWSDESCRIPTION
Exception

If at the beginning of the file.