libfly  6.2.2
C++20 utility library for Linux, macOS, and Windows
fly::detail::ScopedStreamModifiers Class Reference

#include <stream_util.hpp>

Public Member Functions

 ScopedStreamModifiers (std::ostream &stream) noexcept
 
 ~ScopedStreamModifiers ()
 
void setf (std::ios_base::fmtflags flag)
 
void setf (std::ios_base::fmtflags flag, std::ios_base::fmtflags mask)
 
template<typename Facet >
void locale ()
 
void fill (char ch)
 
void width (std::streamsize size)
 
void precision (std::streamsize size)
 

Detailed Description

RAII helper class to make formatting modifications to a stream and ensure those modifications are reset upon destruction.

Author
Timothy Flynn (trfly.nosp@m.nn89.nosp@m.@pm.m.nosp@m.e)
Version
January 3, 2021

Constructor & Destructor Documentation

◆ ScopedStreamModifiers()

fly::detail::ScopedStreamModifiers::ScopedStreamModifiers ( std::ostream &  stream)
inlineexplicitnoexcept

Constructor. Store the stream's current state to be restored upon destruction.

Parameters
streamThe stream to be modified.

◆ ~ScopedStreamModifiers()

fly::detail::ScopedStreamModifiers::~ScopedStreamModifiers ( )
inline

Destructor. Restore the stream's orginal state.

Member Function Documentation

◆ fill()

void fly::detail::ScopedStreamModifiers::fill ( char  ch)
inline

Set the fill character of the stream.

Parameters
chThe new fill setting.

◆ locale()

template<typename Facet >
void fly::detail::ScopedStreamModifiers::locale
inline

Imbue a new locale onto the stream with a specific facet.

Template Parameters
FacetThe type of facet to imbue.

◆ precision()

void fly::detail::ScopedStreamModifiers::precision ( std::streamsize  size)
inline

Set the precision of the stream.

Parameters
sizeThe new precision setting.

◆ setf() [1/2]

void fly::detail::ScopedStreamModifiers::setf ( std::ios_base::fmtflags  flag)
inline

Sets a formatting flag on the stream.

Parameters
flagThe new formatting setting.

◆ setf() [2/2]

void fly::detail::ScopedStreamModifiers::setf ( std::ios_base::fmtflags  flag,
std::ios_base::fmtflags  mask 
)
inline

Clears a mask of formatting flags on the stream and sets a specific flag.

Parameters
flagThe new formatting setting.
maskThe formatting mask to clear.

◆ width()

void fly::detail::ScopedStreamModifiers::width ( std::streamsize  size)
inline

Set the width of the stream.

Parameters
sizeThe new width setting.

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