Google
Web alhem.net

WebForm.cpp

Go to the documentation of this file.
00001 // WebForm.cpp
00002 /*
00003 Copyright (C) 2003  Anders Hedstrom
00004 
00005 This program is free software; you can redistribute it and/or
00006 modify it under the terms of the GNU General Public License
00007 as published by the Free Software Foundation; either version 2
00008 of the License, or (at your option) any later version.
00009 
00010 This program is distributed in the hope that it will be useful,
00011 but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00013 GNU General Public License for more details.
00014 
00015 You should have received a copy of the GNU General Public License
00016 along with this program; if not, write to the Free Software
00017 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018 */
00019 
00020 #ifdef _WIN32
00021 #pragma warning(disable:4786)
00022 #endif
00023 #include <stdio.h>
00024 //#include <string>
00025 #include <stdarg.h>
00026 
00027 #include "Form.h"
00028 #include "Cookies.h"
00029 //#include <vector>
00030 #include "WebForm.h"
00031 #include "Web.h"
00032 
00033 namespace Cgi {
00034 
00035 WebForm::WebForm(Web *web,const std::string &name)
00036 :m_pclWeb(web)
00037 ,m_strFormName(name)
00038 {
00039 }
00040 
00041 
00042 WebForm::~WebForm()
00043 {
00044 }
00045 
00046 
00047 Form *WebForm::GetForm() 
00048 { 
00049         return m_pclWeb->GetForm(); 
00050 }
00051 
00052 
00053 Cookies *WebForm::GetCookies() 
00054 { 
00055         return m_pclWeb->GetCookies(); 
00056 }
00057 
00058 
00059 std::string WebForm::GetCgiName() 
00060 { 
00061         return m_pclWeb->GetCgiName(); 
00062 }
00063 
00064 
00065 Web *WebForm::GetWeb() 
00066 { 
00067         return m_pclWeb; 
00068 }
00069 
00070 
00071 std::string WebForm::GetDate()
00072 { 
00073         return m_pclWeb -> GetDate(); 
00074 }
00075 
00076 
00077 std::string WebForm::GetFormName()
00078 {
00079         return m_strFormName;
00080 }
00081 
00082 
00083 void WebForm::nbprintf(char *format, ...)
00084 {
00085         char slask[5000];
00086         va_list ap;
00087 
00088         va_start(ap, format);
00089 #ifdef WIN32
00090         vsprintf(slask, format, ap);
00091 #else
00092         vsnprintf(slask, 5000, format, ap);
00093 #endif
00094         va_end(ap);
00095 
00096         for (size_t i = 0; i < strlen(slask); i++)
00097         {
00098                 if (slask[i] == ' ')
00099                         printf("&nbsp;");
00100                 else
00101                         printf("%c",slask[i]);
00102         }
00103 }
00104 
00105 
00106 void WebForm::nbfprintf(FILE *fil,char *format, ...)
00107 {
00108         char slask[5000];
00109         va_list ap;
00110 
00111         va_start(ap, format);
00112 #ifdef WIN32
00113         vsprintf(slask, format, ap);
00114 #else
00115         vsnprintf(slask, 5000, format, ap);
00116 #endif
00117         va_end(ap);
00118 
00119         for (size_t i = 0; i < strlen(slask); i++)
00120         {
00121                 if (slask[i] == ' ')
00122                         fprintf(fil,"&nbsp;");
00123                 else
00124                         fprintf(fil,"%c",slask[i]);
00125         }
00126 }
00127 
00128 
00129 void WebForm::eprintf(char *format, ...)
00130 {
00131         char slask[5000];
00132         va_list ap;
00133 
00134         va_start(ap, format);
00135 #ifdef WIN32
00136         vsprintf(slask, format, ap);
00137 #else
00138         vsnprintf(slask, 5000, format, ap);
00139 #endif
00140         va_end(ap);
00141 
00142         for (size_t i = 0; i < strlen(slask); i++)
00143         {
00144                 switch (slask[i])
00145                 {
00146                 case '<':
00147                         printf("&lt;");
00148                         break;
00149                 case '&':
00150                         printf("&amp;");
00151                         break;
00152                 default:
00153                         printf("%c",slask[i]);
00154                 }
00155         }
00156 }
00157 
00158 
00159 void WebForm::SetContentType(const std::string& x)
00160 {
00161         m_pclWeb -> SetContentType(x);
00162 }
00163 
00164 
00165 void WebForm::SetContentDisposition(const std::string& x)
00166 {
00167         m_pclWeb -> SetContentDisposition(x);
00168 }
00169 
00170 
00171 void WebForm::SetLocation(const std::string& x)
00172 {
00173         m_pclWeb -> SetLocation(x);
00174 }
00175 
00176 
00177 std::string WebForm::GetRequestMethod()
00178 {
00179         return m_pclWeb -> GetRequestMethod();
00180 }
00181 
00182 
00183 } // namespace

Generated for cgi++ by doxygen 1.3.7

Page, code, and content Copyright (C) 2004 by Anders Hedström