#include <gromacs/utility/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::filesystem::path &filename) |
|
| TextOutputFile (FILE *fp) |
| Initializes file object from an existing file handle. More...
|
|
void | write (const char *text) override |
| Writes a given string to the stream.
|
|
void | close () override |
| Closes the stream. More...
|
|
gmx::TextOutputFile::TextOutputFile |
( |
const std::filesystem::path & |
filename | ) |
|
|
explicit |
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 |
( |
| ) |
|
|
overridevirtual |
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: