OGS
anonymous_namespace{FlushStdoutGuard.h}::FlushStdoutGuard Class Referencefinal

Detailed Description

Optionally flushes the standard output upon creation and destruction. Can be used to improve the debug output readability when printing debug messages both from OGS and from Python.

Definition at line 18 of file FlushStdoutGuard.h.

#include <FlushStdoutGuard.h>

Public Member Functions

 FlushStdoutGuard (bool const flush)
 Optionally flushes C++ stdout before running Python code.
 
 ~FlushStdoutGuard ()
 Optionally flushes Python's stdout after running Python code.
 

Private Attributes

const bool _flush
 To flush or not to flush.
 

Constructor & Destructor Documentation

◆ FlushStdoutGuard()

anonymous_namespace{FlushStdoutGuard.h}::FlushStdoutGuard::FlushStdoutGuard ( bool const flush)
inlineexplicit

Optionally flushes C++ stdout before running Python code.

Definition at line 22 of file FlushStdoutGuard.h.

22 : _flush(flush)
23 {
24 if (!flush)
25 {
26 return;
27 }
28
29 std::cout << std::flush;
30 }

◆ ~FlushStdoutGuard()

anonymous_namespace{FlushStdoutGuard.h}::FlushStdoutGuard::~FlushStdoutGuard ( )
inline

Optionally flushes Python's stdout after running Python code.

Definition at line 33 of file FlushStdoutGuard.h.

34 {
35 if (!_flush)
36 {
37 return;
38 }
39
40 using namespace pybind11::literals;
41 pybind11::print("end"_a = "", "flush"_a = true);
42 }

Member Data Documentation

◆ _flush

const bool anonymous_namespace{FlushStdoutGuard.h}::FlushStdoutGuard::_flush
private

To flush or not to flush.

Definition at line 46 of file FlushStdoutGuard.h.


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