From d3e5268f25e338e25b039fb8fc5c754676cf2225 Mon Sep 17 00:00:00 2001 From: heister Date: Mon, 10 Sep 2012 14:25:52 +0000 Subject: [PATCH] new TextOutputFormat::simple_table_with_separate_column_description git-svn-id: https://svn.dealii.org/trunk@26266 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/doc/news/changes.h | 5 ++ deal.II/include/deal.II/base/table_handler.h | 17 +++++- deal.II/source/base/table_handler.cc | 55 +++++++++++++++++++- 3 files changed, 74 insertions(+), 3 deletions(-) diff --git a/deal.II/doc/news/changes.h b/deal.II/doc/news/changes.h index 48e7670d5c..649e991a96 100644 --- a/deal.II/doc/news/changes.h +++ b/deal.II/doc/news/changes.h @@ -50,6 +50,11 @@ never working correctly and it is not used.

Specific improvements

    +
  1. New: TableHandler TextOutputFormat::simple_table_with_separate_column_description +that skips aligning the columns for increased performance. +
    +(Timo Heister, 2012/09/10) +
  2. Fixed: The Clang C++ compiler had some trouble dealing with obtaining the return value of a Threads::Task object, due to a compiler bug in dealing with friend declarations. This is now fixed. diff --git a/deal.II/include/deal.II/base/table_handler.h b/deal.II/include/deal.II/base/table_handler.h index 034bd82542..8200af5b22 100644 --- a/deal.II/include/deal.II/base/table_handler.h +++ b/deal.II/include/deal.II/base/table_handler.h @@ -280,11 +280,26 @@ class TableHandler * 2 13 a * 1 0 "" * @endcode + * - simple_table_with_separate_column_description: This format + * is very similar to table_with_separate_column_description, + * but it skips aligning the columns with additional white space. This + * increases the performance o fwrite_text() for large tables. Example output: + * @code + * # 1: key1 + * # 2: key2 + * # 3: key3 + * 0 0 "" + * 1 0 "" + * 2 13 a + * 1 0 "" + * @endcode + * **/ enum TextOutputFormat { table_with_headers, - table_with_separate_column_description + table_with_separate_column_description, + simple_table_with_separate_column_description, }; /** diff --git a/deal.II/source/base/table_handler.cc b/deal.II/source/base/table_handler.cc index 6a98b15fa3..ee91075742 100644 --- a/deal.II/source/base/table_handler.cc +++ b/deal.II/source/base/table_handler.cc @@ -290,9 +290,60 @@ void TableHandler::write_text(std::ostream &out, const unsigned int nrows = n_rows(); const unsigned int n_cols = sel_columns.size(); + // handle the simple format separately first + if (format==simple_table_with_separate_column_description) + { + // write the captions + for (unsigned int j=0; j cols; + for (unsigned int j=0; j::const_iterator + col_iter=columns.find(key); + Assert(col_iter!=columns.end(), ExcInternalError()); + cols.push_back(&(col_iter->second)); + } + + // write the body + for (unsigned int i=0; i(&(column.entries[i].value)); + if (val!=NULL && val->length()==0) + out << "\"\""; + else + out << column.entries[i].value; + + out << ' '; + } + out << '\n'; + } + + out << std::flush; + return; + } + // first compute the widths of each // entry of the table, in order to - // have a nicer alignement + // have a nicer alignment Table<2,unsigned int> entry_widths (nrows, n_cols); for (unsigned int i=0; i