17 #ifndef __deal2__table_handler_h 18 #define __deal2__table_handler_h 21 #include <deal.II/base/config.h> 31 #include <boost/variant.hpp> 32 #include <boost/serialization/map.hpp> 33 #include <boost/serialization/string.hpp> 34 #include <boost/serialization/vector.hpp> 35 #include <boost/serialization/split_member.hpp> 90 void cache_string(
bool scientific,
unsigned int precision)
const;
111 template <
class Archive>
112 void save (Archive &ar,
const unsigned int version)
const;
119 template <
class Archive>
120 void load (Archive &ar,
const unsigned int version);
122 BOOST_SERIALIZATION_SPLIT_MEMBER()
128 typedef boost::variant<int,unsigned int,unsigned long long int,double,std::string>
value_type;
140 friend class ::TableHandler;
328 table_with_separate_column_description,
329 simple_table_with_separate_column_description,
348 template <
typename T>
349 void add_value (
const std::string &key,
356 void set_auto_fill_mode (
const bool state);
380 void add_column_to_supercolumn (
const std::string &key,
381 const std::string &superkey);
412 void set_column_order (
const std::vector<std::string> &new_order);
422 void set_precision (
const std::string &key,
423 const unsigned int precision);
431 void set_scientific (
const std::string &key,
432 const bool scientific);
442 void set_tex_caption (
const std::string &key,
443 const std::string &tex_caption);
449 void set_tex_table_caption (
const std::string &table_caption);
455 void set_tex_table_label (
const std::string &table_label);
466 void set_tex_supercaption (
const std::string &superkey,
467 const std::string &tex_supercaption);
478 void set_tex_format (
const std::string &key,
479 const std::string &format=
"c");
500 void write_text (std::ostream &out,
515 void write_tex (std::ostream &file,
const bool with_header=
true)
const;
522 template <
class Archive>
523 void serialize(Archive &ar,
const unsigned int version);
533 <<
"Column <" << arg1 <<
"> does not exist.");
540 <<
"Supercolumn <" << arg1 <<
"> does not exist.");
547 <<
"Column or supercolumn <" << arg1 <<
"> does not exist.");
553 std::string,
int, std::string,
int,
554 <<
"Column <" << arg1 <<
"> has got " << arg2
555 <<
" rows, but Column <" << arg3 <<
"> has got " << arg4 <<
".");
562 <<
"<" << arg1 <<
"> is not a tex column format. Use l,c,r.");
581 Column (
const std::string &tex_caption);
587 void pad_column_below (
const unsigned int length);
594 template <
class Archive>
595 void save(Archive &ar,
const unsigned int version)
const;
596 template<
class Archive>
597 void load(Archive &ar,
const unsigned int version);
598 BOOST_SERIALIZATION_SPLIT_MEMBER()
605 void invalidate_cache();
689 void get_selected_columns (std::vector<std::string> &sel_columns)
const;
700 unsigned int n_rows()
const;
770 template <
typename T>
777 template <
typename T>
788 return boost::get<T>(
value);
792 Assert(
false,
ExcMessage (
"This TableEntry object does not store a datum of type T"));
799 template <
class Archive>
801 const unsigned int)
const 806 if (
const int *p = boost::get<int>(&
value))
811 else if (
const unsigned int *p = boost::get<unsigned int>(&
value))
816 else if (
const double *p = boost::get<double>(&
value))
821 else if (
const std::string *p = boost::get<std::string>(&
value))
832 template <
class Archive>
883 template <
typename T>
888 if (columns.find(key) == columns.end())
890 std::pair<std::string, Column> new_column(key,
Column(key));
891 columns.insert(new_column);
892 column_order.push_back(key);
895 if (auto_fill_mode ==
true)
900 for (std::map< std::string, Column >::iterator p = columns.begin(); p != columns.end(); ++p)
901 n = (n >= p->second.entries.size() ? n : p->second.entries.size());
903 while (columns[key].entries.size()+1 < n)
907 entry.
cache_string(columns[key].scientific, columns[key].precision);
908 columns[key].max_length = std::max(columns[key].max_length, static_cast<unsigned int>(entry.
get_cached_string().length()));
915 entry.
cache_string(columns[key].scientific, columns[key].precision);
916 columns[key].max_length = std::max(columns[key].max_length, static_cast<unsigned int>(entry.
get_cached_string().length()));
920 template <
class Archive>
924 ar &entries &tex_caption
925 & tex_format &precision
931 template<
class Archive>
933 TableHandler::Column::load(Archive &ar,
const unsigned int version)
935 ar &entries &tex_caption
936 & tex_format &precision
944 template <
class Archive>
949 ar &column_order &columns
950 & supercolumns &tex_supercaptions
957 DEAL_II_NAMESPACE_CLOSE
std::map< std::string, std::string > tex_supercaptions
void save(Archive &ar, const unsigned int version) const
::ExceptionBase & ExcMessage(std::string arg1)
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
std::string tex_table_caption
const std::string & get_cached_string() const
#define DeclException1(Exception1, type1, outsequence)
#define Assert(cond, exc)
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
::ExceptionBase & ExcInternalError()
std::map< std::string, std::vector< std::string > > supercolumns
std::string tex_table_label