00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024 #ifndef _CGICC_H_
00025 #define _CGICC_H_ 1
00026
00027 #ifdef __GNUG__
00028 # pragma interface
00029 #endif
00030
00035
00036
00037
00038
00039
00040
00041
00042
00043 #include <vector>
00044 #include <string>
00045
00046 #include "cgicc/CgiDefs.h"
00047 #include "cgicc/FormEntry.h"
00048 #include "cgicc/FormFile.h"
00049 #include "cgicc/CgiInput.h"
00050 #include "cgicc/CgiEnvironment.h"
00051
00052 namespace cgicc {
00053
00054 #ifdef WIN32
00055 template class CGICC_API std::vector<FormEntry>;
00056 template class CGICC_API std::vector<FormFile>;
00057 #endif
00058
00059 class MultipartHeader;
00060
00061
00062
00063
00064
00066 typedef std::vector<FormEntry>::iterator form_iterator;
00068 typedef std::vector<FormEntry>::const_iterator const_form_iterator;
00069
00071 typedef std::vector<FormFile>::iterator file_iterator;
00073 typedef std::vector<FormFile>::const_iterator const_file_iterator;
00074
00075
00076
00077
00078
00103 class CGICC_API Cgicc {
00104 public:
00105
00106
00107
00110
00120 Cgicc(CgiInput *input = 0);
00121
00128 inline
00129 Cgicc(const Cgicc& cgi)
00130 : fEnvironment(cgi.fEnvironment)
00131 { operator=(cgi); }
00132
00138 ~Cgicc();
00140
00141
00142
00145
00153 inline bool
00154 operator== (const Cgicc& cgi) const
00155 { return this->fEnvironment == cgi.fEnvironment; }
00156
00164 inline bool
00165 operator!= (const Cgicc& cgi) const
00166 { return ! operator==(cgi); }
00167
00168 #ifdef WIN32
00169
00170 inline bool
00171 operator< (const Cgicc& cgi) const
00172 { return false; }
00173 #endif
00174
00182 Cgicc&
00183 operator= (const Cgicc& cgi);
00185
00186
00187
00192
00199 const char*
00200 getCompileDate() const;
00201
00208 const char*
00209 getCompileTime() const;
00210
00217 const char*
00218 getVersion() const;
00219
00226 const char*
00227 getHost() const;
00229
00230
00231
00236
00243 bool
00244 queryCheckbox(const std::string& elementName) const;
00245
00252 inline form_iterator
00253 operator[] (const std::string& name)
00254 { return getElement(name); }
00255
00262 std::string
00263 operator() (const std::string& name) const;
00264
00271 inline const_form_iterator
00272 operator[] (const std::string& name) const
00273 { return getElement(name); }
00274
00281 form_iterator
00282 getElement(const std::string& name);
00283
00290 const_form_iterator
00291 getElement(const std::string& name) const;
00292
00300 bool
00301 getElement(const std::string& name,
00302 std::vector<FormEntry>& result) const;
00303
00310 form_iterator
00311 getElementByValue(const std::string& value);
00312
00319 const_form_iterator
00320 getElementByValue(const std::string& value) const;
00321
00329 bool
00330 getElementByValue(const std::string& value,
00331 std::vector<FormEntry>& result) const;
00332
00338 inline const std::vector<FormEntry>&
00339 operator* () const
00340 { return fFormData; }
00341
00347 inline const std::vector<FormEntry>&
00348 getElements() const
00349 { return fFormData; }
00351
00352
00353
00356
00363 file_iterator
00364 getFile(const std::string& name);
00365
00372 const_file_iterator
00373 getFile(const std::string& name) const;
00374
00379 inline const std::vector<FormFile>&
00380 getFiles() const
00381 { return fFormFiles; }
00383
00384
00385
00388
00393 inline const CgiEnvironment&
00394 getEnvironment() const
00395 { return fEnvironment;}
00397
00398
00399
00402
00409 void
00410 save(const std::string& filename) const;
00411
00418 void
00419 restore(const std::string& filename);
00421
00422 private:
00423 CgiEnvironment fEnvironment;
00424 std::vector<FormEntry> fFormData;
00425 std::vector<FormFile> fFormFiles;
00426
00427
00428 void
00429 parseFormInput(const std::string& data);
00430
00431
00432 MultipartHeader
00433 parseHeader(const std::string& data);
00434
00435
00436 void
00437 parsePair(const std::string& data);
00438
00439
00440 void
00441 parseMIME(const std::string& data);
00442
00443
00444 bool
00445 findEntries(const std::string& param,
00446 bool byName,
00447 std::vector<FormEntry>& result) const;
00448 };
00449
00450 }
00451
00452 #endif