sorted_table.h
1 // Copyright 2018, Beeri 15. All rights reserved.
2 // Author: Roman Gershman (romange@gmail.com)
3 //
4 #include <vector>
5 #include "strings/stringpiece.h"
6 
7 namespace util {
8 namespace html {
9 
10 class SortedTable {
11  public:
12  static std::string HtmlStart();
13 
14  static void StartTable(const std::vector<StringPiece>& header, std::string* dest);
15 
16  static void Row(const std::vector<StringPiece>& row, std::string* dest);
17 
18  static void EndTable(std::string* dest);
19 };
20 
21 /*
22 std::string SortedTable::Start(const Container& header) {
23  std::string res(
24  absl::StrCat("<table id='", name, "' class='tablesorter' cellspacing='1'> \n<thead>"));
25  for (auto v : header) {
26  res.append(absl::StrCat("<th>", v, "</th>"));
27  }
28  res.append("</thead>\n <tbody> \n");
29  return res;
30 }
31 
32 template <class Container>
33 std::string SortedTable::Row(StringPiece style, const Container& row) {
34  std::string res("<tr>");
35  std::string td_tag;
36  if (style.empty()) {
37  td_tag = "<td>";
38  } else {
39  td_tag = absl::StrCat("<td style='", style, "'>");
40  }
41  for (const auto& cell : row) {
42  absl::StrAppend(&res, td_tag, cell, "</td>");
43  }
44  res.append("</tr>\n");
45  return res;
46 }
47 */
48 
49 } // namespace html
50 } // namespace util