17#include <boost/io/ios_state.hpp>
44 return std::get<int>(
value);
53 return std::get<unsigned int>(
value);
61 return std::get<std::uint64_t>(
value);
69 return std::get<double>(
value);
74 ExcMessage(
"The number stored by this element of the "
75 "table is not a number."));
84 std::ostringstream
ss;
86 ss << std::setprecision(precision);
89 ss.setf(std::ios::scientific, std::ios::floatfield);
91 ss.setf(std::ios::fixed, std::ios::floatfield);
96 std::visit([&
ss](
const auto &v) {
ss << v; },
value);
117 auto &
arg) {
arg = std::remove_reference_t<decltype(arg)>(); },
129 : tex_caption(tex_caption)
158 while (entries.size() <
size)
160 entries.push_back(entries.back().get_default_constructed_copy());
175 for (
const auto &entry : entries)
177 entry.cache_string(this->scientific, this->precision);
180 static_cast<unsigned int>(entry.get_cached_string().size()));
199 ExcMessage(
"You are trying to declare a column with key <" +
key +
200 "> but such a column already exists."));
213 for (
const auto &column :
columns)
216 static_cast<unsigned int>(column.second.entries.size()));
223 column.second.entries.emplace_back(
"");
225 entry.
cache_string(column.second.scientific, column.second.precision);
226 column.second.max_length =
249 std::pair<std::string, std::vector<std::string>>
new_column(
250 superkey, std::vector<std::string>());
301 const std::string &tex_caption)
338 const std::string &tex_format)
341 Assert(tex_format ==
"l" || tex_format ==
"c" || tex_format ==
"r",
350 const unsigned int precision)
383 for (std::map<std::string, Column>::const_iterator p =
columns.begin();
389 column.second.pad_column_below(
max_rows);
399 std::vector<const Column *> cols;
401 for (
unsigned int j = 0;
j < n_cols; ++
j)
404 const std::map<std::string, Column>::const_iterator
col_iter =
407 cols.push_back(&(
col_iter->second));
417 out <<
"| " << std::left;
418 for (
unsigned int j = 0;
j < n_cols; ++
j)
423 static_cast<unsigned int>(
key.size()));
430 for (
unsigned int i = 0; i <
nrows; ++i)
433 for (
unsigned int j = 0;
j < n_cols; ++
j)
435 const Column &column = *(cols[
j]);
438 out << column.
entries[i].get_cached_string();
451 for (
unsigned int j = 0;
j < n_cols; ++
j)
454 out <<
"# " <<
j + 1 <<
": " <<
key <<
'\n';
458 for (
unsigned int i = 0; i <
nrows; ++i)
460 for (
unsigned int j = 0;
j < n_cols; ++
j)
462 const Column &column = *(cols[
j]);
464 out << column.
entries[i].get_cached_string();
479 for (
unsigned int j = 0;
j < n_cols; ++
j)
482 out <<
"# " <<
j + 1 <<
": " <<
key <<
'\n';
493 unsigned int width = 0;
496 const std::map<std::string,
497 std::vector<std::string>>::const_iterator
504 const std::map<std::string, Column>::const_iterator
508 width +=
col_iter->second.max_length;
514 const std::map<std::string, Column>::const_iterator
517 width =
col_iter->second.max_length;
522 if (width <
key.size())
528 const std::map<std::string,
529 std::vector<std::string>>::const_iterator
537 for (
unsigned int i = 0; i < n_cols; ++i)
572 for (
unsigned int i = 0; i <
nrows; ++i)
574 for (
unsigned int j = 0;
j < n_cols; ++
j)
576 const Column &column = *(cols[
j]);
578 out << column.
entries[i].get_cached_string();
596 out <<
"\\documentclass[10pt]{report}" <<
'\n'
597 <<
"\\usepackage{float}" <<
'\n'
600 <<
"\\begin{document}" <<
'\n';
602 out <<
"\\begin{table}[H]" <<
'\n'
603 <<
"\\begin{center}" <<
'\n'
604 <<
"\\begin{tabular}{|";
610 for (std::map<std::string, Column>::const_iterator p =
columns.begin();
616 column.second.pad_column_below(
max_rows);
626 const std::map<std::string, std::vector<std::string>>::const_iterator
635 const std::map<std::string, Column>::const_iterator
col_iter =
639 out <<
col_iter->second.tex_format <<
"|";
645 const std::map<std::string, Column>::const_iterator
col_iter =
648 out <<
col_iter->second.tex_format <<
"|";
651 out <<
"} \\hline" <<
'\n';
658 const std::map<std::string, std::vector<std::string>>::const_iterator
665 std::map<std::string, std::string>::const_iterator
674 const std::map<std::string, Column>::const_iterator
col_iter =
677 out <<
col_iter->second.tex_caption;
682 out <<
"\\\\ \\hline" <<
'\n';
686 for (
unsigned int i = 0; i <
nrows; ++i)
690 for (
unsigned int j = 0;
j < n_cols; ++
j)
694 const std::map<std::string, Column>::const_iterator
col_iter =
700 out << std::setprecision(column.
precision);
703 out.setf(std::ios::scientific, std::ios::floatfield);
705 out.setf(std::ios::fixed, std::ios::floatfield);
707 std::visit([&out](
const auto &v) { out << v; },
713 out <<
"\\\\ \\hline" <<
'\n';
716 out <<
"\\end{tabular}" <<
'\n' <<
"\\end{center}" <<
'\n';
721 out <<
"\\end{table}" <<
'\n';
723 out <<
"\\end{document}" <<
'\n';
751 std::map<std::string, Column>::const_iterator
col_iter =
columns.begin();
752 unsigned int n =
col_iter->second.entries.size();
773 const std::map<std::string, std::vector<std::string>>::const_iterator
802 std::vector<internal::TableEntry>::size_type n = 0;
803 for (
const auto &column :
columns)
804 n =
std::max(n, column.second.entries.size());
809 if (column.second.entries.size() == n)
810 column.second.entries.pop_back();
void set_tex_format(const std::string &key, const std::string &format="c")
void set_tex_table_caption(const std::string &table_caption)
void set_tex_supercaption(const std::string &superkey, const std::string &tex_supercaption)
void declare_column(const std::string &key)
void write_text(std::ostream &out, const TextOutputFormat format=table_with_headers) const
void set_auto_fill_mode(const bool state)
unsigned int n_rows() const
void get_selected_columns(std::vector< std::string > &sel_columns) const
std::map< std::string, std::vector< std::string > > supercolumns
@ simple_table_with_separate_column_description
@ table_with_separate_column_description
std::map< std::string, std::string > tex_supercaptions
std::string tex_table_label
std::string tex_table_caption
void write_tex(std::ostream &file, const bool with_header=true) const
void add_column_to_supercolumn(const std::string &key, const std::string &superkey)
void set_column_order(const std::vector< std::string > &new_order)
void set_tex_caption(const std::string &key, const std::string &tex_caption)
void set_scientific(const std::string &key, const bool scientific)
std::vector< std::string > column_order
void set_tex_table_label(const std::string &table_label)
void set_precision(const std::string &key, const unsigned int precision)
std::map< std::string, Column > columns
#define DEAL_II_NAMESPACE_OPEN
#define DEAL_II_NAMESPACE_CLOSE
static ::ExceptionBase & ExcSuperColumnNotExistent(std::string arg1)
static ::ExceptionBase & ExcWrongNumberOfDataEntries(std::string arg1, int arg2, std::string arg3, int arg4)
static ::ExceptionBase & ExcIO()
static ::ExceptionBase & ExcColumnNotExistent(std::string arg1)
#define Assert(cond, exc)
static ::ExceptionBase & ExcUndefinedTexFormat(std::string arg1)
static ::ExceptionBase & ExcInternalError()
static ::ExceptionBase & ExcColumnOrSuperColumnNotExistent(std::string arg1)
static ::ExceptionBase & ExcMessage(std::string arg1)
#define AssertThrow(cond, exc)
#define DEAL_II_ASSERT_UNREACHABLE()
::VectorizedArray< Number, width > max(const ::VectorizedArray< Number, width > &, const ::VectorizedArray< Number, width > &)
void pad_column_below(const unsigned int length)
std::vector< internal::TableEntry > entries
TableEntry get_default_constructed_copy() const
const std::string & get_cached_string() const
double get_numeric_value() const
void cache_string(bool scientific, unsigned int precision) const