PMT Renovated main-branch
Partition Manager Tool is a fast, reliable, and feature-rich CLI application for Android devices that enables advanced partition operations such as backup, flashing, erasing, information retrieval, and more.
Loading...
Searching...
No Matches
Helper::BasicUniqueFP< Closer > Class Template Reference

A class that helps with easy file pointer management. More...

#include <management.hpp>

Public Member Functions

 BasicUniqueFP ()=default
 Default constructor, initializes local class variables.
 
 BasicUniqueFP (const BasicUniqueFP &)=delete
 A class that claims the unique property cannot be copied.
 
 BasicUniqueFP (BasicUniqueFP &&other) noexcept
 Move constructor.
 
 BasicUniqueFP (const std::filesystem::path &path, const std::string_view &flags)
 Constructor that opens the file.
 
 BasicUniqueFP (FILE *fp)
 A constructor that takes over the management of an existing file pointer.
 
 ~BasicUniqueFP ()
 The destructor that closes the file pointer.
 
BasicUniqueFPoperator= (const BasicUniqueFP &)=delete
 A class that claims the unique property cannot be copied.
 
BasicUniqueFPoperator= (BasicUniqueFP &&other) noexcept
 Mover = operator.
 
BasicUniqueFP's function declarations.

In-class declarations of functions that work with file pointers.

int rawFd () const noexcept
 Get file descriptor of file pointer.
 
FILE * fp () noexcept
 
const FILE * fp () const noexcept
 
std::string_view flags () noexcept
 Get fopen() flags.
 
std::string_view flags () const noexcept
 Get fopen() flags.
 
mode_t mode () const noexcept
 Get file permissions (mode).
 
std::filesystem::path path () noexcept
 Get file path.
 
std::filesystem::path path () const noexcept
 Get file path.
 
BasicUniqueFPopen (const std::filesystem::path &path, const std::string_view &flags) noexcept
 Open input file.
 
bool reOpen ()
 Class-specific function that reopens the file.
 
void close () noexcept
 
int putc (int c) noexcept
 
int puts (const std::string &s) noexcept
 
template<typename... Args>
int printf (std::format_string< Args... > fmt, Args &&...args) noexcept
 
size_t write (const void *buf, size_t size, size_t nmemb) noexcept
 
int getc () noexcept
 
char * gets (char *str, int size) noexcept
 
size_t read (void *buf, size_t size, size_t count) noexcept
 
template<typename... Args>
int scanf (const char *fmt, Args &&...args) noexcept
 
int seek (long offset, int whence) noexcept
 
long tell () noexcept
 
void rewind () noexcept
 
void clearerr () noexcept
 
int eof () noexcept
 
int error () noexcept
 
int flush () noexcept
 
BasicUniqueFP's operator declarations.

Definitions of operators required for pointer-style behavior and usability.

bool operator! () const noexcept
 
 operator bool () const noexcept
 
FILE * operator() () noexcept
 
FILE * operator() () const noexcept
 
bool operator== (const FILE *fp) const noexcept
 
bool operator!= (const FILE *fp) const noexcept
 

Static Public Member Functions

static BasicUniqueFP getOwnership (FILE *fp)
 An alternative to Helper::BasicUniqueFP(FILE *fp)
 

Public Attributes

bool flushOnClose = true
 Turn on/off flushing before closing (by object).
 

Detailed Description

template<typename Closer = Helper::Closer>
requires IsCloser<Closer, FILE *>
class Helper::BasicUniqueFP< Closer >

A class that helps with easy file pointer management.

auto sfd = BasicUniqueFP("file.txt", "r");
// ... operations
BasicUniqueFP()=default
Default constructor, initializes local class variables.
Template Parameters
CloserCloser class. Helper::Closer used by default.
See also
Helper::IsCloser
Helper::IsCloserWithOperator
Helper::Closer

Constructor & Destructor Documentation

◆ BasicUniqueFP() [1/2]

template<typename Closer = Helper::Closer>
Helper::BasicUniqueFP< Closer >::BasicUniqueFP ( const std::filesystem::path path,
const std::string_view flags 
)
inline

Constructor that opens the file.

Parameters
pathFile path.
flagsOpen flags.
See also
fopen() flags

◆ BasicUniqueFP() [2/2]

template<typename Closer = Helper::Closer>
Helper::BasicUniqueFP< Closer >::BasicUniqueFP ( FILE *  fp)
inlineexplicit

A constructor that takes over the management of an existing file pointer.

Parameters
fpFile pointer.
See also
Helper::BasicUniqueFP::getOwnership

Member Function Documentation

◆ getOwnership()

template<typename Closer = Helper::Closer>
static BasicUniqueFP Helper::BasicUniqueFP< Closer >::getOwnership ( FILE *  fp)
inlinestatic

An alternative to Helper::BasicUniqueFP(FILE *fp)

Parameters
fpFile pointer.
Returns
A BasicUniqueFP object that holds fp.

◆ open()

template<typename Closer = Helper::Closer>
BasicUniqueFP & Helper::BasicUniqueFP< Closer >::open ( const std::filesystem::path path,
const std::string_view flags 
)
inlinenoexcept

Open input file.

Parameters
pathFile path.
flagsOpen flags.
Returns
*this
See also
fopen() flags

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