HtmlBuilder.h
Go to the documentation of this file.
1 /* -*- C++ -*- */
2 
3 /****************************************************************************
4 ** Copyright (c) 2001-2014
5 **
6 ** This file is part of the QuickFIX FIX Engine
7 **
8 ** This file may be distributed under the terms of the quickfixengine.org
9 ** license as defined by quickfixengine.org and appearing in the file
10 ** LICENSE included in the packaging of this file.
11 **
12 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
13 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
14 **
15 ** See http://www.quickfixengine.org/LICENSE for licensing information.
16 **
17 ** Contact ask@quickfixengine.org if any conditions of this licensing are
18 ** not clear to you.
19 **
20 ****************************************************************************/
21 
22 #ifndef HTML_BUILDER_H
23 #define HTML_BUILDER_H
24 
25 #ifdef _MSC_VER
26 #pragma warning( disable : 4503 4355 4786 4290 )
27 #endif
28 
29 #include <sstream>
30 
31 namespace HTML
32 {
33 class TAG
34 {
35 public:
36  TAG( const std::string& tag, std::ostream& stream )
37  : m_tag( tag ), m_stream( stream )
38  {
39  m_stream << "<" << m_tag;
40  }
41 
42  virtual ~TAG()
43  {
44  m_stream << m_value.str();
45  m_stream << "</" << m_tag << ">";
46  }
47 
48  TAG& text()
49  { m_stream << ">"; return *this; }
50  TAG& text( const std::string& value )
51  { m_value << value; text(); return *this; }
52  TAG& text( int value )
53  { m_value << value; text(); return *this; }
54 
55  private:
56  std::string m_tag;
57  std::stringstream m_value;
58 
59  protected:
60  std::ostream& m_stream;
61 };
62 
63 class SPECIAL
64 {
65  public:
66  SPECIAL( const std::string& value, std::ostream& stream )
67  {
68  stream << "&" << value << ";";
69  }
70 };
71 
72 class A : public TAG
73 {
74 public:
75  A( std::ostream& stream )
76  : TAG( "A", stream ) {}
77 
78  A& href( const std::string& value )
79  { m_stream << " href='" << value << "'"; return *this; }
80 };
81 
82 class BODY : public TAG
83 {
84 public:
85  BODY( std::ostream& stream )
86  : TAG( "BODY", stream ) {}
87 };
88 
89 class BR : public TAG
90 {
91 public:
92  BR( std::ostream& stream )
93  : TAG( "BR", stream ) {}
94 };
95 
96 class CAPTION : public TAG
97 {
98 public:
99  CAPTION( std::ostream& stream )
100  : TAG( "CAPTION", stream ) {}
101 };
102 
103 class CENTER : public TAG
104 {
105 public:
106  CENTER( std::ostream& stream )
107  : TAG( "CENTER", stream ) {}
108 };
109 
110 class EM : public TAG
111 {
112 public:
113  EM( std::ostream& stream )
114  : TAG( "EM", stream ) {}
115 };
116 
117 class H1 : public TAG
118 {
119 public:
120  H1( std::ostream& stream )
121  : TAG( "H1", stream ) {}
122 };
123 
124 class H2 : public TAG
125 {
126 public:
127  H2( std::ostream& stream )
128  : TAG( "H2", stream ) {}
129 };
130 
131 class HEAD : public TAG
132 {
133 public:
134  HEAD( std::ostream& stream )
135  : TAG( "HEAD", stream ) {}
136 };
137 
138 class HR : public TAG
139 {
140 public:
141  HR( std::ostream& stream )
142  : TAG( "HR", stream ) {}
143 };
144 
145 const char* NBSP = "&nbsp;";
146 
147 class TABLE : public TAG
148 {
149 public:
150  TABLE( std::ostream& stream )
151  : TAG( "TABLE", stream ) {}
152 
153  TABLE& border( int value )
154  { m_stream << " border='" << value << "'"; return *this; }
155  TABLE& cellspacing( int value )
156  { m_stream << " cellspacing='" << value << "'"; return *this; }
157  TABLE& width( int value )
158  { m_stream << " width='" << value << "%'"; return *this; }
159 };
160 
161 class TD : public TAG
162 {
163 public:
164  TD( std::ostream& stream )
165  : TAG( "TD", stream ) {}
166 
167  TD& align( const std::string& value )
168  { m_stream << " align='" << value << "'"; return *this; }
169 };
170 
171 class TITLE : public TAG
172 {
173 public:
174  TITLE( std::ostream& stream )
175  : TAG( "TITLE", stream ) {}
176 };
177 
178 class TR : public TAG
179 {
180 public:
181  TR( std::ostream& stream )
182  : TAG( "TR", stream ) {}
183 };
184 }
185 
186 #endif
A & href(const std::string &value)
Definition: HtmlBuilder.h:78
A(std::ostream &stream)
Definition: HtmlBuilder.h:75
BODY(std::ostream &stream)
Definition: HtmlBuilder.h:85
BR(std::ostream &stream)
Definition: HtmlBuilder.h:92
CAPTION(std::ostream &stream)
Definition: HtmlBuilder.h:99
CENTER(std::ostream &stream)
Definition: HtmlBuilder.h:106
EM(std::ostream &stream)
Definition: HtmlBuilder.h:113
H1(std::ostream &stream)
Definition: HtmlBuilder.h:120
H2(std::ostream &stream)
Definition: HtmlBuilder.h:127
HEAD(std::ostream &stream)
Definition: HtmlBuilder.h:134
HR(std::ostream &stream)
Definition: HtmlBuilder.h:141
SPECIAL(const std::string &value, std::ostream &stream)
Definition: HtmlBuilder.h:66
TABLE & width(int value)
Definition: HtmlBuilder.h:157
TABLE & border(int value)
Definition: HtmlBuilder.h:153
TABLE & cellspacing(int value)
Definition: HtmlBuilder.h:155
TABLE(std::ostream &stream)
Definition: HtmlBuilder.h:150
TAG & text()
Definition: HtmlBuilder.h:48
std::string m_tag
Definition: HtmlBuilder.h:56
TAG(const std::string &tag, std::ostream &stream)
Definition: HtmlBuilder.h:36
std::stringstream m_value
Definition: HtmlBuilder.h:57
std::ostream & m_stream
Definition: HtmlBuilder.h:60
TAG & text(int value)
Definition: HtmlBuilder.h:52
TAG & text(const std::string &value)
Definition: HtmlBuilder.h:50
virtual ~TAG()
Definition: HtmlBuilder.h:42
TD(std::ostream &stream)
Definition: HtmlBuilder.h:164
TD & align(const std::string &value)
Definition: HtmlBuilder.h:167
TITLE(std::ostream &stream)
Definition: HtmlBuilder.h:174
TR(std::ostream &stream)
Definition: HtmlBuilder.h:181
const char * NBSP
Definition: HtmlBuilder.h:145

Generated on Wed Nov 24 2021 09:55:53 for QuickFIX by doxygen 1.9.1 written by Dimitri van Heesch, © 1997-2001