version 0.1.7
[fms.git] / include / http / ipagehandler.h
1 #ifndef _ipagehandler_\r
2 #define _ipagehandler_\r
3 \r
4 #include <cstdlib>\r
5 #include <string>\r
6 #include <map>\r
7 #include <vector>\r
8 #include <shttpd.h>\r
9 \r
10 class IPageHandler\r
11 {\r
12 public:\r
13         IPageHandler()  {}\r
14         IPageHandler(const std::string &templatestr)    { m_template=templatestr; }\r
15         virtual ~IPageHandler() {}\r
16 \r
17         /**\r
18                 \brief Handles request for a page\r
19                 \r
20                 \return true if request was handled, false if it was ignored\r
21         */\r
22         const bool Handle(shttpd_arg *arg);\r
23 \r
24 private:\r
25         void HandlePost(shttpd_arg *arg);\r
26         void HadleGet(shttpd_arg *arg);\r
27         virtual const bool WillHandleURI(const std::string &uri)=0;\r
28         virtual const std::string GeneratePage(const std::string &method, const std::map<std::string,std::string> &queryvars)=0;\r
29         \r
30 protected:\r
31         // converts from basename[#] query args into a vector where the vector pos is the index pos #\r
32         void CreateArgArray(const std::map<std::string,std::string> &vars, const std::string &basename, std::vector<std::string> &args);\r
33 \r
34         std::string m_template;\r
35 \r
36 };\r
37 \r
38 #endif  // _ipagehandler_\r