A handle to a stdio FILE* to ensure that the file is properly disposed using RAII.
More...
#include <bond/io/stdiofilehandle.h>
|
| | StdioFileHandle () |
| | Constructs an empty handle that is not bound to a file.
|
| | StdioFileHandle (FILE *file) |
| | Constructs a handle that takes ownership of the given FILE pointer.
|
| | StdioFileHandle (const char *fileName, const char *mode) |
| | Opens a file and constructs a handle that owns the resulting FILE pointer.
|
| | StdioFileHandle (StdioFileHandle &&other) noexcept |
| | Move-constructs a handle by transferring ownership from another handle.
|
| | ~StdioFileHandle () |
| | Destroys the handle and closes the owned file, if any.
|
| StdioFileHandle & | operator= (StdioFileHandle &&other) noexcept |
| | Move-assigns by closing any currently owned file and taking ownership from another handle.
|
| StdioFileHandle & | operator= (FILE *file) |
| | Rebinds the handle to the given FILE pointer.
|
| | StdioFileHandle (const StdioFileHandle &other)=delete |
| StdioFileHandle & | operator= (const StdioFileHandle &other)=delete |
| FILE * | GetFile () const |
| | Returns the currently owned FILE pointer.
|
| FILE * | Release () |
| | Releases ownership of the current FILE pointer without closing it.
|
| void | Reset (FILE *file=nullptr) |
| | Replaces the owned FILE pointer, closing the previously owned file if needed.
|
| bool | IsBound () const |
| | Indicates whether this handle currently owns a FILE pointer.
|
A handle to a stdio FILE* to ensure that the file is properly disposed using RAII.
◆ StdioFileHandle() [1/5]
| Bond::StdioFileHandle::StdioFileHandle |
( |
| ) |
|
|
inline |
Constructs an empty handle that is not bound to a file.
◆ StdioFileHandle() [2/5]
| Bond::StdioFileHandle::StdioFileHandle |
( |
FILE * | file | ) |
|
|
inlineexplicit |
Constructs a handle that takes ownership of the given FILE pointer.
- Parameters
-
| file | Pointer to an open FILE object to be owned by this handle. May be null. |
◆ StdioFileHandle() [3/5]
| Bond::StdioFileHandle::StdioFileHandle |
( |
const char * | fileName, |
|
|
const char * | mode ) |
|
inline |
Opens a file and constructs a handle that owns the resulting FILE pointer.
- Parameters
-
| fileName | The path to the file to open. |
| mode | The fopen mode string used to open the file. |
◆ StdioFileHandle() [4/5]
| Bond::StdioFileHandle::StdioFileHandle |
( |
StdioFileHandle && | other | ) |
|
|
inlinenoexcept |
Move-constructs a handle by transferring ownership from another handle.
- Parameters
-
| other | Source handle whose ownership is transferred. |
◆ ~StdioFileHandle()
| Bond::StdioFileHandle::~StdioFileHandle |
( |
| ) |
|
|
inline |
Destroys the handle and closes the owned file, if any.
◆ StdioFileHandle() [5/5]
| Bond::StdioFileHandle::StdioFileHandle |
( |
const StdioFileHandle & | other | ) |
|
|
delete |
◆ GetFile()
| FILE * Bond::StdioFileHandle::GetFile |
( |
| ) |
const |
|
inline |
Returns the currently owned FILE pointer.
- Returns
- The owned FILE pointer, or null if no file is bound.
◆ IsBound()
| bool Bond::StdioFileHandle::IsBound |
( |
| ) |
const |
|
inline |
Indicates whether this handle currently owns a FILE pointer.
- Returns
- True if a file is bound; otherwise false.
◆ operator=() [1/3]
◆ operator=() [2/3]
Rebinds the handle to the given FILE pointer.
- Parameters
-
| file | Pointer to an open FILE object to be owned by this handle. May be null. |
- Returns
- A reference to this handle.
◆ operator=() [3/3]
Move-assigns by closing any currently owned file and taking ownership from another handle.
- Parameters
-
| other | Source handle whose ownership is transferred. |
- Returns
- A reference to this handle.
◆ Release()
| FILE * Bond::StdioFileHandle::Release |
( |
| ) |
|
|
inline |
Releases ownership of the current FILE pointer without closing it.
- Returns
- The previously owned FILE pointer, or null if no file is bound.
◆ Reset()
| void Bond::StdioFileHandle::Reset |
( |
FILE * | file = nullptr | ) |
|
|
inline |
Replaces the owned FILE pointer, closing the previously owned file if needed.
- Parameters
-
| file | New FILE pointer to own. Defaults to null, which simply unbinds the handle. |
The documentation for this class was generated from the following file:
- include/bond/io/stdiofilehandle.h