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
HTML::TR
Definition: HtmlBuilder.h:195
HTML::HEAD::HEAD
HEAD(std::ostream &stream)
Definition: HtmlBuilder.h:151
HTML::HR
Definition: HtmlBuilder.h:155
HTML::BR
Definition: HtmlBuilder.h:106
HTML::TR::TR
TR(std::ostream &stream)
Definition: HtmlBuilder.h:198
HTML::TD::TD
TD(std::ostream &stream)
Definition: HtmlBuilder.h:181
HTML::NBSP
const char * NBSP
Definition: HtmlBuilder.h:162
HTML::TAG::text
TAG & text()
Definition: HtmlBuilder.h:82
HTML::TABLE::border
TABLE & border(int value)
Definition: HtmlBuilder.h:170
HTML::HEAD
Definition: HtmlBuilder.h:148
HTML::A::href
A & href(const std::string &value)
Definition: HtmlBuilder.h:95
HTML::TABLE::cellspacing
TABLE & cellspacing(int value)
Definition: HtmlBuilder.h:172
HTML::H2
Definition: HtmlBuilder.h:141
HTML::H1::H1
H1(std::ostream &stream)
Definition: HtmlBuilder.h:137
HTML::TAG::m_stream
std::ostream & m_stream
Definition: HtmlBuilder.h:94
HTML::HR::HR
HR(std::ostream &stream)
Definition: HtmlBuilder.h:158
HTML::TABLE::TABLE
TABLE(std::ostream &stream)
Definition: HtmlBuilder.h:167
HTML::TAG
Definition: HtmlBuilder.h:50
HTML::BODY::BODY
BODY(std::ostream &stream)
Definition: HtmlBuilder.h:102
HTML::H1
Definition: HtmlBuilder.h:134
HTML
Definition: HtmlBuilder.h:31
HTML::TABLE::width
TABLE & width(int value)
Definition: HtmlBuilder.h:174
HTML::TITLE::TITLE
TITLE(std::ostream &stream)
Definition: HtmlBuilder.h:191
HTML::CENTER::CENTER
CENTER(std::ostream &stream)
Definition: HtmlBuilder.h:123
HTML::CENTER
Definition: HtmlBuilder.h:120
HTML::A::A
A(std::ostream &stream)
Definition: HtmlBuilder.h:92
HTML::EM
Definition: HtmlBuilder.h:127
HTML::TD
Definition: HtmlBuilder.h:178
HTML::BODY
Definition: HtmlBuilder.h:99
HTML::H2::H2
H2(std::ostream &stream)
Definition: HtmlBuilder.h:144
HTML::SPECIAL::SPECIAL
SPECIAL(const std::string &value, std::ostream &stream)
Definition: HtmlBuilder.h:83
HTML::CAPTION
Definition: HtmlBuilder.h:113
HTML::EM::EM
EM(std::ostream &stream)
Definition: HtmlBuilder.h:130
HTML::TAG::m_tag
std::string m_tag
Definition: HtmlBuilder.h:90
HTML::TAG::~TAG
virtual ~TAG()
Definition: HtmlBuilder.h:76
HTML::BR::BR
BR(std::ostream &stream)
Definition: HtmlBuilder.h:109
HTML::TITLE
Definition: HtmlBuilder.h:188
HTML::A
Definition: HtmlBuilder.h:89
HTML::CAPTION::CAPTION
CAPTION(std::ostream &stream)
Definition: HtmlBuilder.h:116
HTML::TAG::m_value
std::stringstream m_value
Definition: HtmlBuilder.h:91
HTML::TD::align
TD & align(const std::string &value)
Definition: HtmlBuilder.h:184
HTML::TAG::TAG
TAG(const std::string &tag, std::ostream &stream)
Definition: HtmlBuilder.h:70
HTML::TABLE
Definition: HtmlBuilder.h:164

Generated on Wed Apr 29 2020 19:41:30 for QuickFIX by doxygen 1.8.17 written by Dimitri van Heesch, © 1997-2001