A rather simple text file line-reader. While this is used with the class TTextFile, it might well be used as a standalone helper, i.e. in cases where the text file is read but does not need to be stored in a vector.
| TLocalBufferSize | The size of the local buffer. If lines are wider and the local buffer is exceeded, it will be replaced by an heap-allocated buffer, which is then reused for any further line. Defaults to 1024. |
Definition at line 29 of file ALib.Files.TextFile.H.
#include <ALib.Files.TextFile.H>
Public Field Index: | |
| std::ifstream | IFStream |
| The input stream opened on construction. | |
| NLocalString< TLocalBufferSize > | Line |
| The line buffer. | |
| alib::IStreamLine | ReadOp |
| std::errc | Status |
Public Method Index: | |
| TextFileLineReader (const CString &filePath) | |
| TextFileLineReader (files::File file) | |
| Substring | NextLine () |
Protected Method Index: | |
| void | construct (const CString &filePath) |
| std::ifstream alib::files::TextFileLineReader< TLocalBufferSize >::IFStream |
The input stream opened on construction.
Definition at line 30 of file ALib.Files.TextFile.H.
| NLocalString<TLocalBufferSize> alib::files::TextFileLineReader< TLocalBufferSize >::Line |
The line buffer.
Definition at line 31 of file ALib.Files.TextFile.H.
| alib::IStreamLine alib::files::TextFileLineReader< TLocalBufferSize >::ReadOp |
An AString-appendable object used for reading.
Definition at line 32 of file ALib.Files.TextFile.H.
| std::errc alib::files::TextFileLineReader< TLocalBufferSize >::Status |
Set after construction. If std::errc(0), the filewas correctly opened.
Definition at line 34 of file ALib.Files.TextFile.H.
|
inline |
Constructor. Opens the file specified by filePath. On success, the field Status will hold std::errc(0), an error code otherwise.
| filePath | The path of the text-file to read. |
Definition at line 59 of file ALib.Files.TextFile.H.
|
inline |
Alternative constructor taking a File object instead of a file's path string.
| file | The text-file to read. |
Definition at line 65 of file ALib.Files.TextFile.H.
|
inlineprotected |
Implementation of the two constructors.
| filePath | The path of the text-file to read. |
Definition at line 40 of file ALib.Files.TextFile.H.
|
inline |
Reads the next text-line into the field Line and returns a Substring pointing to it. When the end of the file is reached, the returned object is nulled.Prior to the invocation, method IsEOF may be called to detect the end of the file actively.
Definition at line 74 of file ALib.Files.TextFile.H.