#include <gromacs/utility/filestream.h>
Text output stream implementation for writing to a file.
Implementations for the TextOutputStream methods throw FileIOError on any I/O error.
|
| TextOutputFile (const std::string &filename) |
| Opens a text file as a stream. More...
|
|
| TextOutputFile (FILE *fp) |
| Initializes file object from an existing file handle. More...
|
|
virtual void | write (const char *text) |
| Writes a given string to the stream.
|
|
virtual void | close () |
| Closes the stream. More...
|
|
gmx::TextOutputFile::TextOutputFile |
( |
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::TextOutputFile::TextOutputFile |
( |
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::TextOutputFile::close |
( |
| ) |
|
|
virtual |
Closes the stream.
It is not allowed to write to a stream after it has been closed. A method separate from the destructor is provided such that errors that occur while closing the stream (e.g., when closing the file) can be handled using exceptions. The destructor is not allowed to throw, so code that wants to observe such errors needs to call close() after it has finished writing to the stream.
Implements gmx::TextOutputStream.
Returns a stream for accessing stderr
.
- Exceptions
-
std::bad_alloc | if out of memory (only on first call). |
Returns a stream for accessing stdout
.
- Exceptions
-
std::bad_alloc | if out of memory (only on first call). |
The documentation for this class was generated from the following files: