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
31namespace HTML
32{
33class TAG
34{
35public:
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
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
64{
65 public:
66 SPECIAL( const std::string& value, std::ostream& stream )
67 {
68 stream << "&" << value << ";";
69 }
70};
71
72class A : public TAG
73{
74public:
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
82class BODY : public TAG
83{
84public:
85 BODY( std::ostream& stream )
86 : TAG( "BODY", stream ) {}
87};
88
89class BR : public TAG
90{
91public:
92 BR( std::ostream& stream )
93 : TAG( "BR", stream ) {}
94};
95
96class CAPTION : public TAG
97{
98public:
99 CAPTION( std::ostream& stream )
100 : TAG( "CAPTION", stream ) {}
101};
102
103class CENTER : public TAG
104{
105public:
106 CENTER( std::ostream& stream )
107 : TAG( "CENTER", stream ) {}
108};
109
110class EM : public TAG
111{
112public:
113 EM( std::ostream& stream )
114 : TAG( "EM", stream ) {}
115};
116
117class H1 : public TAG
118{
119public:
120 H1( std::ostream& stream )
121 : TAG( "H1", stream ) {}
122};
123
124class H2 : public TAG
125{
126public:
127 H2( std::ostream& stream )
128 : TAG( "H2", stream ) {}
129};
130
131class HEAD : public TAG
132{
133public:
134 HEAD( std::ostream& stream )
135 : TAG( "HEAD", stream ) {}
136};
137
138class HR : public TAG
139{
140public:
141 HR( std::ostream& stream )
142 : TAG( "HR", stream ) {}
143};
144
145const char* NBSP = "&nbsp;";
146
147class TABLE : public TAG
148{
149public:
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
161class TD : public TAG
162{
163public:
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
171class TITLE : public TAG
172{
173public:
174 TITLE( std::ostream& stream )
175 : TAG( "TITLE", stream ) {}
176};
177
178class TR : public TAG
179{
180public:
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)
EM(std::ostream &stream)
H1(std::ostream &stream)
H2(std::ostream &stream)
HEAD(std::ostream &stream)
HR(std::ostream &stream)
SPECIAL(const std::string &value, std::ostream &stream)
Definition HtmlBuilder.h:66
TABLE & cellspacing(int value)
TABLE & border(int value)
TABLE(std::ostream &stream)
TABLE & width(int value)
TAG & text(const std::string &value)
Definition HtmlBuilder.h:50
std::string m_tag
Definition HtmlBuilder.h:56
TAG(const std::string &tag, std::ostream &stream)
Definition HtmlBuilder.h:36
TAG & text(int value)
Definition HtmlBuilder.h:52
TAG & text()
Definition HtmlBuilder.h:48
std::stringstream m_value
Definition HtmlBuilder.h:57
std::ostream & m_stream
Definition HtmlBuilder.h:60
virtual ~TAG()
Definition HtmlBuilder.h:42
TD(std::ostream &stream)
TD & align(const std::string &value)
TITLE(std::ostream &stream)
TR(std::ostream &stream)
const char * NBSP

Generated on Thu Feb 29 2024 22:38:19 for QuickFIX by doxygen 1.9.8 written by Dimitri van Heesch, © 1997-2001