roar
Loading...
Searching...
No Matches
instance.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <curl/curl.h>
4
5#include <memory>
6#include <stdexcept>
7
8namespace Roar::Curl
9{
11 {
12 public:
14 : instance_{
15 curl_easy_init(),
16 [](CURL* instance) {
17 if (instance)
18 curl_easy_cleanup(instance);
19 },
20 }
21 {
22 if (instance_ == nullptr)
23 throw std::runtime_error("initializing a curl instance failed.");
24 }
25 operator CURL*() const
26 {
27 return instance_.get();
28 }
29 CURL* get() const
30 {
31 return instance_.get();
32 }
33
34 private:
35 std::shared_ptr<CURL> instance_;
36 };
37}
Definition instance.hpp:11
CURL * get() const
Definition instance.hpp:29
std::shared_ptr< CURL > instance_
Definition instance.hpp:35
Instance()
Definition instance.hpp:13
Definition curl_error.hpp:9