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 
5 #include <iostream>
6 #include <string>
7 #include <sstream>
8 #include <map>
9 #include <set>
10 #include <vector>
11 
13 
14 
15 class DDHtmlFormatter;
16 
17 std::ostream & operator<<(std::ostream & o, const DDHtmlFormatter & f);
18 
20 {
21 public:
22 
23  typedef std::map<std::string,std::set<std::string> > ns_type;
24 
25  explicit DDHtmlFormatter() { }
26  DDHtmlFormatter(const DDHtmlFormatter & f) : os_(f.os_.str()) { }
27 
28  DDHtmlFormatter header(const std::string & text, const std::string & style="../../style.css");
30 
31  DDHtmlFormatter br() { pre(); os_ << "<br>" << std::endl; return *this; }
32  DDHtmlFormatter p(const std::string & content) { pre(); os_ << "<p>" << std::endl << content << std::endl << "</p>" << std::endl; return *this; }
33 
34  DDHtmlFormatter ul() { pre(); os_ << "<ul>" << std::endl; return *this;}
35  DDHtmlFormatter li(const std::string & content) { pre(); os_ << "<li>" << content << "</li>" << std::endl; return *this;}
36  DDHtmlFormatter ulEnd() { pre(); os_ << "</ul>" << std::endl; return *this;}
37 
38  DDHtmlFormatter h1(const std::string & content) { pre(); os_ << "<h1>" << content << "</h1>" << std::endl; return *this;}
39  DDHtmlFormatter h2(const std::string & content) { pre(); os_ << "<h2>" << content << "</h2>" << std::endl; return *this;}
40  DDHtmlFormatter h3(const std::string & content) { pre(); os_ << "<h3>" << content << "</h3>" << std::endl; return *this;}
41 
42  DDHtmlFormatter link(const std::string & url, const std::string & text, const std::string & target="_self");
43  std::string lnk(const std::string & url, const std::string & text, const std::string & target="_self");
44 
45  DDHtmlFormatter table(int border=0){ pre(); os_ << "<table border=\"" << border << "\">" << std::endl; return *this;}
46  DDHtmlFormatter tableEnd() { pre(); os_ << "</table>" << std::endl; return *this;}
47  DDHtmlFormatter tr() { pre(); os_ << " <tr>" << std::endl; return *this;}
48  DDHtmlFormatter trEnd() { pre(); os_ << " </tr>" << std::endl; return *this;}
49  DDHtmlFormatter td(const std::string & content) { pre(); os_ << " <td>" << content << std::endl << " </td>" << std::endl; return *this;}
50 
51  DDHtmlFormatter color(int red, int green, int blue){return *this;};
52 
53  void pre() { os_.str(""); }
54 
55 // std::string operator<<(std::string o) { o << os_; }
56  mutable std::stringstream os_;
57 
58 };
59 
60 
61 
62 
63 
64 
69 {
70 
71 public:
72  DDNsGenerator(std::ostream & os,
73  const std::string & title,
74  const std::string & target,
75  const ns_type & n,
76  const std::string & text="")
77  : os_(os), title_(title), text_(text), target_(target), n_(n){ }
78 
79  void doit();
80 
81 private:
82 
83  std::ostream & os_;
84  std::string title_, text_, target_;
85  const ns_type & n_;
86 };
87 
89 {
90 public:
91  DDFrameGenerator(std::ostream & os,
92  const std::string & title,
93  const std::string & n1 = "_ns", //frame names
94  const std::string & n2 = "_list",
95  const std::string & n3 = "_details",
96  const std::string & u1 = "ns.html", //url to be displayed in each frame
97  const std::string & u2 = "list.html",
98  const std::string & u3 = "details.html")
99  : t_(title), n1_(n1), n2_(n2), n3_(n3), u1_(u1), u2_(u2), u3_(u3), os_(os) { }
100 
101  void doit();
102 
103 private:
104  std::string t_, n1_, n2_, n3_, u1_, u2_, u3_;
105  std::ostream & os_;
106 };
107 
108 // =============================================================================================================
109 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
110 
112 {
113 public:
114  DDHtmlDetails(const std::string & cat, const std::string & txt);
115  virtual bool details(std::ostream & os, const DDName &) = 0;
116  virtual ns_type & names() = 0;
117  virtual ~DDHtmlDetails(){};
118  const std::string & category() { return cat_; }
119  const std::string & text() {return txt_; }
120 protected:
121  mutable ns_type names_;
122  std::string cat_, txt_;
124 };
125 
126 
128 {
129 public:
130  DDHtmlLpDetails(const std::string & cat, const std::string & txt) : DDHtmlDetails(cat,txt) {}
131  bool details(std::ostream & os, const DDName &);
132  ns_type & names();
133 
134 };
135 
137 {
138 public:
139  DDHtmlMaDetails(const std::string & cat, const std::string & txt) : DDHtmlDetails(cat,txt) {}
140  bool details(std::ostream & os, const DDName &);
141  ns_type & names();
142 
143 };
144 
146 {
147 public:
148  DDHtmlSoDetails(const std::string & cat, const std::string & txt) : DDHtmlDetails(cat,txt) {}
149  bool details(std::ostream & os, const DDName &);
150  ns_type & names();
151 
152 };
153 
155 {
156 public:
157  DDHtmlRoDetails(const std::string & cat, const std::string & txt) : DDHtmlDetails(cat,txt) {}
158  bool details(std::ostream & os, const DDName &);
159  ns_type & names();
160 
161 };
162 
164 {
165 public:
166  DDHtmlSpDetails(const std::string & cat, const std::string & txt) : DDHtmlDetails(cat,txt) {}
167  bool details(std::ostream & os, const DDName &);
168  ns_type & names();
169 
170 };
171 
172 
173 // +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
174 // =============================================================================================================
175 
176 void dd_to_html(DDHtmlDetails & det);
177 
178 void dd_html_frameset(std::ostream & os);
179 
180 void dd_html_menu_frameset(std::ostream & os);
181 
182 void dd_html_menu(std::ostream & os);
183 
184 void dd_html_ro();
185 
186 
187 
188 #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:18
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)
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_
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