Introduce version 0.1
[dueringa_WikiWalker.git] / src / CurlUrlCreator.h
blob511475ee166df030cc464505ef20144a3a5e109f
1 //! \file CurlUrlCreator.h
3 #ifndef _CURLURLCREATOR_H
4 #define _CURLURLCREATOR_H
6 #include <string>
7 #include <unordered_map>
8 #include <curl/curl.h>
10 /*! Creates GET URLs with parameters.
11 * With the help of curl
13 class CurlUrlCreator
15 public:
16 //! Create a new instance, given a base URL
17 CurlUrlCreator(std::string baseUrl);
19 //! delete copy constructor, because of CURL handle
20 CurlUrlCreator(const CurlUrlCreator&) = delete;
22 //! delete copy assignment, because of CURL handle
23 CurlUrlCreator& operator=(const CurlUrlCreator&) = delete;
25 /*! Add GET parameters to URL.
26 * If parameter keys are specified multiple times, later occurrences
27 * overwrite earlier ones.
28 * \param param the parameter name
29 * \param value the parameter value - UNESCAPED!
30 * This will be done by curl. If you already escape
31 * it will be double-escaped.
32 * \return reference to self, so method chaining is possible.
34 CurlUrlCreator& addParameter(std::string param, std::string value);
36 //! Reset parameters
37 void reset();
39 /*! Creates the URL
40 * \return Complete GET URL.
42 std::string buildUrl() const;
44 ~CurlUrlCreator();
46 private:
47 std::string _baseUrl;
48 std::unordered_map<std::string, std::string> args;
49 CURL* handle;
53 #endif /* _CURLURLCREATOR_H */