ZeroErr
zeroerr::Printer Struct Reference

A functor class Printer for printing a value of any type. More...

#include <print.h>

Collaboration diagram for zeroerr::Printer:

Public Member Functions

template<typename... Args>
Printeroperator() (Args &&... args)
 
template<typename T >
Printeroperator() (std::initializer_list< T > &&value)
 
void check_stream ()
 
template<typename T , typename... V>
void call (T value, V... others)
 
template<typename T >
void call (T value)
 
 Printer (std::ostream &os)
 
 Printer ()
 
 ~Printer ()
 
 print (T value, unsigned level, const char *lb, rank< 0 >)
 
 print (T value, unsigned level, const char *lb, rank< 0 >)
 
 print (T value, unsigned level, const char *lb, rank< 0 >)
 
 print (T value, unsigned level, const char *lb, rank< 1 >)
 
 print (T value, unsigned level, const char *lb, rank< 2 >)
 
 print (T value, unsigned level, const char *lb, rank< 2 >)
 
 print (const T &value, unsigned level, const char *lb, rank< 2 >)
 
 print (const T &value, unsigned level, const char *lb, rank< 3 >)
 
 print (T value, unsigned level, const char *lb, rank< 3 >)
 
 print (const T &value, unsigned level, const char *lb, rank< 4 >)
 
 print (T value, unsigned level, const char *lb, rank< 4 >)
 
 print (T value, unsigned level, const char *lb, rank< 4 >)
 
template<class TupType >
void print_tuple (const TupType &, unsigned, const char *, detail::seq<>)
 
template<class TupType , unsigned... I>
void print_tuple (const TupType &_tup, unsigned level, const char *, detail::seq< I... >)
 
template<class... Args>
void print (const std::tuple< Args... > &value, unsigned level, const char *lb, rank< 3 >)
 
std::string tab (unsigned level)
 
const char * quote ()
 
std::string str () const
 
 operator std::string () const
 

Static Public Member Functions

template<class T >
static std::string type (const T &t)
 
static std::string demangle (const char *name)
 

Public Attributes

bool isColorful = true
 
bool isCompact = false
 
bool isQuoted = true
 
int indent = 2
 
const char * line_break = "\n"
 
std::ostream & os
 
bool use_stringstream = false
 
bool clear_stream_before_printing = true
 

Friends

std::ostream & operator<< (std::ostream &os, const Printer &P)
 

Detailed Description

A functor class Printer for printing a value of any type.

This class can print values with all basic types, pointers, STL containers, tuple, optional, and variant values. Any class that is streamable can be printed. POD structs can be supported using third-party library Boost.PFR and enum can be supported using magic_enum.

Constructor & Destructor Documentation

◆ Printer() [1/2]

zeroerr::Printer::Printer ( std::ostream &  os)
inline

◆ Printer() [2/2]

zeroerr::Printer::Printer ( )
inline

◆ ~Printer()

zeroerr::Printer::~Printer ( )
inline

Member Function Documentation

◆ call() [1/2]

template<typename T >
void zeroerr::Printer::call ( value)
inline

◆ call() [2/2]

template<typename T , typename... V>
void zeroerr::Printer::call ( value,
V...  others 
)
inline

◆ check_stream()

void zeroerr::Printer::check_stream ( )
inline

◆ demangle()

static std::string zeroerr::Printer::demangle ( const char *  name)
inlinestatic

◆ operator std::string()

zeroerr::Printer::operator std::string ( ) const
inline

◆ operator()() [1/2]

template<typename... Args>
Printer& zeroerr::Printer::operator() ( Args &&...  args)
inline

◆ operator()() [2/2]

template<typename T >
Printer& zeroerr::Printer::operator() ( std::initializer_list< T > &&  value)
inline

◆ print() [1/13]

template<class... Args>
void zeroerr::Printer::print ( const std::tuple< Args... > &  value,
unsigned  level,
const char *  lb,
rank< 3 >   
)
inline

◆ print() [2/13]

zeroerr::Printer::print ( const T &  value,
unsigned  level,
const char *  lb,
rank< 2 >   
)
inline

◆ print() [3/13]

zeroerr::Printer::print ( const T &  value,
unsigned  level,
const char *  lb,
rank< 3 >   
)
inline

◆ print() [4/13]

zeroerr::Printer::print ( const T &  value,
unsigned  level,
const char *  lb,
rank< 4 >   
)
inline

◆ print() [5/13]

zeroerr::Printer::print ( value,
unsigned  level,
const char *  lb,
rank< 0 >   
)
inline

◆ print() [6/13]

zeroerr::Printer::print ( value,
unsigned  level,
const char *  lb,
rank< 0 >   
)
inline

◆ print() [7/13]

zeroerr::Printer::print ( value,
unsigned  level,
const char *  lb,
rank< 0 >   
)
inline

◆ print() [8/13]

zeroerr::Printer::print ( value,
unsigned  level,
const char *  lb,
rank< 1 >   
)
inline

◆ print() [9/13]

zeroerr::Printer::print ( value,
unsigned  level,
const char *  lb,
rank< 2 >   
)
inline

◆ print() [10/13]

zeroerr::Printer::print ( value,
unsigned  level,
const char *  lb,
rank< 2 >   
)
inline

◆ print() [11/13]

zeroerr::Printer::print ( value,
unsigned  level,
const char *  lb,
rank< 3 >   
)
inline

◆ print() [12/13]

zeroerr::Printer::print ( value,
unsigned  level,
const char *  lb,
rank< 4 >   
)
inline

◆ print() [13/13]

zeroerr::Printer::print ( value,
unsigned  level,
const char *  lb,
rank< 4 >   
)
inline

◆ print_tuple() [1/2]

template<class TupType >
void zeroerr::Printer::print_tuple ( const TupType &  ,
unsigned  ,
const char *  ,
detail::seq<>   
)
inline

◆ print_tuple() [2/2]

template<class TupType , unsigned... I>
void zeroerr::Printer::print_tuple ( const TupType &  _tup,
unsigned  level,
const char *  ,
detail::seq< I... >   
)
inline

◆ quote()

const char* zeroerr::Printer::quote ( )
inline

◆ str()

std::string zeroerr::Printer::str ( ) const
inline

◆ tab()

std::string zeroerr::Printer::tab ( unsigned  level)
inline

◆ type()

template<class T >
static std::string zeroerr::Printer::type ( const T &  t)
inlinestatic

Friends And Related Function Documentation

◆ operator<<

std::ostream& operator<< ( std::ostream &  os,
const Printer P 
)
friend

Member Data Documentation

◆ clear_stream_before_printing

bool zeroerr::Printer::clear_stream_before_printing = true

◆ indent

int zeroerr::Printer::indent = 2

◆ isColorful

bool zeroerr::Printer::isColorful = true

◆ isCompact

bool zeroerr::Printer::isCompact = false

◆ isQuoted

bool zeroerr::Printer::isQuoted = true

◆ line_break

const char* zeroerr::Printer::line_break = "\n"

◆ os

std::ostream& zeroerr::Printer::os

◆ use_stringstream

bool zeroerr::Printer::use_stringstream = false

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