1.3.49
 
Loading...
Searching...
No Matches
helios::capture_cout Struct Reference

A utility struct to capture and store what is written to std::cout. More...

#include <global.h>

Public Member Functions

std::string get_captured_output () const
 Get the captured cout output as a string.
 
bool has_output () const
 Check if any output has been captured.
 
void clear ()
 Clear the captured output.
 
size_t size () const
 Get the number of characters captured.
 

Data Fields

std::streambuf * old_buf
 
std::ostringstream captured_stream
 

Detailed Description

A utility struct to capture and store what is written to std::cout.

This struct redirects the std::cout stream to an internal string stream while an instance of the struct exists. When the struct is destroyed, it restores the original std::cout output stream. The captured output can be queried and cleared as needed.

Definition at line 1371 of file global.h.

Constructor & Destructor Documentation

◆ capture_cout()

helios::capture_cout::capture_cout ( )
inline

Definition at line 1375 of file global.h.

◆ ~capture_cout()

helios::capture_cout::~capture_cout ( )
inline

Definition at line 1379 of file global.h.

Member Function Documentation

◆ clear()

void helios::capture_cout::clear ( )
inline

Clear the captured output.

Definition at line 1394 of file global.h.

◆ get_captured_output()

std::string helios::capture_cout::get_captured_output ( ) const
inline

Get the captured cout output as a string.

Definition at line 1384 of file global.h.

◆ has_output()

bool helios::capture_cout::has_output ( ) const
inline

Check if any output has been captured.

Definition at line 1389 of file global.h.

◆ size()

size_t helios::capture_cout::size ( ) const
inline

Get the number of characters captured.

Definition at line 1400 of file global.h.

Field Documentation

◆ captured_stream

std::ostringstream helios::capture_cout::captured_stream

Definition at line 1373 of file global.h.

◆ old_buf

std::streambuf* helios::capture_cout::old_buf

Definition at line 1372 of file global.h.


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