* [Powertop] [PATCH v2 03/31] html-report: add title and div tags
@ 2013-11-16 0:28 Alexandra Yates
0 siblings, 0 replies; 2+ messages in thread
From: Alexandra Yates @ 2013-11-16 0:28 UTC (permalink / raw)
To: powertop
[-- Attachment #1: Type: text/plain, Size: 2817 bytes --]
Implements add_title and add_div methods that pass css attributes for
modular styling.
Signed-off-by: Alexandra Yates <alexandra.yates(a)linux.intel.com>
---
src/report/report-data-html.h | 4 ++++
src/report/report-formatter-html.cpp | 33 +++++++++++++++++++++++++++++++++
src/report/report-formatter-html.h | 5 ++++-
3 files changed, 41 insertions(+), 1 deletion(-)
create mode 100644 src/report/report-data-html.h
diff --git a/src/report/report-data-html.h b/src/report/report-data-html.h
new file mode 100644
index 0000000..70ccbdb
--- /dev/null
+++ b/src/report/report-data-html.h
@@ -0,0 +1,4 @@
+struct tag_attr {
+ const char *css_class;
+ const char *css_id;
+};
diff --git a/src/report/report-formatter-html.cpp b/src/report/report-formatter-html.cpp
index 79a0c35..db21c8c 100644
--- a/src/report/report-formatter-html.cpp
+++ b/src/report/report-formatter-html.cpp
@@ -464,6 +464,8 @@ report_formatter_html::set_cpu_number(int nr)
cpu_nr = nr;
}
+
+/* Report Style */
void
report_formatter_html::add_logo()
{
@@ -481,3 +483,34 @@ report_formatter_html::end_hheader()
{
add_exact("</header>\n\n");
}
+void
+report_formatter_html::add_div(struct tag_attr * div_attr)
+{
+ std::string empty="";
+ std::string tmp_str;
+
+ if (div_attr->css_class == empty && div_attr->css_id == empty)
+ add_exact("<div>\n");
+
+ else if (div_attr->css_class == empty && div_attr->css_id != empty)
+ addf_exact("<div id=\"%s\">\n", div_attr->css_id);
+
+ else if (div_attr->css_class != empty && div_attr->css_id == empty)
+ addf_exact("<div class=\"%s\">\n", div_attr->css_class);
+
+ else if (div_attr->css_class != empty && div_attr->css_id != empty)
+ addf_exact("<div class=\"%s\" id=\"%s\">\n", div_attr->css_class, div_attr->css_id);
+}
+
+void
+report_formatter_html::end_div()
+{
+ add_exact("</div>\n");
+}
+
+void
+report_formatter_html::add_title(struct tag_attr *title_att, const char *title)
+{
+ addf_exact("<h2 class=\"%s\"> %s </h2>\n", title_att->css_class, title);
+}
+
diff --git a/src/report/report-formatter-html.h b/src/report/report-formatter-html.h
index 1ade760..0f508d3 100644
--- a/src/report/report-formatter-html.h
+++ b/src/report/report-formatter-html.h
@@ -29,7 +29,7 @@
#include <string>
#include "report-formatter-base.h"
-
+#include "report-data-html.h"
/* Whether to replace " and ' in HTML by " and ' respectively */
/*#define REPORT_HTML_ESCAPE_QUOTES*/
@@ -86,6 +86,9 @@ public:
void add_logo();
void add_header();
void end_hheader();
+ void add_div(struct tag_attr *div_attr);
+ void end_div();
+ void add_title(struct tag_attr *title_att, const char *title);
private:
/* Document structure related functions */
--
1.7.9.5
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [Powertop] [PATCH v2 03/31] html-report: add title and div tags
@ 2013-11-18 7:36 Igor Zhbanov
0 siblings, 0 replies; 2+ messages in thread
From: Igor Zhbanov @ 2013-11-18 7:36 UTC (permalink / raw)
To: powertop
[-- Attachment #1: Type: text/plain, Size: 1088 bytes --]
Hi Alexandra,
Alexandra Yates wrote:
...
> +void
> +report_formatter_html::add_div(struct tag_attr * div_attr)
> +{
> + std::string empty="";
> + std::string tmp_str;
> +
> + if (div_attr->css_class == empty && div_attr->css_id == empty)
> + add_exact("<div>\n");
> +
> + else if (div_attr->css_class == empty && div_attr->css_id != empty)
> + addf_exact("<div id=\"%s\">\n", div_attr->css_id);
> +
> + else if (div_attr->css_class != empty && div_attr->css_id == empty)
> + addf_exact("<div class=\"%s\">\n", div_attr->css_class);
> +
> + else if (div_attr->css_class != empty && div_attr->css_id != empty)
> + addf_exact("<div class=\"%s\" id=\"%s\">\n", div_attr->css_class, div_attr->css_id);
Please use indentation like:
if (something)
do_something();
else if (other)
do_something else();
--
Best regards,
Igor Zhbanov,
Expert Software Engineer,
phone: +7 (495) 797 25 00 ext 3981
e-mail: i.zhbanov(a)samsung.com
Mobile group, Moscow R&D center, Samsung Electronics
12 Dvintsev street, building 1
127018, Moscow, Russian Federation
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2013-11-18 7:36 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-11-18 7:36 [Powertop] [PATCH v2 03/31] html-report: add title and div tags Igor Zhbanov
-- strict thread matches above, loose matches on Subject: below --
2013-11-16 0:28 Alexandra Yates
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.