16 #ifndef dealii__table_handler_h 17 #define dealii__table_handler_h 20 #include <deal.II/base/config.h> 21 #include <deal.II/base/exceptions.h> 30 #include <boost/variant.hpp> 31 #include <boost/serialization/map.hpp> 32 #include <boost/serialization/string.hpp> 33 #include <boost/serialization/vector.hpp> 34 #include <boost/serialization/split_member.hpp> 37 DEAL_II_NAMESPACE_OPEN
90 void cache_string(
bool scientific,
unsigned int precision)
const;
110 template <
class Archive>
111 void save (Archive &ar,
const unsigned int version)
const;
117 template <
class Archive>
118 void load (Archive &ar,
const unsigned int version);
120 BOOST_SERIALIZATION_SPLIT_MEMBER()
126 typedef boost::variant<int,unsigned int,unsigned long long int,double,std::string>
value_type;
138 friend class ::TableHandler;
355 template <
typename T>
356 void add_value (
const std::string &key,
363 void set_auto_fill_mode (
const bool state);
377 void add_column_to_supercolumn (
const std::string &key,
378 const std::string &superkey);
396 void set_column_order (
const std::vector<std::string> &new_order);
403 void set_precision (
const std::string &key,
404 const unsigned int precision);
410 void set_scientific (
const std::string &key,
411 const bool scientific);
418 void set_tex_caption (
const std::string &key,
419 const std::string &tex_caption);
424 void set_tex_table_caption (
const std::string &table_caption);
429 void set_tex_table_label (
const std::string &table_label);
436 void set_tex_supercaption (
const std::string &superkey,
437 const std::string &tex_supercaption);
445 void set_tex_format (
const std::string &key,
446 const std::string &format=
"c");
459 void write_text (std::ostream &out,
469 void write_tex (std::ostream &file,
const bool with_header=
true)
const;
482 void clear_current_row ();
488 template <
class Archive>
489 void serialize(Archive &ar,
const unsigned int version);
501 <<
"Column <" << arg1 <<
"> does not exist.");
508 <<
"Supercolumn <" << arg1 <<
"> does not exist.");
515 <<
"Column or supercolumn <" << arg1 <<
"> does not exist.");
521 std::string,
int, std::string,
int,
522 <<
"Column <" << arg1 <<
"> has " << arg2
523 <<
" rows, but Column <" << arg3 <<
"> has " << arg4 <<
" rows.");
530 <<
"<" << arg1 <<
"> is not a tex column format. Use " 531 <<
"'l', 'c', or 'r' to indicate left, centered, or " 532 <<
"right aligned text.");
550 Column (
const std::string &tex_caption);
556 void pad_column_below (
const unsigned int length);
562 template <
class Archive>
563 void save(Archive &ar,
const unsigned int version)
const;
564 template<
class Archive>
565 void load(Archive &ar,
const unsigned int version);
566 BOOST_SERIALIZATION_SPLIT_MEMBER()
573 void invalidate_cache();
633 void get_selected_columns (std::vector<std::string> &sel_columns)
const;
640 unsigned int n_rows()
const;
695 template <
typename T>
702 template <
typename T>
713 return boost::get<T>(
value);
717 Assert(
false,
ExcMessage (
"This TableEntry object does not store a datum of type T"));
724 template <
class Archive>
726 const unsigned int)
const 731 if (
const int *p = boost::get<int>(&
value))
736 else if (
const unsigned int *p = boost::get<unsigned int>(&
value))
741 else if (
const double *p = boost::get<double>(&
value))
746 else if (
const std::string *p = boost::get<std::string>(&
value))
751 else if (
const unsigned long long int *p = boost::get<unsigned long long int>(&
value))
762 template <
class Archive>
809 unsigned long long int val;
821 template <
typename T>
826 if (columns.find(key) == columns.end())
828 std::pair<std::string, Column> new_column(key,
Column(key));
829 columns.insert(new_column);
830 column_order.push_back(key);
833 if (auto_fill_mode ==
true)
838 for (std::map< std::string, Column >::iterator p = columns.begin(); p != columns.end(); ++p)
839 n = (n >= p->second.entries.size() ? n : p->second.entries.size());
841 while (columns[key].entries.size()+1 < n)
845 entry.
cache_string(columns[key].scientific, columns[key].precision);
846 columns[key].max_length = std::max(columns[key].max_length, static_cast<unsigned int>(entry.
get_cached_string().length()));
853 entry.
cache_string(columns[key].scientific, columns[key].precision);
854 columns[key].max_length = std::max(columns[key].max_length, static_cast<unsigned int>(entry.
get_cached_string().length()));
858 template <
class Archive>
862 ar &entries &tex_caption
863 & tex_format &precision
869 template<
class Archive>
871 TableHandler::Column::load(Archive &ar,
const unsigned int )
873 ar &entries &tex_caption
874 & tex_format &precision
882 template <
class Archive>
887 ar &column_order &columns
888 & supercolumns &tex_supercaptions
895 DEAL_II_NAMESPACE_CLOSE
std::map< std::string, std::string > tex_supercaptions
void save(Archive &ar, const unsigned int version) const
void add_value(const std::string &key, const T value)
void save(Archive &ar, const unsigned int version) const
void load(Archive &ar, const unsigned int version)
std::vector< std::string > column_order
void cache_string(bool scientific, unsigned int precision) const
static::ExceptionBase & ExcMessage(std::string arg1)
std::string tex_table_caption
#define DeclException1(Exception1, type1, outsequence)
#define Assert(cond, exc)
const std::string & get_cached_string() const
boost::variant< int, unsigned int, unsigned long long int, double, std::string > value_type
double get_numeric_value() const
#define DeclException4(Exception4, type1, type2, type3, type4, outsequence)
TableEntry get_default_constructed_copy() const
void serialize(Archive &ar, const unsigned int version)
std::vector< internal::TableEntry > entries
std::map< std::string, Column > columns
std::map< std::string, std::vector< std::string > > supercolumns
std::string tex_table_label
static::ExceptionBase & ExcInternalError()