Skip to content

FileReader

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

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

class FileReader

Provides an interface for reading files, with support for caching and binary files.

DEFINITION
class FileReader;

method file_namesconst

Get the names of all files that have been read.

DEFINITION
std::vector< Symbol >  file_names ( ) const;
RETURNSDESCRIPTION
std::vector< Symbol >

A vector of file names.

method get_lineconst

Get a specific line from a file.

DEFINITION
const std::string & get_line ( Symbol  file,
size_t  line_number ) const;
PARAMETERDESCRIPTION
file

The name of the file.

line_number

The line number to retrieve (0-based).

RETURNSDESCRIPTION
const std::string &

The requested line.

THROWSDESCRIPTION
Exception

If the file has not been read or the line does not exist.

method read

Get the contents of a text file.

DEFINITION
const std::vector< std::string > & read ( Symbol  file_name,
bool  optional = false );
PARAMETERDESCRIPTION
file_name

The name of the file to read.

optional

If true, return an empty file if the file does not exist.

RETURNSDESCRIPTION
const std::vector< std::string > &

The contents of the file as a vector of lines.

THROWSDESCRIPTION
Exception

If the file does not exist and optional is false.

method read_binary

Get the contents of a binary file.

DEFINITION
std::string  read_binary ( Symbol  file_name,
bool  optional = false );
PARAMETERDESCRIPTION
file_name

The name of the file to read.

optional

If true, return an empty string if the file does not exist.

RETURNSDESCRIPTION
std::string

The contents of the file as a string.

THROWSDESCRIPTION
Exception

If the file does not exist and optional is false.

method read_stdin

Get the contents of the standard input.

DEFINITION
const std::vector< std::string > & read_stdin ( );
RETURNSDESCRIPTION
const std::vector< std::string > &

The contents of the standard input as a vector of lines.

member globalstatic

The global file reader instance.

DEFINITION
static FileReader  global;