CMS 3D CMS Logo

DDHtmlFormatter.h
Go to the documentation of this file.
1 #ifndef DETECTOR_DESCRIPTION_REGRESSION_TEST_DD_HTML_FORMATTER_H
2 #define DETECTOR_DESCRIPTION_REGRESSION_TEST_DD_HTML_FORMATTER_H
3 
4 #include <iostream>
5 #include <string>
6 #include <sstream>
7 #include <map>
8 #include <set>
9 #include <vector>
10 
12 
13 class DDHtmlFormatter;
14 
15 std::ostream &operator<<(std::ostream &o, const DDHtmlFormatter &f);
16 
18 public:
19  typedef std::map<std::string, std::set<std::string> > ns_type;
20 
21  explicit DDHtmlFormatter() {}
23 
24  DDHtmlFormatter header(const std::string &text, const std::string &style = "../../style.css");
26 
28  pre();
29  os_ << "<br>" << std::endl;
30  return *this;
31  }
33  pre();
34  os_ << "<p>" << std::endl << content << std::endl << "</p>" << std::endl;
35  return *this;
36  }
37 
39  pre();
40  os_ << "<ul>" << std::endl;
41  return *this;
42  }
44  pre();
45  os_ << "<li>" << content << "</li>" << std::endl;
46  return *this;
47  }
49  pre();
50  os_ << "</ul>" << std::endl;
51  return *this;
52  }
53 
55  pre();
56  os_ << "<h1>" << content << "</h1>" << std::endl;
57  return *this;
58  }
60  pre();
61  os_ << "<h2>" << content << "</h2>" << std::endl;
62  return *this;
63  }
65  pre();
66  os_ << "<h3>" << content << "</h3>" << std::endl;
67  return *this;
68  }
69 
70  DDHtmlFormatter link(const std::string &url, const std::string &text, const std::string &target = "_self");
71  std::string lnk(const std::string &url, const std::string &text, const std::string &target = "_self");
72 
73  DDHtmlFormatter table(int border = 0) {
74  pre();
75  os_ << "<table border=\"" << border << "\">" << std::endl;
76  return *this;
77  }
79  pre();
80  os_ << "</table>" << std::endl;
81  return *this;
82  }
84  pre();
85  os_ << " <tr>" << std::endl;
86  return *this;
87  }
89  pre();
90  os_ << " </tr>" << std::endl;
91  return *this;
92  }
94  pre();
95  os_ << " <td>" << content << std::endl << " </td>" << std::endl;
96  return *this;
97  }
98 
99  DDHtmlFormatter color(int red, int green, int blue) { return *this; };
100 
101  void pre() { os_.str(""); }
102 
103  // std::string operator<<(std::string o) { o << os_; }
104  mutable std::stringstream os_;
105 
106  DDHtmlFormatter &operator=(const DDHtmlFormatter &) = delete;
107 };
108 
113 public:
114  DDNsGenerator(std::ostream &os,
115  const std::string &title,
116  const std::string &target,
117  const ns_type &n,
118  const std::string &text = "")
119  : os_(os), title_(title), text_(text), target_(target), n_(n) {}
120 
121  void doit();
122 
123 private:
124  std::ostream &os_;
126  const ns_type &n_;
127 };
128 
130 public:
131  DDFrameGenerator(std::ostream &os,
132  const std::string &title,
133  const std::string &n1 = "_ns", //frame names
134  const std::string &n2 = "_list",
135  const std::string &n3 = "_details",
136  const std::string &u1 = "ns.html", //url to be displayed in each frame
137  const std::string &u2 = "list.html",
138  const std::string &u3 = "details.html")
139  : t_(title), n1_(n1), n2_(n2), n3_(n3), u1_(u1), u2_(u2), u3_(u3), os_(os) {}
140 
141  void doit();
142 
143 private:
145  std::ostream &os_;
146 };
147 
149 public:
150  DDHtmlDetails(const std::string &cat, const std::string &txt);
151  virtual bool details(std::ostream &os, const DDName &) = 0;
152  virtual ns_type &names() = 0;
153  virtual ~DDHtmlDetails(){};
154  const std::string &category() { return cat_; }
155  const std::string &text() { return txt_; }
156 
157 protected:
158  mutable ns_type names_;
161 };
162 
164 public:
166  bool details(std::ostream &os, const DDName &) override;
167  ns_type &names() override;
168 };
169 
171 public:
173  bool details(std::ostream &os, const DDName &) override;
174  ns_type &names() override;
175 };
176 
178 public:
180  bool details(std::ostream &os, const DDName &) override;
181  ns_type &names() override;
182 };
183 
185 public:
187  bool details(std::ostream &os, const DDName &) override;
188  ns_type &names() override;
189 };
190 
192 public:
194  bool details(std::ostream &os, const DDName &) override;
195  ns_type &names() override;
196 };
197 
198 void dd_to_html(DDHtmlDetails &det);
199 
200 void dd_html_frameset(std::ostream &os);
201 
202 void dd_html_menu_frameset(std::ostream &os);
203 
204 void dd_html_menu(std::ostream &os);
205 
206 void dd_html_ro();
207 
208 #endif
bool details(std::ostream &os, const DDName &) override
std::string cat_
void dd_html_frameset(std::ostream &os)
DDHtmlFormatter li(const std::string &content)
ns_type & names() override
DDHtmlSpDetails(const std::string &cat, const std::string &txt)
bool details(std::ostream &os, const DDName &) override
DDHtmlSoDetails(const std::string &cat, const std::string &txt)
virtual bool details(std::ostream &os, const DDName &)=0
DDHtmlFormatter br()
DDHtmlFormatter h3(const std::string &content)
bool details(std::ostream &os, const DDName &) override
std::ostream & os_
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:17
DDHtmlRoDetails(const std::string &cat, const std::string &txt)
std::string title_
DDHtmlFormatter & operator=(const DDHtmlFormatter &)=delete
bool details(std::ostream &os, const DDName &) override
DDFrameGenerator(std::ostream &os, const std::string &title, const std::string &n1="_ns", const std::string &n2="_list", const std::string &n3="_details", const std::string &u1="ns.html", const std::string &u2="list.html", const std::string &u3="details.html")
virtual ~DDHtmlDetails()
DDHtmlMaDetails(const std::string &cat, const std::string &txt)
DDHtmlFormatter h1(const std::string &content)
DDHtmlFormatter td(const std::string &content)
DDHtmlFormatter color(int red, int green, int blue)
DDHtmlFormatter f_
def cat(path)
Definition: eostools.py:401
DDHtmlFormatter p(const std::string &content)
void dd_html_ro()
void dd_html_menu(std::ostream &os)
Definition: style.py:1
DDHtmlFormatter h2(const std::string &content)
std::map< std::string, std::set< std::string > > ns_type
std::ostream & os_
double f[11][100]
DDNsGenerator(std::ostream &os, const std::string &title, const std::string &target, const ns_type &n, const std::string &text="")
bool details(std::ostream &os, const DDName &) override
virtual ns_type & names()=0
DDHtmlFormatter ulEnd()
DDHtmlFormatter table(int border=0)
void dd_to_html(DDHtmlDetails &det)
ns_type & names() override
const ns_type & n_
DDHtmlFormatter tableEnd()
std::string txt_
DDHtmlDetails(const std::string &cat, const std::string &txt)
void dd_html_menu_frameset(std::ostream &os)
std::map< std::string, std::set< std::string > > ns_type
std::string target_
ns_type & names() override
const std::string & text()
std::ostream & operator<<(std::ostream &o, const DDHtmlFormatter &f)
DDHtmlFormatter tr()
DDHtmlFormatter(const DDHtmlFormatter &f)
DDHtmlFormatter header(const std::string &text, const std::string &style="../../style.css")
const std::string & category()
DDHtmlLpDetails(const std::string &cat, const std::string &txt)
std::string lnk(const std::string &url, const std::string &text, const std::string &target="_self")
DDHtmlFormatter trEnd()
std::string text_
std::stringstream os_
DDHtmlFormatter ul()
ns_type & names() override
#define str(s)
DDHtmlFormatter link(const std::string &url, const std::string &text, const std::string &target="_self")
DDHtmlFormatter footer()
ns_type & names() override