Main Page   Namespace List   Class Hierarchy   Alphabetical List   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.7 2001/09/02 19:53:17 sbooth Exp $
00004  *
00005  *  Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001 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  *
00036  * The latest version can be found on your closest GNU mirror site.
00037  * Please mail bug reports to <bug-cgicc@gnu.org>
00038  */
00039 
00040 #include <vector>
00041 #include <string>
00042 
00043 #include "cgicc/CgiDefs.h"
00044 #include "cgicc/FormEntry.h"
00045 #include "cgicc/FormFile.h"
00046 #include "cgicc/CgiEnvironment.h"
00047 
00048 CGICC_BEGIN_NAMESPACE
00049 
00050 #ifdef WIN32
00051   template class CGICC_API STDNS vector<FormEntry>;
00052   template class CGICC_API STDNS vector<FormFile>;
00053 #endif
00054   
00055 class MultipartHeader;
00056 
00057 // ============================================================
00058 // Iterator typedefs
00059 // ============================================================
00060 
00062 typedef STDNS vector<FormEntry>::iterator       form_iterator;
00064 typedef STDNS vector<FormEntry>::const_iterator const_form_iterator;
00065 
00067 typedef STDNS vector<FormFile>::iterator        file_iterator;
00069 typedef STDNS vector<FormFile>::const_iterator  const_file_iterator;
00070 
00071 // ============================================================
00072 // Class Cgicc
00073 // ============================================================
00074 
00099 class CGICC_API Cgicc {
00100 public:
00101 
00102   // ============================================================
00103 
00106 
00115   Cgicc(reader_function_t stream_reader = NULL);
00116   
00122   ~Cgicc();
00124   
00125   // ============================================================
00126 
00131 
00138   const char*
00139   getCompileDate()                                      const;
00140   
00147   const char*
00148   getCompileTime()                                      const;
00149   
00156   const char*
00157   getVersion()                                          const;
00158 
00165   const char*
00166   getHost()                                             const;
00168   
00169   // ============================================================
00170 
00175 
00182   bool 
00183   queryCheckbox(const STDNS string& elementName)        const;
00184   
00191   inline form_iterator 
00192   operator[] (const STDNS string& name)
00193     { return getElement(name); }
00194 
00201   inline const_form_iterator 
00202   operator[] (const STDNS string& name)                 const
00203     { return getElement(name); }
00204   
00211   form_iterator 
00212   getElement(const STDNS string& name);
00213   
00220   const_form_iterator 
00221   getElement(const STDNS string& name)                  const;
00222   
00230   bool 
00231   getElement(const STDNS string& name,
00232              STDNS vector<FormEntry>& result)           const;
00233 
00240   form_iterator 
00241   getElementByValue(const STDNS string& value);
00242   
00249   const_form_iterator 
00250   getElementByValue(const STDNS string& value)          const;
00251   
00259   bool 
00260   getElementByValue(const STDNS string& value,
00261                     STDNS vector<FormEntry>& result)    const;
00262 
00268   inline const STDNS vector<FormEntry>& 
00269   operator* ()                                          const
00270     { return fFormData; }
00271   
00277   inline const STDNS vector<FormEntry>&
00278   getElements()                                         const
00279     { return fFormData; }
00281 
00282   // ============================================================
00283 
00286 
00293   file_iterator 
00294   getFile(const STDNS string& name);
00295   
00302   const_file_iterator 
00303   getFile(const STDNS string& name)                     const;
00304 
00309   inline const STDNS vector<FormFile>&
00310   getFiles()                                            const
00311     { return fFormFiles; }
00313   
00314   // ============================================================
00315 
00318 
00323   inline const CgiEnvironment&
00324   getEnvironment()                                      const
00325     { return fEnvironment;}
00327   
00328   // ============================================================
00329 
00332   
00339   void 
00340   save(const STDNS string& filename)                    const;
00341   
00348   void 
00349   restore(const STDNS string& filename);
00351   
00352 private:
00353   CgiEnvironment                fEnvironment;
00354   STDNS vector<FormEntry>       fFormData;
00355   STDNS vector<FormFile>        fFormFiles;
00356   
00357   // Convert query string into a list of FormEntries
00358   void 
00359   parseFormInput(const STDNS string& data);
00360   
00361   // Parse a multipart/form-data header
00362   MultipartHeader
00363   parseHeader(const STDNS string& data);
00364   
00365   // Parse a (name=value) form entry
00366   void 
00367   parsePair(const STDNS string& data);
00368   
00369   // Parse a MIME entry for ENCTYPE=""
00370   void
00371   parseMIME(const STDNS string& data);
00372 
00373   // Find elements in the list of entries
00374   bool 
00375   findEntries(const STDNS string& param, 
00376               bool byName,
00377               STDNS vector<FormEntry>& result)          const;
00378 };
00379 
00380 CGICC_END_NAMESPACE
00381 
00382 #endif /* ! _CGICC_H_ */

GNU cgicc - A C++ class library for writing CGI applications
Copyright © 1996, 1997, 1998, 1999, 2000, 2001, 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 Wed Jan 9 12:31:26 2002 for cgicc by doxygen 1.2.13.1