be707e5791ce47bbcc6cc678edc31de7cdf70a87
[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         virtual const bool WillHandleURI(const std::string &uri)=0;\r
26         virtual const std::string GeneratePage(const std::string &method, const std::map<std::string,std::string> &queryvars)=0;\r
27         \r
28 protected:\r
29         // converts from basename[#] query args into a vector where the vector pos is the index pos #\r
30         void CreateArgArray(const std::map<std::string,std::string> &vars, const std::string &basename, std::vector<std::string> &args);\r
31 \r
32         // replaces html control characters with elements (i.e. < becomes &lt;)\r
33         const std::string SanitizeOutput(const std::string &input);\r
34 \r
35         std::string m_template;\r
36 \r
37 };\r
38 \r
39 #endif  // _ipagehandler_\r