41 lines
889 B
C++
41 lines
889 B
C++
//
|
|
// requester.hpp
|
|
// curly
|
|
//
|
|
// Created by Bob Polis at 2020-09-01
|
|
// Copyright (c) 2020 SwiftCoder. All rights reserved.
|
|
//
|
|
|
|
#ifndef _requester_H_
|
|
#define _requester_H_
|
|
|
|
#include <string>
|
|
#include <curl/curl.h>
|
|
|
|
class requester {
|
|
public:
|
|
// callback for data receiving
|
|
static size_t write_data(char* buf, size_t sz, size_t nmemb, void* user_data);
|
|
|
|
// this class is a RAII class for a curl handle
|
|
requester();
|
|
|
|
// forbid copying
|
|
requester(const requester& other) = delete;
|
|
requester& operator=(const requester& other) = delete;
|
|
|
|
// allow moving
|
|
requester(requester&& other);
|
|
requester& operator=(requester&& other);
|
|
|
|
// cleanup
|
|
~requester();
|
|
|
|
std::string get(const std::string& url);
|
|
|
|
private:
|
|
CURL* _h {nullptr}; // curl handle
|
|
};
|
|
|
|
#endif // _requester_H_
|