16 #ifndef dealii_table_handler_h 17 #define dealii_table_handler_h 20 #include <deal.II/base/config.h> 22 #include <deal.II/base/exceptions.h> 24 #include <boost/serialization/map.hpp> 25 #include <boost/serialization/split_member.hpp> 26 #include <boost/serialization/string.hpp> 27 #include <boost/serialization/vector.hpp> 28 #include <boost/variant.hpp> 37 DEAL_II_NAMESPACE_OPEN
93 cache_string(
bool scientific,
unsigned int precision)
const;
115 template <
class Archive>
117 save(Archive &ar,
const unsigned int version)
const;
123 template <
class Archive>
125 load(Archive &ar,
const unsigned int version);
127 BOOST_SERIALIZATION_SPLIT_MEMBER()
134 variant<int, unsigned int, unsigned long long int, double, std::string>;
146 friend class ::TableHandler;
387 declare_column(
const std::string &key);
395 template <
typename T>
397 add_value(
const std::string &key,
const T
value);
420 set_auto_fill_mode(
const bool state);
435 add_column_to_supercolumn(
const std::string &key,
436 const std::string &superkey);
455 set_column_order(
const std::vector<std::string> &new_order);
463 set_precision(
const std::string &key,
const unsigned int precision);
470 set_scientific(
const std::string &key,
const bool scientific);
478 set_tex_caption(
const std::string &key,
const std::string &tex_caption);
484 set_tex_table_caption(
const std::string &table_caption);
490 set_tex_table_label(
const std::string &table_label);
498 set_tex_supercaption(
const std::string &superkey,
499 const std::string &tex_supercaption);
508 set_tex_format(
const std::string &key,
const std::string &format =
"c");
522 write_text(std::ostream & out,
533 write_tex(std::ostream &file,
const bool with_header =
true)
const;
554 template <
class Archive>
556 serialize(Archive &ar,
const unsigned int version);
568 <<
"Column <" << arg1 <<
"> does not exist.");
575 <<
"Supercolumn <" << arg1 <<
"> does not exist.");
582 <<
"Column or supercolumn <" << arg1 <<
"> does not exist.");
592 <<
"Column <" << arg1 <<
"> has " << arg2
593 <<
" rows, but Column <" << arg3 <<
"> has " << arg4
601 <<
"<" << arg1 <<
"> is not a tex column format. Use " 602 <<
"'l', 'c', or 'r' to indicate left, centered, or " 603 <<
"right aligned text.");
620 Column(
const std::string &tex_caption);
627 pad_column_below(
const unsigned int length);
633 template <
class Archive>
635 save(Archive &ar,
const unsigned int version)
const;
636 template <
class Archive>
638 load(Archive &ar,
const unsigned int version);
639 BOOST_SERIALIZATION_SPLIT_MEMBER()
708 get_selected_columns(std::vector<std::string> &sel_columns)
const;
732 mutable std::map<std::string, Column>
columns;
771 template <
typename T>
777 template <
typename T>
789 return boost::get<T>(
value);
795 "This TableEntry object does not store a datum of type T"));
802 template <
class Archive>
809 if (
const int *p = boost::get<int>(&
value))
814 else if (
const unsigned int *p = boost::get<unsigned int>(&
value))
819 else if (
const double *p = boost::get<double>(&
value))
824 else if (
const std::string *p = boost::get<std::string>(&
value))
829 else if (
const unsigned long long int *p =
830 boost::get<unsigned long long int>(&
value))
841 template <
class Archive>
888 unsigned long long int val;
902 template <
typename T>
907 if (columns.find(key) == columns.end())
910 if (auto_fill_mode ==
true)
914 unsigned int max_col_length = 0;
915 for (
const auto &column : columns)
917 std::max(max_col_length,
918 static_cast<unsigned int>(column.second.entries.size()));
920 while (columns[key].entries.size() + 1 < max_col_length)
924 entry.
cache_string(columns[key].scientific, columns[key].precision);
925 columns[key].max_length =
926 std::max(columns[key].max_length,
927 static_cast<unsigned int>(
935 entry.
cache_string(columns[key].scientific, columns[key].precision);
936 columns[key].max_length =
937 std::max(columns[key].max_length,
943 template <
class Archive>
947 ar &entries &tex_caption &tex_format &precision &scientific &flag &max_length;
952 template <
class Archive>
954 TableHandler::Column::load(Archive &ar,
const unsigned int )
956 ar &entries &tex_caption &tex_format &precision &scientific &flag &max_length;
961 template <
class Archive>
965 ar &column_order &columns &supercolumns &tex_supercaptions &tex_table_caption
966 &tex_table_label &auto_fill_mode;
970 DEAL_II_NAMESPACE_CLOSE
std::map< std::string, std::string > tex_supercaptions
void save(Archive &ar, const unsigned int version) const
boost::variant< int, unsigned int, unsigned long long int, double, std::string > value_type
std::map< std::string, Column > columns
void add_value(const std::string &key, const T value)
const std::string & get_cached_string() const
void cache_string(bool scientific, unsigned int precision) const
void load(Archive &ar, const unsigned int version)
std::vector< std::string > column_order
static ::ExceptionBase & ExcMessage(std::string arg1)
std::string tex_table_caption
double get_numeric_value() const
TableEntry get_default_constructed_copy() const
#define DeclException1(Exception1, type1, outsequence)
#define Assert(cond, exc)
void save(Archive &ar, const unsigned int version) const
#define DeclException4(Exception4, type1, type2, type3, type4, outsequence)
void serialize(Archive &ar, const unsigned int version)
std::vector< internal::TableEntry > entries
std::map< std::string, std::vector< std::string > > supercolumns
std::string tex_table_label
static ::ExceptionBase & ExcInternalError()