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 
00084         void strcpyval(std::string&,const char *);
00085 
00086         /* get names */
00087         bool getfirst(std::string& n);
00088         bool getnext(std::string& n);
00089 
00090         /* get names and values */
00091         bool getfirst(std::string& n,std::string& v);
00092         bool getnext(std::string& n,std::string& v);
00093 
00094         /* get value */
00095         int getvalue(const std::string& ,std::string& );
00096         std::string getvalue(const std::string& );
00097         size_t getlength(const std::string& );
00098         cgi_v& getbase();
00099 
00100         const std::string& GetBoundary();
00101 
00102 private:
00103         HttpdForm(const HttpdForm& ) {}
00104         HttpdForm& operator=(const HttpdForm& ) { return *this; }
00105         cgi_v m_cgi;
00106         cgi_v::iterator m_current;
00107         std::string m_strBoundary;
00108         bool raw;
00109 };
00110 
00111 
00112 #ifdef SOCKETS_NAMESPACE
00113 }
00114 #endif
00115 
00116 #endif // _SOCKETS_HttpdForm_H
Page, code, and content Copyright (C) 2007 by Anders Hedström
Generated for C++ Sockets by  doxygen 1.4.4