cpp-terminal 1.0.0
Small C++ library for writing multiplatform terminal applications
Loading...
Searching...
No Matches
Term::IOStreamInitializer Class Reference

#include <cpp-terminal/iostream_initializer.hpp>

Public Member Functions

 ~IOStreamInitializer () noexcept
 
 IOStreamInitializer () noexcept
 
 IOStreamInitializer (const IOStreamInitializer &)=delete
 
 IOStreamInitializer (IOStreamInitializer &&)=delete
 
IOStreamInitializeroperator= (IOStreamInitializer &&)=delete
 
IOStreamInitializeroperator= (const IOStreamInitializer &)=delete
 

Static Private Attributes

static std::size_t m_counter {0}
 

Detailed Description

Definition at line 17 of file iostream_initializer.hpp.

Constructor & Destructor Documentation

◆ ~IOStreamInitializer()

Term::IOStreamInitializer::~IOStreamInitializer ( )
noexcept

Definition at line 42 of file iostream_initializer.cpp.

44{
45 --m_counter;
46 if(0 == m_counter)
47 {
48 (&Term::cout)->~TOstream();
49 (&Term::cerr)->~TOstream();
50 (&Term::clog)->~TOstream();
51 (&Term::cin)->~TIstream();
52 }
53}
54catch(...)
55{
57}
void ExceptionHandler(const ExceptionDestination &destination=ExceptionDestination::StdErr) noexcept
TOstream & clog
Definition iostream.cpp:23
TOstream & cout
Definition iostream.cpp:22
TOstream & cerr
Definition iostream.cpp:24
TIstream & cin
Definition iostream.cpp:25

◆ IOStreamInitializer() [1/3]

Term::IOStreamInitializer::IOStreamInitializer ( )
noexcept

Definition at line 22 of file iostream_initializer.cpp.

24{
25 if(0 == m_counter)
26 {
27 static const std::ios_base::Init iostreams_init; // Init std::cout etc...
28 static const Term::TerminalInitializer terminal_init; // Make sure terminal is set up.
29 new(&Term::cout) TOstream(Term::Buffer::Type::FullBuffered, BUFSIZ);
30 new(&Term::clog) TOstream(Term::Buffer::Type::LineBuffered, BUFSIZ);
32 new(&Term::cin) TIstream(Term::Buffer::Type::FullBuffered, BUFSIZ);
33 if(is_stdin_a_tty()) { std::cin.rdbuf(Term::cin.rdbuf()); }
34 }
35 ++m_counter;
36}
37catch(...)
38{
40}
bool is_stdin_a_tty()
Check if stdin is a tty.
Definition tty.cpp:32

◆ IOStreamInitializer() [2/3]

Term::IOStreamInitializer::IOStreamInitializer ( const IOStreamInitializer & )
delete

◆ IOStreamInitializer() [3/3]

Term::IOStreamInitializer::IOStreamInitializer ( IOStreamInitializer && )
delete

Member Function Documentation

◆ operator=() [1/2]

IOStreamInitializer & Term::IOStreamInitializer::operator= ( const IOStreamInitializer & )
delete

◆ operator=() [2/2]

IOStreamInitializer & Term::IOStreamInitializer::operator= ( IOStreamInitializer && )
delete

Member Data Documentation

◆ m_counter

std::size_t Term::IOStreamInitializer::m_counter {0}
staticprivate

Definition at line 20 of file iostream_initializer.hpp.

27:
28 static std::size_t m_counter;
29};
30
31} // namespace Term

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