ModErn Text Analysis
META Enumerates Textual Applications
Classes | Functions
meta::printing Namespace Reference

Contains functions that print to the terminal and provide progress bars. More...

Classes

struct  default_progress_trait
 
struct  no_progress_trait
 
class  null_progress
 Class adhering to the progress API that can be substituted for it when no progress output is desired. More...
 
class  progress
 Simple class for reporting progress of lengthy operations. More...
 

Functions

std::string add_commas (const std::string &number)
 
std::string make_green (std::string str)
 
std::string make_red (std::string str)
 
std::string make_bold (std::string str)
 
std::string bytes_to_units (double num_bytes)
 Converts a number of bytes into a human-readable number. More...
 
void show_progress (size_t idx, size_t max, size_t freq, const std::string &prefix="")
 
void end_progress (const std::string &prefix)
 Ends output from a call to show_progess by displaying 100% completion. More...
 

Detailed Description

Contains functions that print to the terminal and provide progress bars.

Function Documentation

§ add_commas()

std::string meta::printing::add_commas ( const std::string &  number)
inline
Parameters
numberThe string-encoded number
Returns
the parameter with commas added every thousandths place

§ make_green()

std::string meta::printing::make_green ( std::string  str)
inline
Parameters
strThe string to turn green
Returns
the parameter string colored green

§ make_red()

std::string meta::printing::make_red ( std::string  str)
inline
Parameters
strThe string to turn red
Returns
the parameter string colored red

§ make_bold()

std::string meta::printing::make_bold ( std::string  str)
inline
Parameters
strThe string to turn bold
Returns
the parameter string bolded

§ bytes_to_units()

std::string meta::printing::bytes_to_units ( double  num_bytes)
inline

Converts a number of bytes into a human-readable number.

Parameters
num_bytesThe number in bytes to convert
Returns
a human-readable string

§ show_progress()

void meta::printing::show_progress ( size_t  idx,
size_t  max,
size_t  freq,
const std::string &  prefix = "" 
)
inline
Parameters
idxThe current progress in the operation
maxThe maximum value of idx, when it is done
freqHow often to write output to the terminal
prefixThe text to show before the percentage

§ end_progress()

void meta::printing::end_progress ( const std::string &  prefix)
inline

Ends output from a call to show_progess by displaying 100% completion.

Parameters
prefixThe text to show before the percentage