test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
DDHtmlFormatter.h
Go to the documentation of this file.
1 #ifndef DDHtmlFormatter_h
2 #define DDHtmlFormatter_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 {
19 public:
20 
21  typedef std::map<std::string,std::set<std::string> > ns_type;
22 
23  explicit DDHtmlFormatter() { }
24  DDHtmlFormatter(const DDHtmlFormatter & f) : os_(f.os_.str()) { }
25 
26  DDHtmlFormatter header(const std::string & text, const std::string & style="../../style.css");
28 
29  DDHtmlFormatter br() { pre(); os_ << "<br>" << std::endl; return *this; }
30  DDHtmlFormatter p(const std::string & content) { pre(); os_ << "<p>" << std::endl << content << std::endl << "</p>" << std::endl; return *this; }
31 
32  DDHtmlFormatter ul() { pre(); os_ << "<ul>" << std::endl; return *this;}
33  DDHtmlFormatter li(const std::string & content) { pre(); os_ << "<li>" << content << "</li>" << std::endl; return *this;}
34  DDHtmlFormatter ulEnd() { pre(); os_ << "</ul>" << std::endl; return *this;}
35 
36  DDHtmlFormatter h1(const std::string & content) { pre(); os_ << "<h1>" << content << "</h1>" << std::endl; return *this;}
37  DDHtmlFormatter h2(const std::string & content) { pre(); os_ << "<h2>" << content << "</h2>" << std::endl; return *this;}
38  DDHtmlFormatter h3(const std::string & content) { pre(); os_ << "<h3>" << content << "</h3>" << std::endl; return *this;}
39 
40  DDHtmlFormatter link(const std::string & url, const std::string & text, const std::string & target="_self");
41  std::string lnk(const std::string & url, const std::string & text, const std::string & target="_self");
42 
43  DDHtmlFormatter table(int border=0){ pre(); os_ << "<table border=\"" << border << "\">" << std::endl; return *this;}
44  DDHtmlFormatter tableEnd() { pre(); os_ << "</table>" << std::endl; return *this;}
45  DDHtmlFormatter tr() { pre(); os_ << " <tr>" << std::endl; return *this;}
46  DDHtmlFormatter trEnd() { pre(); os_ << " </tr>" << std::endl; return *this;}
47  DDHtmlFormatter td(const std::string & content) { pre(); os_ << " <td>" << content << std::endl << " </td>" << std::endl; return *this;}
48 
49  DDHtmlFormatter color(int red, int green, int blue){return *this;};
50 
51  void pre() { os_.str(""); }
52 
53  // std::string operator<<(std::string o) { o << os_; }
54  mutable std::stringstream os_;
55 
56 private:
57 
59 };
60 
61 
62 
63 
64 
65 
70 {
71 
72 public:
73  DDNsGenerator(std::ostream & os,
74  const std::string & title,
75  const std::string & target,
76  const ns_type & n,
77  const std::string & text="")
78  : os_(os), title_(title), text_(text), target_(target), n_(n){ }
79 
80  void doit();
81 
82 private:
83 
84  std::ostream & os_;
86  const ns_type & n_;
87 };
88 
90 {
91 public:
92  DDFrameGenerator(std::ostream & os,
93  const std::string & title,
94  const std::string & n1 = "_ns", //frame names
95  const std::string & n2 = "_list",
96  const std::string & n3 = "_details",
97  const std::string & u1 = "ns.html", //url to be displayed in each frame
98  const std::string & u2 = "list.html",
99  const std::string & u3 = "details.html")
100  : t_(title), n1_(n1), n2_(n2), n3_(n3), u1_(u1), u2_(u2), u3_(u3), os_(os) { }
101 
102  void doit();
103 
104 private:
106  std::ostream & os_;
107 };
108 
109 // =============================================================================================================
110 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
111 
113 {
114 public:
115  DDHtmlDetails(const std::string & cat, const std::string & txt);
116  virtual bool details(std::ostream & os, const DDName &) = 0;
117  virtual ns_type & names() = 0;
118  virtual ~DDHtmlDetails(){};
119  const std::string & category() { return cat_; }
120  const std::string & text() {return txt_; }
121 protected:
122  mutable ns_type names_;
125 };
126 
127 
129 {
130 public:
131  DDHtmlLpDetails(const std::string & cat, const std::string & txt) : DDHtmlDetails(cat,txt) {}
132  bool details(std::ostream & os, const DDName &);
133  ns_type & names();
134 
135 };
136 
138 {
139 public:
140  DDHtmlMaDetails(const std::string & cat, const std::string & txt) : DDHtmlDetails(cat,txt) {}
141  bool details(std::ostream & os, const DDName &);
142  ns_type & names();
143 
144 };
145 
147 {
148 public:
149  DDHtmlSoDetails(const std::string & cat, const std::string & txt) : DDHtmlDetails(cat,txt) {}
150  bool details(std::ostream & os, const DDName &);
151  ns_type & names();
152 
153 };
154 
156 {
157 public:
158  DDHtmlRoDetails(const std::string & cat, const std::string & txt) : DDHtmlDetails(cat,txt) {}
159  bool details(std::ostream & os, const DDName &);
160  ns_type & names();
161 
162 };
163 
165 {
166 public:
167  DDHtmlSpDetails(const std::string & cat, const std::string & txt) : DDHtmlDetails(cat,txt) {}
168  bool details(std::ostream & os, const DDName &);
169  ns_type & names();
170 
171 };
172 
173 
174 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
175 // =============================================================================================================
176 
177 void dd_to_html(DDHtmlDetails & det);
178 
179 void dd_html_frameset(std::ostream & os);
180 
181 void dd_html_menu_frameset(std::ostream & os);
182 
183 void dd_html_menu(std::ostream & os);
184 
185 void dd_html_ro();
186 
187 
188 
189 #endif
bool details(std::ostream &os, const DDName &)
std::string cat_
void dd_html_frameset(std::ostream &os)
DDHtmlFormatter li(const std::string &content)
DDHtmlSpDetails(const std::string &cat, const std::string &txt)
bool details(std::ostream &os, const DDName &)
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)
std::ostream & os_
DDName is used to identify DDD entities uniquely.
Definition: DDName.h:14
DDHtmlRoDetails(const std::string &cat, const std::string &txt)
std::string title_
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
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)
bool details(std::ostream &os, const DDName &)
DDHtmlFormatter h1(const std::string &content)
DDHtmlFormatter td(const std::string &content)
DDHtmlFormatter color(int red, int green, int blue)
DDHtmlFormatter f_
DDHtmlFormatter p(const std::string &content)
void dd_html_ro()
void dd_html_menu(std::ostream &os)
def cat
Definition: eostools.py:400
DDHtmlFormatter h2(const std::string &content)
std::ostream & os_
double f[11][100]
tuple text
Definition: runonSM.py:42
bool details(std::ostream &os, const DDName &)
DDNsGenerator(std::ostream &os, const std::string &title, const std::string &target, const ns_type &n, const std::string &text="")
virtual ns_type & names()=0
DDHtmlFormatter ulEnd()
DDHtmlFormatter table(int border=0)
void dd_to_html(DDHtmlDetails &det)
ns_type & names()
std::map< std::string, std::set< std::string > > ns_type
const ns_type & n_
DDHtmlFormatter tableEnd()
std::string txt_
DDHtmlFormatter & operator=(const DDHtmlFormatter &)
DDHtmlDetails(const std::string &cat, const std::string &txt)
void dd_html_menu_frameset(std::ostream &os)
std::string target_
const std::string & text()
DDHtmlFormatter tr()
DDHtmlFormatter(const DDHtmlFormatter &f)
DDHtmlFormatter header(const std::string &text, const std::string &style="../../style.css")
const std::string & category()
bool details(std::ostream &os, const DDName &)
ns_type & names()
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()
DDHtmlFormatter link(const std::string &url, const std::string &text, const std::string &target="_self")
DDHtmlFormatter footer()
std::map< std::string, std::set< std::string > > ns_type