Main Page   Class Hierarchy   File List  

cgiExtend.cpp

00001 
00002                                            /*
00003   cgiExtend.cpp
00004 
00005   Common Gateway Interface Class Implementation.
00006      Extended classes for cgi support
00007      -- generic tag container
00008   copyright (c) 2001
00009 
00010   David McCombs davidmc@newcottage.com
00011 
00012   Nuclear Core Class Library
00013 
00014   freely re-usable, redistributable.
00015 
00016 */
00017 #include "cgiExtend.h"
00018 
00019 /*
00020   A generic html tag container
00021 */
00022 
00023 
00024 cgiCan::cgiCan( const char * name, const char * attr = NULL)
00025 {
00026   isClosed = false;
00027   id = generic;
00028   opening = "<";
00029   opening += name;
00030   if( attr && strlen(attr) )
00031   {
00032     opening += " ";
00033     opening += attr;
00034   }
00035   opening += ">";
00036   cgiBase::close = "</";
00037   cgiBase::close += name;
00038   cgiBase::close += ">";
00039   *this << opening;
00040 }
00041 
00042 void cgiCan::open()
00043 {
00044   if( isClosed )
00045   {
00046     *this << cgiBase::opening << endl;
00047     flush();
00048     isClosed = false;
00049   }
00050 }
00051 void cgiCan::close()
00052 {
00053   if( !isClosed )
00054   {
00055     *this << cgiBase::close << endl;
00056     flush();
00057     isClosed = true;
00058   }
00059 }
00060 cgiCan::~cgiCan()
00061 {
00062   if( !isClosed )
00063   {
00064     *this << cgiBase::close << endl;
00065     flush();
00066   }
00067 }
00068 
00069 
00070 
00071 cgiTextbox::cgiTextbox( const char * name,
00072             const char * value = NULL,
00073             const char * size = NULL,
00074             const char * max = NULL,
00075             const char * attr = NULL )
00076 {
00077   id = generic;
00078 
00079   *this << "<input type='text'";
00080   if ( name && strlen(name) )
00081   {
00082     *this << " name='" << name << "'";
00083   }
00084   if ( value && strlen(value) )
00085   {
00086     *this << " value=\"" << value << "\"";
00087   }
00088   if ( size && strlen(size) )
00089   {
00090     *this << " size='" << size << "'";
00091   }
00092   if ( max && strlen(max) )
00093   {
00094     *this << " maxlength='" << max << "'";
00095   }
00096   if ( attr && strlen(attr) )
00097   {
00098     *this << " " << attr;
00099   }
00100   *this << ">";
00101   flush();
00102 }
00103 
00104 // unary tag - not a container
00105 cgiTextbox::~cgiTextbox(){;}
00106 
00107 
00108 
00109 cgiPassword::cgiPassword( const char * name,
00110             const char * value = NULL,
00111             const char * size = NULL,
00112             const char * max = NULL,
00113             const char * attr = NULL )
00114 {
00115   id = generic;
00116 
00117   *this << "<input type='password'";
00118   if ( name && strlen(name) )
00119   {
00120     *this << " name='" << name << "'";
00121   }
00122   if ( value && strlen(value) )
00123   {
00124     *this << " value=\"" << value << "\"";
00125   }
00126   if ( size && strlen(size) )
00127   {
00128     *this << " size='" << size << "'";
00129   }
00130   if ( max && strlen(max) )
00131   {
00132     *this << " maxlength='" << max << "'";
00133   }
00134   if ( attr && strlen(attr) )
00135   {
00136     *this << " " << attr;
00137   }
00138   *this << ">";
00139   flush();
00140 }
00141 
00142 // unary tag - not a container
00143 cgiPassword::~cgiPassword(){;}
00144 
00145 
00146 
00147 cgiSelect::cgiSelect(const char * attr = NULL):cgiCan( "select", attr )
00148 {
00149   ;
00150 }
00151 void cgiSelect::setSelected( const char * selected )
00152 {
00153   m_selected = selected;
00154 }
00155 void cgiSelect::addOption( const char * label, const char * value, bool selected=false, const char * attr = NULL )
00156 {
00157   *this << "<option";
00158   if( attr ) *this << " " << attr;
00159   if( (m_selected == value) || selected ) *this << " selected";
00160   *this << " value='" << value << "'>" << label << "</option>";
00161 }
00162 cgiSelect::~cgiSelect(){;}
00163 
00164 
00165 cgiTextarea::cgiTextarea(const char * attr = NULL):cgiCan( "textarea", attr?attr:" rows='10' cols='80'" )
00166 {
00167   ;
00168 }
00169 cgiTextarea::~cgiTextarea(){;}

Generated on Tue Jan 20 09:03:27 2004 for OpenTools by doxygen1.2.18