Generates a modular table to the csv report using the table_size and a
set of data stored in a single dimensional array stored in row major
order.
Signed-off-by: Alexandra Yates <alexandra.yates(a)linux.intel.com>
---
src/report/report-formatter-csv.cpp | 28 ++++++++++++++++++++++++++++
src/report/report-formatter-csv.h | 2 ++
2 files changed, 30 insertions(+)
diff --git a/src/report/report-formatter-csv.cpp b/src/report/report-formatter-csv.cpp
index 2981940..b9336ad 100644
--- a/src/report/report-formatter-csv.cpp
+++ b/src/report/report-formatter-csv.cpp
@@ -33,6 +33,7 @@
#include <stdarg.h>
#include "report-formatter-csv.h"
+#include "report-data-html.h"
static const char report_csv_header[] = "PowerTOP Report";
@@ -279,3 +280,30 @@ report_formatter_csv::add_summary_list(string *list, int size)
add_exact("\n");
}
+void
+report_formatter_csv::add_table(string *system_data, struct table_size *size,
+ struct table_attributes* tb_attr)
+{
+ int i, j;
+ int offset=0;
+ string tmp_str="";
+ int empty_row=0;
+ add_exact("\n");
+ for (i=0; i < size->rows; i++){
+ for (j=0; j < size->cols; j++){
+ offset = i * (size->cols) + j;
+ tmp_str=system_data[offset];
+
+ if(tmp_str == " ")
+ empty_row+=1;
+ else{
+ addf_exact("%s", system_data[offset].c_str());
+ if(j < (size->cols - 1))
+ add_exact(",");
+ }
+ }
+ if(empty_row < size->cols)
+ add_exact("\n");
+ empty_row=0;
+ }
+}
diff --git a/src/report/report-formatter-csv.h b/src/report/report-formatter-csv.h
index daf723e..994b765 100644
--- a/src/report/report-formatter-csv.h
+++ b/src/report/report-formatter-csv.h
@@ -82,6 +82,8 @@ public:
void add_title(struct tag_attr *title_att, const char *title);
void add_navigation();
void add_summary_list(string *list, int size);
+ void add_table(string *system_data, struct table_size *size,
+ struct table_attributes *tb_attr);
private:
void add_doc_header();
--
1.7.9.5