Wexus2 0.20
wexus2.src/wexus/ParamsParser.h
00001 
00002 /*
00003  * Copyright (c) 2011 Aleksander B. Demko
00004  * This source code is distributed under the MIT license.
00005  * See the accompanying file LICENSE.MIT.txt for details.
00006  */
00007 
00008 #ifndef __INCLUDED_WEXUS_PARAMSPARSER_H__
00009 #define __INCLUDED_WEXUS_PARAMSPARSER_H__
00010 
00011 #include <map>
00012 
00013 #include <QString>
00014 #include <QVariant>
00015 
00016 #include <wexus/HTTPHandler.h>
00017 
00018 namespace wexus
00019 {
00020   class ParamsParser;
00021 }
00022 
00023 /**
00024  * Parsers form params.
00025  *
00026  * @author Aleksander Demko
00027  */ 
00028 class wexus::ParamsParser
00029 {
00030   public:
00031     class ParamsDecodeException : public wexus::HTTPHandler::Exception   // TODO should this really decend from HTTPHandler::Exception?
00032     {
00033       public:
00034         ParamsDecodeException(void);
00035     };
00036 
00037   public:
00038     /**
00039      * Parse the form params out of the given wexus::HTTPRequest
00040      *
00041      * @author Aleksander Demko
00042      */ 
00043     static QVariantMap parse(wexus::HTTPRequest *req);
00044 
00045     /**
00046      * Parse the form params out of the given wexus::HTTPRequest
00047      *
00048      * @author Aleksander Demko
00049      */ 
00050     static void parse(wexus::HTTPRequest *req, QVariantMap &out);
00051 
00052   private:
00053     template <class ITER>
00054       static void decodeAndParse(ITER encodedBegin, ITER encodedEnd, QVariantMap &out);
00055 
00056     static void nestedInsert(QVariantMap &m, const QString &key, const QString &val);
00057 };
00058 
00059 #endif
00060 
00061 
 All Classes Namespaces Functions Variables Enumerations Enumerator