Logo
~Sockets~
~Examples~
~Contact~


HttpdForm.h

Go to the documentation of this file.
00001 
00006 /*
00007 Copyright (C) 1999-2007  Anders Hedstrom
00008 
00009 This library is made available under the terms of the GNU GPL.
00010 
00011 If you would like to use this library in a closed-source application,
00012 a separate license agreement is available. For information about 
00013 the closed-source license agreement for the C++ sockets library,
00014 please visit http://www.alhem.net/Sockets/license.html and/or
00015 email license@alhem.net.
00016 
00017 This program is free software; you can redistribute it and/or
00018 modify it under the terms of the GNU General Public License
00019 as published by the Free Software Foundation; either version 2
00020 of the License, or (at your option) any later version.
00021 
00022 This program is distributed in the hope that it will be useful,
00023 but WITHOUT ANY WARRANTY; without even the implied warranty of
00024 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00025 GNU General Public License for more details.
00026 
00027 You should have received a copy of the GNU General Public License
00028 along with this program; if not, write to the Free Software
00029 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00030 */
00031 
00032 #ifndef _SOCKETS_HttpdForm_H
00033 #define _SOCKETS_HttpdForm_H
00034 
00035 #include "sockets-config.h"
00036 #include <string>
00037 #include <list>
00038 
00039 #ifdef SOCKETS_NAMESPACE
00040 namespace SOCKETS_NAMESPACE {
00041 #endif
00042 
00043 
00044 class IFile;
00045 
00048 class HttpdForm
00049 {
00055         struct CGI
00056         {
00057                 CGI(const std::string& n,const std::string& v) : name(n),value(v) {}
00058                 CGI(const std::string& n,const std::string& v,const std::string& p) : name(n),value(v),path(p) {}
00059                 std::string name;
00060                 std::string value;
00061                 std::string path;
00062         };
00064         typedef std::list<CGI *> cgi_v;
00065 
00066 public:
00072         HttpdForm(IFile *, const std::string& content_type, size_t content_length);
00079         HttpdForm(const std::string& query_string,size_t length);
00080         ~HttpdForm();
00081 
00082         void EnableRaw(bool);
00083 
00085         void strcpyval(std::string&,const char *) const;
00086 
00087         /* get names */
00088         bool getfirst(std::string& n) const;
00089         bool getnext(std::string& n) const;
00090 
00091         /* get names and values */
00092         bool getfirst(std::string& n,std::string& v) const;
00093         bool getnext(std::string& n,std::string& v) const;
00094 
00095         /* get value */
00096         int getvalue(const std::string& ,std::string& ) const;
00097         std::string getvalue(const std::string& ) const;
00098         size_t getlength(const std::string& ) const;
00099         cgi_v& getbase();
00100 
00101         const std::string& GetBoundary() const;
00102 
00103 private:
00104         HttpdForm(const HttpdForm& ) {}
00105         HttpdForm& operator=(const HttpdForm& ) { return *this; }
00106         cgi_v m_cgi;
00107         mutable cgi_v::const_iterator m_current;
00108         std::string m_strBoundary;
00109         bool raw;
00110 };
00111 
00112 
00113 #ifdef SOCKETS_NAMESPACE
00114 }
00115 #endif
00116 
00117 #endif // _SOCKETS_HttpdForm_H
Page, code, and content Copyright (C) 2007 by Anders Hedström
Generated for C++ Sockets by  doxygen 1.4.4