Dune::Copasi 2.1.0-git79717215+dune.gitlab.629933
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages Concepts
Public Member Functions | Static Public Member Functions | List of all members
Dune::Copasi::OStreamRedirect Class Referencefinal

Helper class to redirect std::ostream to a functor. More...

#include <ostream_redirect.hh>

Inheritance diagram for Dune::Copasi::OStreamRedirect:

Public Member Functions

 ~OStreamRedirect () override
 
 OStreamRedirect (const OStreamRedirect &other)=delete
 
OStreamRedirectoperator= (const OStreamRedirect &other)=delete
 
 OStreamRedirect (OStreamRedirect &&other) noexcept=delete
 
OStreamRedirectoperator= (OStreamRedirect &&other) noexcept=delete
 

Static Public Member Functions

static std::unique_ptr< OStreamRedirectmake (std::ostream &ostream, fu2::unique_function< void(std::string_view)> redirection, bool line_buffered=true)
 RAII safe constructor of the redirection object While the object is alive, the output of ostream will be redirected to the redirection functor. More...
 

Detailed Description

Helper class to redirect std::ostream to a functor.

This object takes an std::ostream and redirects its input to a stream buffer owned by this class. When the stream syncs, it forwards the resulting strings views to a functor. It has the effect to redirect the output stream to the functor.

This std::ostream does not directly output data, but forwards any input to its associated functor. It can operate in two different modes:

Author
Steffen Müthing

Constructor & Destructor Documentation

◆ ~OStreamRedirect()

Dune::Copasi::OStreamRedirect::~OStreamRedirect ( )
override

◆ OStreamRedirect() [1/2]

Dune::Copasi::OStreamRedirect::OStreamRedirect ( const OStreamRedirect other)
delete

◆ OStreamRedirect() [2/2]

Dune::Copasi::OStreamRedirect::OStreamRedirect ( OStreamRedirect &&  other)
deletenoexcept

Member Function Documentation

◆ make()

static std::unique_ptr< OStreamRedirect > Dune::Copasi::OStreamRedirect::make ( std::ostream &  ostream,
fu2::unique_function< void(std::string_view)>  redirection,
bool  line_buffered = true 
)
static

RAII safe constructor of the redirection object While the object is alive, the output of ostream will be redirected to the redirection functor.

Parameters
ostreamThe output stream to redirect
redirectionThe functor to redirect the stream of characters
line_bufferedWhether to operate on buffered mode
Returns
RAII safe pointer to a redirection object

◆ operator=() [1/2]

OStreamRedirect & Dune::Copasi::OStreamRedirect::operator= ( const OStreamRedirect other)
delete

◆ operator=() [2/2]

OStreamRedirect & Dune::Copasi::OStreamRedirect::operator= ( OStreamRedirect &&  other)
deletenoexcept

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