#include <gromacs/utility/filestream.h>
Text input stream implementation for reading from a file.
Implementations for the TextInputStream methods throw FileIOError on any I/O error.
|
static FILE * | openRawHandle (const char *filename) |
| Opens a file and returns a FILE handle. More...
|
|
static FILE * | openRawHandle (const std::string &filename) |
| Opens a file and returns a FILE handle. More...
|
|
gmx::TextInputFile::TextInputFile |
( |
const std::string & |
filename | ) |
|
|
explicit |
Opens a text file as a stream.
- Parameters
-
[in] | filename | Path to the file to open. |
- Exceptions
-
std::bad_alloc | if out of memory. |
FileIOError | on any I/O error. |
gmx::TextInputFile::TextInputFile |
( |
FILE * |
fp | ) |
|
|
explicit |
Initializes file object from an existing file handle.
- Parameters
-
[in] | fp | File handle to use. |
- Exceptions
-
std::bad_alloc | if out of memory. |
The caller is responsible of closing the file; close() does nothing for an object constructed this way.
void gmx::TextInputFile::close |
( |
| ) |
|
|
virtual |
Closes the stream.
It is not allowed to read from a stream after it has been closed. See TextOutputStream::close() for rationale for a close() method separate from the destructor. For input, failures during close should be rare, but it is clearer to keep the interface symmetric.
Implements gmx::TextInputStream.
FILE * gmx::TextInputFile::handle |
( |
| ) |
|
Returns a raw handle to the input file.
This is provided for interoperability with older C-like code.
FILE * gmx::TextInputFile::openRawHandle |
( |
const char * |
filename | ) |
|
|
static |
Opens a file and returns a FILE
handle.
- Parameters
-
[in] | filename | Path of the file to open. |
- Exceptions
-
Instead of returning NULL
on errors, throws an exception with additional details (including the file name and errno
).
FILE * gmx::TextInputFile::openRawHandle |
( |
const std::string & |
filename | ) |
|
|
static |
Opens a file and returns a FILE
handle.
- Parameters
-
[in] | filename | Path of the file to open. |
- Exceptions
-
Instead of returning NULL
on errors, throws an exception with additional details (including the file name and errno
).
bool gmx::TextInputFile::readLine |
( |
std::string * |
line | ) |
|
|
virtual |
Reads a line (with newline included) from the stream.
- Parameters
-
[out] | line | String to receive the line. |
- Returns
false
if nothing was read because the stream ended.
On error or when false
is returned, line
will be empty.
Implements gmx::TextInputStream.
The documentation for this class was generated from the following files: