constness must also occur in header file
[dueringa_WikiWalker.git] / src / CurlUrlCreator.cpp
blobd209b8871686528635a64408a7cf4f3798419115
1 //! \file CurlUrlCreator.cpp
3 #include "CurlUrlCreator.h"
5 CurlUrlCreator::CurlUrlCreator(std::string baseUrl)
6 : _baseUrl(baseUrl)
8 curl_global_init(CURL_GLOBAL_ALL);
9 handle = curl_easy_init();
12 CurlUrlCreator::~CurlUrlCreator()
14 curl_easy_cleanup(handle);
15 curl_global_cleanup();
18 CurlUrlCreator& CurlUrlCreator::addParameter(std::string param, std::string value)
20 // overwrite
21 char* eval = curl_easy_escape(handle, value.c_str(), 0);
22 args[param] = eval;
23 curl_free(eval);
24 return *this;
27 std::string CurlUrlCreator::buildUrl() const
29 std::string ret = _baseUrl;
30 ret.append("?");
32 for(auto parpair : args) {
33 ret.append(parpair.first).append("=").append(parpair.second).append("&");
36 ret.pop_back();
38 return ret;
41 void CurlUrlCreator::reset()
43 args.clear();