Main Page   Namespace List   Class Hierarchy   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

Cgicc.h

Go to the documentation of this file.
00001 /* -*-c++-*- */
00002 /*
00003  *  $Id: Cgicc.h,v 1.11 2002/03/09 18:34:18 sbooth Exp $
00004  *
00005  *  Copyright (C) 1996 - 2002 Stephen F. Booth
00006  *
00007  *  This library is free software; you can redistribute it and/or
00008  *  modify it under the terms of the GNU Lesser General Public
00009  *  License as published by the Free Software Foundation; either
00010  *  version 2.1 of the License, or (at your option) any later version.
00011  *
00012  *  This library is distributed in the hope that it will be useful,
00013  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00015  *  Lesser General Public License for more details.
00016  *
00017  *  You should have received a copy of the GNU Lesser General Public
00018  *  License along with this library; if not, write to the Free Software
00019  *  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00020  */
00021 
00022 #ifndef _CGICC_H_
00023 #define _CGICC_H_ 1
00024 
00025 #ifdef __GNUG__
00026 #  pragma interface
00027 #endif
00028 
00033 /*
00034  * The GNU cgicc library, by Stephen F. Booth <sbooth@gnu.org>
00035  * http://www.cgicc.org
00036  *
00037  * The latest version can be found on your closest GNU mirror site.
00038  * Please mail bug reports to <bug-cgicc@gnu.org>
00039  */
00040 
00041 #include <vector>
00042 #include <string>
00043 
00044 #include "cgicc/CgiDefs.h"
00045 #include "cgicc/FormEntry.h"
00046 #include "cgicc/FormFile.h"
00047 #include "cgicc/CgiInput.h"
00048 #include "cgicc/CgiEnvironment.h"
00049 
00050 CGICC_BEGIN_NAMESPACE
00051 
00052 #ifdef WIN32
00053   template class CGICC_API STDNS vector<FormEntry>;
00054   template class CGICC_API STDNS vector<FormFile>;
00055 #endif
00056   
00057 class MultipartHeader;
00058 
00059 // ============================================================
00060 // Iterator typedefs
00061 // ============================================================
00062 
00064 typedef STDNS vector<FormEntry>::iterator       form_iterator;
00066 typedef STDNS vector<FormEntry>::const_iterator const_form_iterator;
00067 
00069 typedef STDNS vector<FormFile>::iterator        file_iterator;
00071 typedef STDNS vector<FormFile>::const_iterator  const_file_iterator;
00072 
00073 // ============================================================
00074 // Class Cgicc
00075 // ============================================================
00076 
00101 class CGICC_API Cgicc {
00102 public:
00103 
00104   // ============================================================
00105 
00108 
00118   Cgicc(CgiInput *input = 0);
00119   
00125   ~Cgicc();
00127   
00128   // ============================================================
00129 
00134 
00141   const char*
00142   getCompileDate()                                      const;
00143   
00150   const char*
00151   getCompileTime()                                      const;
00152   
00159   const char*
00160   getVersion()                                          const;
00161 
00168   const char*
00169   getHost()                                             const;
00171   
00172   // ============================================================
00173 
00178 
00185   bool 
00186   queryCheckbox(const STDNS string& elementName)        const;
00187   
00194   inline form_iterator 
00195   operator[] (const STDNS string& name)
00196     { return getElement(name); }
00197 
00204   inline const_form_iterator 
00205   operator[] (const STDNS string& name)                 const
00206     { return getElement(name); }
00207   
00214   form_iterator 
00215   getElement(const STDNS string& name);
00216   
00223   const_form_iterator 
00224   getElement(const STDNS string& name)                  const;
00225   
00233   bool 
00234   getElement(const STDNS string& name,
00235              STDNS vector<FormEntry>& result)           const;
00236 
00243   form_iterator 
00244   getElementByValue(const STDNS string& value);
00245   
00252   const_form_iterator 
00253   getElementByValue(const STDNS string& value)          const;
00254   
00262   bool 
00263   getElementByValue(const STDNS string& value,
00264                     STDNS vector<FormEntry>& result)    const;
00265 
00271   inline const STDNS vector<FormEntry>& 
00272   operator* ()                                          const
00273     { return fFormData; }
00274   
00280   inline const STDNS vector<FormEntry>&
00281   getElements()                                         const
00282     { return fFormData; }
00284 
00285   // ============================================================
00286 
00289 
00296   file_iterator 
00297   getFile(const STDNS string& name);
00298   
00305   const_file_iterator 
00306   getFile(const STDNS string& name)                     const;
00307 
00312   inline const STDNS vector<FormFile>&
00313   getFiles()                                            const
00314     { return fFormFiles; }
00316   
00317   // ============================================================
00318 
00321 
00326   inline const CgiEnvironment&
00327   getEnvironment()                                      const
00328     { return fEnvironment;}
00330   
00331   // ============================================================
00332 
00335   
00342   void 
00343   save(const STDNS string& filename)                    const;
00344   
00351   void 
00352   restore(const STDNS string& filename);
00354   
00355 private:
00356   CgiEnvironment                fEnvironment;
00357   STDNS vector<FormEntry>       fFormData;
00358   STDNS vector<FormFile>        fFormFiles;
00359   
00360   // Convert query string into a list of FormEntries
00361   void 
00362   parseFormInput(const STDNS string& data);
00363   
00364   // Parse a multipart/form-data header
00365   MultipartHeader
00366   parseHeader(const STDNS string& data);
00367   
00368   // Parse a (name=value) form entry
00369   void 
00370   parsePair(const STDNS string& data);
00371   
00372   // Parse a MIME entry for ENCTYPE=""
00373   void
00374   parseMIME(const STDNS string& data);
00375 
00376   // Find elements in the list of entries
00377   bool 
00378   findEntries(const STDNS string& param, 
00379               bool byName,
00380               STDNS vector<FormEntry>& result)          const;
00381 };
00382 
00383 CGICC_END_NAMESPACE
00384 
00385 #endif /* ! _CGICC_H_ */

GNU cgicc - A C++ class library for writing CGI applications
Copyright © 1996 - 2002 Stephen F. Booth
Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.1 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front Cover Texts, and with no Back-Cover Texts.
Documentation generated Sun Mar 17 16:40:57 2002 for cgicc by doxygen 1.2.13.1