hexed 0.4.0
 
Loading...
Searching...
No Matches
hexed::Stream_printer Class Reference

prints to a std::ostream. More...

#include <Printer.hpp>

Inheritance diagram for hexed::Stream_printer:
hexed::Printer

Classes

struct  Format
 for passing text formatting parameters to Stream_printer::Stream_printer More...
 

Public Types

enum  format_type {
  unspecified_type = -1 , default_type = 0 , bold = 1 , dim = 2 ,
  underline = 4 , blink = 5 , reverse = 7 , hidden = 8
}
 specifies the typeface (i.e. font) to print in More...
 
enum  format_color {
  unspecified_color = -1 , default_color = 9 , black = 0 , red = 1 ,
  green = 2 , yellow = 3 , blue = 4 , magenta = 5 ,
  cyan = 6 , gray = 7
}
 specifies the color to print in More...
 

Public Member Functions

 Stream_printer (std::ostream &stream=std::cout, bool use_escape_codes=false, Format emph_format=default_format)
 constructs a Stream_printer
 
void operator() (std::string, bool emph=false, bool replace=false) override
 

Static Public Attributes

static const Format default_format
 

Detailed Description

prints to a std::ostream.

Member Enumeration Documentation

◆ format_color

specifies the color to print in

Note
unspecified_color is not the same as default_color. The latter will explicitly send an ASCII escape code which sets the color to the default. If the output stream was already printing in some non-default color, this will reset it to the default. It also requires the output stream to support colors. On the other hand, unspecified_color indicates that no escape code will be sent to specify the color
Enumerator
unspecified_color 

indicates that the text color is not specified

default_color 

explicitly indicates that the default color should be used

◆ format_type

specifies the typeface (i.e. font) to print in

Enumerator
unspecified_type 

indicates that the type is not specified

reverse 

indicates that the foreground and background colors are swapped

Constructor & Destructor Documentation

◆ Stream_printer()

hexed::Stream_printer::Stream_printer ( std::ostream & stream = std::cout,
bool use_escape_codes = false,
Format emph_format = default_format )

constructs a Stream_printer

Parameters
streamstream to print to
use_escape_codesIf true, ASCII escape codes will be used to apply formatting to the text and play other tricks. This is necessary for the emph and replace arguments of operator() to have any effect, but it also requires the stream to support ASCII escape codes. cout and cerr support these codes, but ASCII files do not.
emph_formatFormatting to apply to emphasized text. Any value other than the default will require use_escape_codes = true.

Member Function Documentation

◆ operator()()

void hexed::Stream_printer::operator() ( std::string message,
bool emph = false,
bool replace = false )
overridevirtual
Parameters
messagewhat you want to print
emphIf true, some form of emphasis formatting will be used, if possible.
replaceIf true, message will replace the current line of text on the screen, rather than be appended to it.

Implements hexed::Printer.


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