CppTools
Loading...
Searching...
No Matches
CppTools::Box Class Reference

Class Box can be used used to print values and their name in the box. More...

#include <Box.hpp>

Public Member Functions

 Box ()
 Default constructor.
 Box (const std::string &boxName, const int width=-1)
 Constructor with parameters.
void SetName (const std::string &boxName)
 Set box name.
void SetWidth (const int width)
 Set box width.
void AddEntry (const std::string &name, const double value, const unsigned int precision=2)
 Add double-precision floating type value to the box with the set precision.
void AddEntry (const std::string &name, const int value)
 Add int type value to the box.
void AddEntry (const std::string &name, const short value)
 Add short type value to the box.
void AddEntry (const std::string &name, const long value)
 Add long type value to the box.
void AddEntry (const std::string &name, const unsigned int value)
 Add unsigned int type value to the box.
void AddEntry (const std::string &name, const unsigned short value)
 Add unsigned short type value to the box.
void AddEntry (const std::string &name, const unsigned long value)
 Add unsigned long type value to the box.
void AddEntry (const std::string &name, const std::string &value)
 Add std::string type value to the box.
void AddEntry (const std::string &name, const bool value)
 Add bool type value to the box.
void AddEntry (const std::string &name, const std::vector< double > &values, const unsigned int precision=2)
 Add double-precision floating type values to the box with the set precision.
void AddEntry (const std::string &name, const std::vector< int > &values)
 Add int type values to the box.
void AddEntry (const std::string &name, const std::vector< short > &values)
 Add short type values to the box.
void AddEntry (const std::string &name, const std::vector< long > &values)
 Add long type values to the box.
void AddEntry (const std::string &name, const std::vector< unsigned int > &values)
 Add unsigned int type values to the box.
void AddEntry (const std::string &name, const std::vector< unsigned short > &values)
 Add unsigned short type values to the box.
void AddEntry (const std::string &name, const std::vector< unsigned long > &values)
 Add unsigned long type values to the box.
void AddEntry (const std::string &name, const std::vector< std::string > &values)
 Add std::string type values to the box.
void AddEntry (const std::string &name, const std::vector< bool > &values)
 Add bool type values to the box.
void Print (const std::string &titleColor=COLOR_GREEN)
 Print the box.
void Clear ()
 Remove box entries.
virtual ~Box ()
 Descructor.

Protected Attributes

int boxWidth = -1
 width of the box
std::string name
 text in the head of the box
std::vector< std::string > entryNames
 containers with values and their names
std::vector< std::string > entryValues

Detailed Description

Class Box can be used used to print values and their name in the box.

Example:

CppTools::Box box("text", 20);
box.AddEntry("value1", 1);
box.AddEntry("value2", true);
box.AddEntry("value3", 0.4, 2);
box.AddEntry("value4", "some text");
box.Print()
Class Box can be used used to print values and their name in the box.
Definition Box.hpp:47

Result:

 ╔════════════════╗
 ║      text      ║
 ╟────────────────╢
 ║ value1       1 ║
 ║ value2    true ║
 ║ value3    0.40 ║
 ║ value4    true ║
 ╚════════════════╝

Constructor & Destructor Documentation

◆ Box()

CppTools::Box::Box ( const std::string & boxName,
const int width = -1 )

Constructor with parameters.

Parameters
[in]boxNametext to be printed in the head of the box
[in]widthwidth of the box (negative value will result for the box to be printed with the width of a terminal)

Member Function Documentation

◆ AddEntry() [1/18]

void CppTools::Box::AddEntry ( const std::string & name,
const bool value )

Add bool type value to the box.

Parameters
[in]namevalue's name
[in]valueit will converted into std::string and printed as either "true" or "false"

◆ AddEntry() [2/18]

void CppTools::Box::AddEntry ( const std::string & name,
const double value,
const unsigned int precision = 2 )

Add double-precision floating type value to the box with the set precision.

Parameters
[in]namevalue's name
[in]value
[in]precisionfloating point precision

◆ AddEntry() [3/18]

void CppTools::Box::AddEntry ( const std::string & name,
const int value )

Add int type value to the box.

Parameters
[in]namevalue's name
[in]value

◆ AddEntry() [4/18]

void CppTools::Box::AddEntry ( const std::string & name,
const long value )

Add long type value to the box.

Parameters
[in]namevalue's name
[in]value

◆ AddEntry() [5/18]

void CppTools::Box::AddEntry ( const std::string & name,
const short value )

Add short type value to the box.

Parameters
[in]namevalue's name
[in]value

◆ AddEntry() [6/18]

void CppTools::Box::AddEntry ( const std::string & name,
const std::string & value )

Add std::string type value to the box.

Parameters
[in]namevalue's name
[in]value

◆ AddEntry() [7/18]

void CppTools::Box::AddEntry ( const std::string & name,
const std::vector< bool > & values )

Add bool type values to the box.

Parameters
[in]namevalues names
[in]valueeach value will converted into std::string and printed as either "true" or "false"

◆ AddEntry() [8/18]

void CppTools::Box::AddEntry ( const std::string & name,
const std::vector< double > & values,
const unsigned int precision = 2 )

Add double-precision floating type values to the box with the set precision.

Parameters
[in]namevalues names
[in]values
[in]precisionfloating point precision

◆ AddEntry() [9/18]

void CppTools::Box::AddEntry ( const std::string & name,
const std::vector< int > & values )

Add int type values to the box.

Parameters
[in]namevalues names
[in]values

◆ AddEntry() [10/18]

void CppTools::Box::AddEntry ( const std::string & name,
const std::vector< long > & values )

Add long type values to the box.

Parameters
[in]namevalues names
[in]values

◆ AddEntry() [11/18]

void CppTools::Box::AddEntry ( const std::string & name,
const std::vector< short > & values )

Add short type values to the box.

Parameters
[in]namevalues names
[in]values

◆ AddEntry() [12/18]

void CppTools::Box::AddEntry ( const std::string & name,
const std::vector< std::string > & values )

Add std::string type values to the box.

Parameters
[in]namevalues names
[in]values

◆ AddEntry() [13/18]

void CppTools::Box::AddEntry ( const std::string & name,
const std::vector< unsigned int > & values )

Add unsigned int type values to the box.

Parameters
[in]namevalues names
[in]values

◆ AddEntry() [14/18]

void CppTools::Box::AddEntry ( const std::string & name,
const std::vector< unsigned long > & values )

Add unsigned long type values to the box.

Parameters
[in]namevalues names
[in]values

◆ AddEntry() [15/18]

void CppTools::Box::AddEntry ( const std::string & name,
const std::vector< unsigned short > & values )

Add unsigned short type values to the box.

Parameters
[in]namevalues names
[in]values

◆ AddEntry() [16/18]

void CppTools::Box::AddEntry ( const std::string & name,
const unsigned int value )

Add unsigned int type value to the box.

Parameters
[in]namevalue's name
[in]value

◆ AddEntry() [17/18]

void CppTools::Box::AddEntry ( const std::string & name,
const unsigned long value )

Add unsigned long type value to the box.

Parameters
[in]namevalue's name
[in]value

◆ AddEntry() [18/18]

void CppTools::Box::AddEntry ( const std::string & name,
const unsigned short value )

Add unsigned short type value to the box.

Parameters
[in]namevalue's name
[in]value

◆ Print()

void CppTools::Box::Print ( const std::string & titleColor = COLOR_GREEN)

Print the box.

Parameters
[in]titleColorcolor of the text in the head of the box

◆ SetName()

void CppTools::Box::SetName ( const std::string & boxName)

Set box name.

Parameters
[in]boxNametext to be printed in the head of the box

◆ SetWidth()

void CppTools::Box::SetWidth ( const int width)

Set box width.

Parameters
[in]widthwidth of the box (negative value will result in a box to be printed with the width of a terminal)

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