CppTools
Loading...
Searching...
No Matches
Box.hpp
Go to the documentation of this file.
1
11#ifndef CPP_TOOLS_BOX_HPP
12#define CPP_TOOLS_BOX_HPP
13
14#include "OutputColor.hpp"
15#include "ErrorHandler.hpp"
16#include "IOTools.hpp"
17#include "StrTools.hpp"
18
20namespace CppTools
21{
46 class Box
47 {
48 public:
49
51 Box();
56 Box(const std::string& boxName, const int width = -1);
60 void SetName(const std::string& boxName);
64 void SetWidth(const int width);
70 void AddEntry(const std::string& name, const double value,
71 const unsigned int precision = 2);
76 void AddEntry(const std::string& name, const int value);
81 void AddEntry(const std::string& name, const short value);
86 void AddEntry(const std::string& name, const long value);
91 void AddEntry(const std::string& name, const unsigned int value);
96 void AddEntry(const std::string& name, const unsigned short value);
101 void AddEntry(const std::string& name, const unsigned long value);
106 void AddEntry(const std::string& name, const std::string& value);
111 void AddEntry(const std::string& name, const bool value);
117 void AddEntry(const std::string& name, const std::vector<double>& values,
118 const unsigned int precision = 2);
123 void AddEntry(const std::string& name, const std::vector<int>& values);
128 void AddEntry(const std::string& name, const std::vector<short>& values);
133 void AddEntry(const std::string& name, const std::vector<long>& values);
138 void AddEntry(const std::string& name, const std::vector<unsigned int>& values);
143 void AddEntry(const std::string& name, const std::vector<unsigned short>& values);
148 void AddEntry(const std::string& name, const std::vector<unsigned long>& values);
153 void AddEntry(const std::string& name, const std::vector<std::string>& values);
158 void AddEntry(const std::string& name, const std::vector<bool>& values);
162 void Print(const std::string& titleColor = COLOR_GREEN);
165 void Clear();
166
169 virtual ~Box();
170
171 protected:
172
174 int boxWidth = -1;
176 std::string name;
178 std::vector<std::string> entryNames, entryValues;
179 };
180}
181#endif /* CPP_TOOLS_BOX_HPP */
Contains useful set of functions to print errors, warning, check existence of files,...
Contains useful set of functions to work with std::string and to convert various types in std::string...
Contains aliases for colors to use in output in terminal.
const std::string COLOR_GREEN
green text
Definition OutputColor.hpp:24
Contains useful set of functions to work with std::string and to convert various types in std::string...
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.
Definition Box.cpp:34
virtual ~Box()
Descructor.
Definition Box.cpp:215
void SetName(const std::string &boxName)
Set box name.
Definition Box.cpp:24
std::string name
text in the head of the box
Definition Box.hpp:176
void SetWidth(const int width)
Set box width.
Definition Box.cpp:29
void Print(const std::string &titleColor=COLOR_GREEN)
Print the box.
Definition Box.cpp:189
std::vector< std::string > entryNames
containers with values and their names
Definition Box.hpp:178
void Clear()
Remove box entries.
Definition Box.cpp:209
int boxWidth
width of the box
Definition Box.hpp:174
Box()
Default constructor.
Definition Box.cpp:16