Helper for reading text files. More...
Public Member Functions | |
void | Close () |
Closes the file. | |
void | Close () |
Closes the file. | |
void | Error (const char *msg,...) |
Prints a formatted error message with line number info. | |
void | Error (const char *msg,...) |
Prints a formatted error message with line number info. | |
bool | Gobble () |
Tries to read one line from a file. | |
bool | Gobble () |
Tries to read one line from a file. | |
int | line_num () const |
Returns the currnet line number. | |
int | line_num () const |
Returns the currnet line number. | |
bool | MoreLines () |
Are there more lines left? | |
bool | MoreLines () |
Are there more lines left? | |
success_t | Open (const char *fname) |
Opens a file. | |
success_t | Open (const char *fname) |
Opens a file. | |
const String & | Peek () const |
Gets the current line. | |
String & | Peek () |
Gets the current line. | |
const String & | Peek () const |
Gets the current line. | |
String & | Peek () |
Gets the current line. | |
TextLineReader () | |
Creates an unitialized object. | |
TextLineReader () | |
Creates an unitialized object. | |
~TextLineReader () | |
Automatically closes the file. | |
~TextLineReader () | |
Automatically closes the file. |
Helper for reading text files.
Files are closed automatically when they fall out of scope, though you may choose to close it yourself at no harm.
Definition at line 60 of file textfile.h.
TextLineReader::TextLineReader | ( | ) | [inline] |
Creates an unitialized object.
Definition at line 71 of file textfile.h.
TextLineReader::~TextLineReader | ( | ) | [inline] |
Automatically closes the file.
Definition at line 78 of file textfile.h.
TextLineReader::TextLineReader | ( | ) | [inline] |
Creates an unitialized object.
Definition at line 71 of file textfile.h.
TextLineReader::~TextLineReader | ( | ) | [inline] |
Automatically closes the file.
Definition at line 78 of file textfile.h.
void TextLineReader::Close | ( | ) | [inline] |
Closes the file.
(No need for a return value since you are only reading the file.)
Definition at line 96 of file textfile.h.
void TextLineReader::Close | ( | ) | [inline] |
Closes the file.
(No need for a return value since you are only reading the file.)
Definition at line 96 of file textfile.h.
void TextLineReader::Error | ( | const char * | msg, | |
... | ||||
) |
Prints a formatted error message with line number info.
void TextLineReader::Error | ( | const char * | msg, | |
... | ||||
) |
Prints a formatted error message with line number info.
Definition at line 96 of file textfile.cc.
References String::c_str().
Referenced by DatasetInfo::InitFromArff(), DatasetInfo::InitFromCsv(), DatasetInfo::InitFromFile(), data::LargeLoad(), and DatasetInfo::ReadPoint().
bool TextLineReader::Gobble | ( | ) |
Tries to read one line from a file.
bool TextLineReader::Gobble | ( | ) |
Tries to read one line from a file.
Definition at line 123 of file textfile.cc.
References String::Destruct(), and String::Init().
Referenced by DatasetInfo::InitFromArff(), DatasetInfo::InitFromCsv(), data::LargeLoad(), Open(), and DatasetInfo::ReadPoint().
int TextLineReader::line_num | ( | ) | const [inline] |
Returns the currnet line number.
Definition at line 111 of file textfile.h.
int TextLineReader::line_num | ( | ) | const [inline] |
Returns the currnet line number.
Definition at line 111 of file textfile.h.
Referenced by data::LargeLoad().
bool TextLineReader::MoreLines | ( | ) | [inline] |
Are there more lines left?
Definition at line 104 of file textfile.h.
bool TextLineReader::MoreLines | ( | ) | [inline] |
Are there more lines left?
Definition at line 104 of file textfile.h.
Referenced by DatasetInfo::ReadPoint().
success_t TextLineReader::Open | ( | const char * | fname | ) |
Opens a file.
success_t TextLineReader::Open | ( | const char * | fname | ) |
Opens a file.
Definition at line 109 of file textfile.cc.
References Gobble(), and String::Init().
Referenced by Dataset::InitFromFile(), and data::LargeLoad().
const String& TextLineReader::Peek | ( | ) | const [inline] |
Gets the current line.
Definition at line 125 of file textfile.h.
String& TextLineReader::Peek | ( | ) | [inline] |
Gets the current line.
Definition at line 118 of file textfile.h.
const String& TextLineReader::Peek | ( | ) | const [inline] |
Gets the current line.
Definition at line 125 of file textfile.h.
String& TextLineReader::Peek | ( | ) | [inline] |
Gets the current line.
Definition at line 118 of file textfile.h.
Referenced by DatasetInfo::InitFromArff(), DatasetInfo::InitFromCsv(), DatasetInfo::InitFromFile(), data::LargeLoad(), and DatasetInfo::ReadPoint().