Index  Source Files  Annotated Class List  Alphabetical Class List  Class Hierarchy  Graphical Class Hierarchy 

HtmlBuilder.h

Go to the documentation of this file.
00001 /* -*- C++ -*- */
00002 
00003 /****************************************************************************
00004 ** Copyright (c) quickfixengine.org  All rights reserved.
00005 **
00006 ** This file is part of the QuickFIX FIX Engine
00007 **
00008 ** This file may be distributed under the terms of the quickfixengine.org
00009 ** license as defined by quickfixengine.org and appearing in the file
00010 ** LICENSE included in the packaging of this file.
00011 **
00012 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
00013 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
00014 **
00015 ** See http://www.quickfixengine.org/LICENSE for licensing information.
00016 **
00017 ** Contact ask@quickfixengine.org if any conditions of this licensing are
00018 ** not clear to you.
00019 **
00020 ****************************************************************************/
00021 
00022 #ifndef HTML_BUILDER_H
00023 #define HTML_BUILDER_H
00024 
00025 #ifdef _MSC_VER
00026 #pragma warning( disable : 4503 4355 4786 4290 )
00027 #endif
00028 
00029 #include <sstream>
00030 
00031 namespace HTML
00032 {
00033 class TAG
00034 {
00035 public:
00036   TAG( const std::string& tag, std::ostream& stream )
00037   : m_tag( tag ), m_stream( stream ) 
00038   {
00039     m_stream << "<" << m_tag;
00040   }
00041 
00042   virtual ~TAG() 
00043   {
00044     m_stream << m_value.str();
00045     m_stream << "</" << m_tag << ">";
00046   }
00047 
00048   TAG& text()
00049   { m_stream << ">"; return *this; }
00050   TAG& text( const std::string& value )
00051   { m_value << value; text(); return *this; }
00052   TAG& text( int value )
00053   { m_value << value; text(); return *this; } 
00054 
00055  private:
00056   std::string m_tag;
00057   std::stringstream m_value;
00058 
00059  protected:
00060   std::ostream& m_stream;
00061 };
00062 
00063 class SPECIAL
00064 {
00065  public:
00066   SPECIAL( const std::string& value, std::ostream& stream )
00067   {
00068     stream << "&" << value << ";";
00069   }
00070 };
00071 
00072 class A : public TAG
00073 {
00074 public:
00075   A( std::ostream& stream )
00076   : TAG( "A", stream ) {}
00077 
00078   A& href( const std::string& value )
00079   { m_stream << " href='" << value << "'"; return *this; }
00080 };
00081 
00082 class BODY : public TAG
00083 {
00084 public:
00085   BODY( std::ostream& stream )
00086   : TAG( "BODY", stream ) {}
00087 };
00088 
00089 class BR : public TAG
00090 {
00091 public:
00092   BR( std::ostream& stream )
00093   : TAG( "BR", stream ) {}
00094 };
00095 
00096 class CAPTION : public TAG
00097 {
00098 public:
00099   CAPTION( std::ostream& stream )
00100   : TAG( "CAPTION", stream ) {}
00101 };
00102 
00103 class CENTER : public TAG
00104 {
00105 public:
00106   CENTER( std::ostream& stream )
00107   : TAG( "CENTER", stream ) {}
00108 };
00109 
00110 class EM : public TAG
00111 {
00112 public:
00113   EM( std::ostream& stream )
00114   : TAG( "EM", stream ) {}
00115 };
00116 
00117 class H1 : public TAG
00118 {
00119 public:
00120   H1( std::ostream& stream )
00121   : TAG( "H1", stream ) {}
00122 };
00123 
00124 class H2 : public TAG
00125 {
00126 public:
00127   H2( std::ostream& stream )
00128   : TAG( "H2", stream ) {}
00129 };
00130 
00131 class HEAD : public TAG
00132 {
00133 public:
00134   HEAD( std::ostream& stream )
00135   : TAG( "HEAD", stream ) {}
00136 };
00137 
00138 class HR : public TAG
00139 {
00140 public:
00141   HR( std::ostream& stream )
00142   : TAG( "HR", stream ) {}
00143 };
00144 
00145 const char* NBSP = "&nbsp;";
00146 
00147 class TABLE : public TAG
00148 {
00149 public:
00150   TABLE( std::ostream& stream )
00151   : TAG( "TABLE", stream ) {}
00152 
00153   TABLE& border( int value )
00154   { m_stream << " border='" << value << "'"; return *this; }
00155   TABLE& cellspacing( int value )
00156   { m_stream << " cellspacing='" << value << "'"; return *this; }
00157   TABLE& width( int value )
00158   { m_stream << " width='" << value << "%'"; return *this; }
00159 };
00160 
00161 class TD : public TAG
00162 {
00163 public:
00164   TD( std::ostream& stream )
00165   : TAG( "TD", stream ) {}
00166 
00167   TD& align( const std::string& value )
00168   { m_stream << " align='" << value << "'"; return *this; }
00169 };
00170 
00171 class TITLE : public TAG
00172 {
00173 public:
00174   TITLE( std::ostream& stream )
00175   : TAG( "TITLE", stream ) {}
00176 };
00177 
00178 class TR : public TAG
00179 {
00180 public:
00181   TR( std::ostream& stream )
00182   : TAG( "TR", stream ) {}
00183 };
00184 }
00185 
00186 #endif

Generated on Mon Apr 5 20:59:50 2010 for QuickFIX by doxygen 1.6.1 written by Dimitri van Heesch, © 1997-2001