libmoost
|
00001 /* vim:set ts=3 sw=3 sts=3 et: */ 00037 #ifndef FM_LAST_MOOST_MURCL_URI_PARAMS_HPP__ 00038 #define FM_LAST_MOOST_MURCL_URI_PARAMS_HPP__ 00039 00040 #include <string> 00041 #include <sstream> 00042 #include <map> 00043 00044 #include <curl/curl.h> 00045 00046 #include <boost/lexical_cast.hpp> 00047 00048 #include "uri_encoder.hpp" 00049 00050 namespace moost { namespace murcl { 00051 00055 class uri_params 00056 { 00057 public: 00058 typedef std::map<std::string, std::string> map_t; 00059 00066 uri_params(map_t const & map) 00067 { 00068 std::ostringstream oss; 00069 00070 for(map_t::const_iterator itr = map.begin(); itr != map.end(); ++itr) 00071 { 00072 if(itr != map.begin()) 00073 { 00074 oss << '&'; 00075 } 00076 00077 oss 00078 << uri_encoder::encode(itr->first) // key 00079 << '=' 00080 << uri_encoder::encode(itr->second); // val 00081 } 00082 00083 params_ = oss.str(); 00084 } 00085 00092 std::string const & get() const 00093 { 00094 return params_; 00095 } 00096 00103 operator std::string const & () const 00104 { 00105 return get(); 00106 } 00107 00108 private: 00109 std::string params_; 00110 }; 00111 00112 }} 00113 00114 00115 #endif // FM_LAST_MOOST_MURCL_URI_PARAMS_HPP__