14 static constexpr
const char *
red =
"\"#DC143C\"";
18 static constexpr
const char *
green =
"\"#7FFF00\"";
22 static constexpr
const char *
blue =
"\"#4169E1\"";
26 static constexpr
const char *
grey =
"\"#D3D3D3\"";
30 static constexpr
const char *
yellow =
"\"#FFFF94\"";
34 static constexpr
const char *
white =
"\"#FFF\"";
38 static constexpr
const char *
black =
"\"#000\"";
50 division_string_stream << std::fixed << std::setprecision(2);
51 division_string_stream <<
"<div>";
61 std::string h_name =
"h" + std::to_string(level);
62 division_string_stream <<
"<" << h_name <<
" align=\"center\" >" << header
63 <<
"</" << h_name <<
">";
72 division_string_stream << text << std::endl;
81 return division_string_stream.str() +
"</div>";
85 std::stringstream division_string_stream;
98 table_string_stream << std::fixed << std::setprecision(2);
99 table_string_stream <<
"<table border=\"1\">";
115 template <
typename DataT>
116 void addCell(
const DataT &data, std::string header =
"",
119 throw std::runtime_error(
"Cannot add cell without beginning row");
121 std::string width_text =
"\"" + std::to_string(colspan * width_) +
"\"";
122 table_string_stream <<
"<td width=" << width_text <<
" colspan=\""
123 << std::to_string(colspan) <<
"\" bgcolor=" << bg_color
125 if (!header.empty()) {
126 table_string_stream << header <<
": ";
128 table_string_stream << data;
129 table_string_stream <<
"</td>";
139 table_string_stream <<
"<tr>";
155 throw std::runtime_error(
"Cannot add cell without beginning row");
157 std::string width_text =
"\"" + std::to_string(colspan * width_) +
"\"";
158 table_string_stream <<
"<th width=" << width_text <<
" colspan=\""
159 << std::to_string(colspan) <<
"\" >";
160 table_string_stream <<
"<font color=" << text_color <<
">" << header
162 table_string_stream <<
"</th>";
174 return table_string_stream.str() +
"</table>";
178 std::stringstream table_string_stream;
187 table_string_stream <<
"</tr>";
static constexpr const char * white
White color hex code.
Definition: html_utils.h:34
static constexpr const char * green
Green color hex code.
Definition: html_utils.h:18
HtmlDivisionWriter()
Constructor.
Definition: html_utils.h:49
std::string getTableString()
Get the html table in string format.
Definition: html_utils.h:170
void addText(std::string text)
Add text to the division.
Definition: html_utils.h:71
static constexpr const char * grey
Grey color hex code.
Definition: html_utils.h:26
Add a division to html.
Definition: html_utils.h:44
static constexpr const char * blue
Blue color hex code.
Definition: html_utils.h:22
void addCell(const DataT &data, std::string header="", std::string bg_color=Colors::white, int colspan=1)
Add a cell to the table. Should be called after beginning a row. Otherwise will throw an exception...
Definition: html_utils.h:116
void addHeader(std::string header, int level=1)
Add a header inside division.
Definition: html_utils.h:60
void beginRow()
Begin a new row in the table.
Definition: html_utils.h:135
Helper class that defines colors in hex format.
Definition: html_utils.h:10
std::string getDivisionText()
Create a divsion html in string format.
Definition: html_utils.h:80
void addHeader(std::string header, std::string text_color=Colors::black, int colspan=1)
Add a table header. Should be called after beginning a row.
Definition: html_utils.h:152
static constexpr const char * yellow
Yellow color hex code.
Definition: html_utils.h:30
HtmlTableWriter(int width=120)
constructor initializes the table header
Definition: html_utils.h:97
Helper class to write html tables to text format.
Definition: html_utils.h:91
static constexpr const char * black
Black color hex code.
Definition: html_utils.h:38
static constexpr const char * red
Red color hex code.
Definition: html_utils.h:14