HtmlBuilder.h
Go to the documentation of this file.
/* -*- C++ -*- */
/****************************************************************************
** Copyright (c) 2001-2014
**
** This file is part of the QuickFIX FIX Engine
**
** This file may be distributed under the terms of the quickfixengine.org
** license as defined by quickfixengine.org and appearing in the file
** LICENSE included in the packaging of this file.
**
** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
**
** See http://www.quickfixengine.org/LICENSE for licensing information.
**
** Contact ask@quickfixengine.org if any conditions of this licensing are
** not clear to you.
**
****************************************************************************/
#ifndef HTML_BUILDER_H
#define HTML_BUILDER_H
#ifdef _MSC_VER
#pragma warning( disable : 4503 4355 4786 4290 )
#endif
#include <sstream>
namespace HTML
{
class TAG
{
public:
TAG( const std::string& tag, std::ostream& stream )
: m_tag( tag ), m_stream( stream )
{
m_stream << "<" << m_tag;
}
virtual ~TAG()
{
m_stream << m_value.str();
m_stream << "</" << m_tag << ">";
}
TAG& text()
{ m_stream << ">"; return *this; }
TAG& text( const std::string& value )
{ m_value << value; text(); return *this; }
TAG& text( int value )
{ m_value << value; text(); return *this; }
private:
std::string m_tag;
std::stringstream m_value;
protected:
std::ostream& m_stream;
};
class SPECIAL
{
public:
SPECIAL( const std::string& value, std::ostream& stream )
{
stream << "&" << value << ";";
}
};
class A : public TAG
{
public:
A( std::ostream& stream )
: TAG( "A", stream ) {}
A& href( const std::string& value )
{ m_stream << " href='" << value << "'"; return *this; }
};
class BODY : public TAG
{
public:
BODY( std::ostream& stream )
: TAG( "BODY", stream ) {}
};
class BR : public TAG
{
public:
BR( std::ostream& stream )
: TAG( "BR", stream ) {}
};
class CAPTION : public TAG
{
public:
CAPTION( std::ostream& stream )
: TAG( "CAPTION", stream ) {}
};
class CENTER : public TAG
{
public:
CENTER( std::ostream& stream )
: TAG( "CENTER", stream ) {}
};
class EM : public TAG
{
public:
EM( std::ostream& stream )
: TAG( "EM", stream ) {}
};
class H1 : public TAG
{
public:
H1( std::ostream& stream )
: TAG( "H1", stream ) {}
};
class H2 : public TAG
{
public:
H2( std::ostream& stream )
: TAG( "H2", stream ) {}
};
class HEAD : public TAG
{
public:
HEAD( std::ostream& stream )
: TAG( "HEAD", stream ) {}
};
class HR : public TAG
{
public:
HR( std::ostream& stream )
: TAG( "HR", stream ) {}
};
const char* NBSP = "&nbsp;";
class TABLE : public TAG
{
public:
TABLE( std::ostream& stream )
: TAG( "TABLE", stream ) {}
TABLE& border( int value )
{ m_stream << " border='" << value << "'"; return *this; }
TABLE& cellspacing( int value )
{ m_stream << " cellspacing='" << value << "'"; return *this; }
TABLE& width( int value )
{ m_stream << " width='" << value << "%'"; return *this; }
};
class TD : public TAG
{
public:
TD( std::ostream& stream )
: TAG( "TD", stream ) {}
TD& align( const std::string& value )
{ m_stream << " align='" << value << "'"; return *this; }
};
class TITLE : public TAG
{
public:
TITLE( std::ostream& stream )
: TAG( "TITLE", stream ) {}
};
class TR : public TAG
{
public:
TR( std::ostream& stream )
: TAG( "TR", stream ) {}
};
}
#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