-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFetch.h
49 lines (39 loc) · 990 Bytes
/
Fetch.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
//
// Copyright (c) 2018 James A. Chappell
#ifndef STORAGE_B_FETCH_H__
#define STORAGE_B_FETCH_H__
#include <memory>
#include <string>
#include "Curl.h"
namespace Storage_B
{
namespace Curlpp
{
class Fetch
{
public:
Fetch(const char *url = nullptr);
long operator()(std::string& result,
CURLoption option = CURLOPT_WRITEDATA) const
{
return fetch(option, result);
}
long operator()(const std::string& url, std::string& result,
CURLoption option = CURLOPT_WRITEDATA)
{
Url(url);
return fetch(option, result);
}
void Url(const std::string& url)
{
curl_->Url(url);
}
private:
long fetch(CURLoption option, std::string& result) const;
static size_t read_result(void *buffer, size_t size, size_t nmemb,
void *stream);
std::unique_ptr<Curl> curl_;
};
}
}
#endif