numerical-collection-cpp 0.10.0
A collection of algorithms in numerical analysis implemented in C++
Loading...
Searching...
No Matches
num_collect::logging::sinks::file_wrapper Class Reference

Class to wrap file pointer. More...

#include <num_collect/logging/sinks/file_wrapper.h>

+ Collaboration diagram for num_collect::logging::sinks::file_wrapper:

Public Member Functions

 file_wrapper () noexcept=default
 Constructor.
 
 file_wrapper (const file_wrapper &)=delete
 
 file_wrapper (const std::string &filepath, const char *mode)
 Constructor to open a file.
 
 file_wrapper (file_wrapper &&obj) noexcept
 Move constructor.
 
 file_wrapper (std::FILE *file, bool close_on_destruction)
 Constructor.
 
 ~file_wrapper () noexcept
 Destructor.
 
void close () noexcept
 Close this file.
 
auto file () const noexcept -> std::FILE *
 Get the file pointer.
 
void flush ()
 Flush buffer.
 
void open (const std::string &filepath, const char *mode)
 Open a file.
 
auto operator= (const file_wrapper &)=delete
 
auto operator= (file_wrapper &&obj) noexcept -> file_wrapper &
 Move assignment operator.
 
void set_stderr ()
 Set this file to standard error.
 
void set_stdout ()
 Set this file to standard output.
 
void swap (file_wrapper &obj) noexcept
 Swap with another object.
 
void write (std::string_view data)
 Write data.
 

Private Attributes

bool close_on_destruction_ {false}
 Whether to close the file when destructed.
 
std::FILE * file_ {nullptr}
 File pointer.
 

Detailed Description

Class to wrap file pointer.

Thread Safety
Not thread-safe.

Definition at line 38 of file file_wrapper.h.

Constructor & Destructor Documentation

◆ file_wrapper() [1/3]

num_collect::logging::sinks::file_wrapper::file_wrapper ( std::FILE * file,
bool close_on_destruction )
inline

Constructor.

Parameters
[in]fileFile pointer.
[in]close_on_destructionWhether to close the file when destructed.

Definition at line 52 of file file_wrapper.h.

◆ file_wrapper() [2/3]

num_collect::logging::sinks::file_wrapper::file_wrapper ( const std::string & filepath,
const char * mode )
inline

Constructor to open a file.

Parameters
[in]filepathFilepath.
[in]modeMode to open. (As in std::fopen.)

Definition at line 61 of file file_wrapper.h.

◆ file_wrapper() [3/3]

num_collect::logging::sinks::file_wrapper::file_wrapper ( file_wrapper && obj)
inlinenoexcept

Move constructor.

Parameters
[in]objObject to move from.

Definition at line 73 of file file_wrapper.h.

◆ ~file_wrapper()

num_collect::logging::sinks::file_wrapper::~file_wrapper ( )
inlinenoexcept

Destructor.

Definition at line 92 of file file_wrapper.h.

Member Function Documentation

◆ close()

void num_collect::logging::sinks::file_wrapper::close ( )
inlinenoexcept

Close this file.

Definition at line 140 of file file_wrapper.h.

◆ file()

auto num_collect::logging::sinks::file_wrapper::file ( ) const -> std::FILE*
inlinenodiscardnoexcept

Get the file pointer.

Returns
File pointer.

Definition at line 186 of file file_wrapper.h.

◆ flush()

void num_collect::logging::sinks::file_wrapper::flush ( )
inline

Flush buffer.

Definition at line 169 of file file_wrapper.h.

◆ open()

void num_collect::logging::sinks::file_wrapper::open ( const std::string & filepath,
const char * mode )
inline

Open a file.

Parameters
[in]filepathFilepath.
[in]modeMode to open. (As in std::fopen.)

Definition at line 110 of file file_wrapper.h.

◆ operator=()

auto num_collect::logging::sinks::file_wrapper::operator= ( file_wrapper && obj) -> file_wrapper&
inlinenoexcept

Move assignment operator.

Parameters
[in]objObject to move from.
Returns
This.

Definition at line 84 of file file_wrapper.h.

◆ set_stderr()

void num_collect::logging::sinks::file_wrapper::set_stderr ( )
inline

Set this file to standard error.

Definition at line 132 of file file_wrapper.h.

◆ set_stdout()

void num_collect::logging::sinks::file_wrapper::set_stdout ( )
inline

Set this file to standard output.

Definition at line 124 of file file_wrapper.h.

◆ swap()

void num_collect::logging::sinks::file_wrapper::swap ( file_wrapper & obj)
inlinenoexcept

Swap with another object.

Parameters
[in]objObject to swap with.

Definition at line 99 of file file_wrapper.h.

◆ write()

void num_collect::logging::sinks::file_wrapper::write ( std::string_view data)
inline

Write data.

Parameters
[in]dataData.

Definition at line 153 of file file_wrapper.h.

Member Data Documentation

◆ close_on_destruction_

bool num_collect::logging::sinks::file_wrapper::close_on_destruction_ {false}
private

Whether to close the file when destructed.

Definition at line 193 of file file_wrapper.h.

◆ file_

std::FILE* num_collect::logging::sinks::file_wrapper::file_ {nullptr}
private

File pointer.

Definition at line 190 of file file_wrapper.h.


The documentation for this class was generated from the following file: