Add moveability
This commit is contained in:
parent
b798539502
commit
5c53dc88e7
@ -3,6 +3,7 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <cstring>
|
#include <cstring>
|
||||||
#include <stdexcept>
|
#include <stdexcept>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
using namespace sc;
|
using namespace sc;
|
||||||
|
|
||||||
@ -26,6 +27,21 @@ requester::~requester() {
|
|||||||
curl_global_cleanup();
|
curl_global_cleanup();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
requester::requester(requester&& other) :
|
||||||
|
_h {std::move(other._h)}, _logger {other._logger}, _text {std::move(other._text)}
|
||||||
|
{
|
||||||
|
other._h = nullptr;
|
||||||
|
other._logger = nullptr;
|
||||||
|
other._text = "";
|
||||||
|
}
|
||||||
|
|
||||||
|
requester& requester::operator=(requester&& other) {
|
||||||
|
std::swap(_h, other._h);
|
||||||
|
std::swap(_logger, other._logger);
|
||||||
|
std::swap(_text, other._text);
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
std::string requester::get(const std::string &url) {
|
std::string requester::get(const std::string &url) {
|
||||||
_text = "";
|
_text = "";
|
||||||
curl_easy_setopt(_h.get(), CURLOPT_URL, url.c_str());
|
curl_easy_setopt(_h.get(), CURLOPT_URL, url.c_str());
|
||||||
|
@ -17,11 +17,13 @@ namespace sc {
|
|||||||
requester();
|
requester();
|
||||||
~requester();
|
~requester();
|
||||||
|
|
||||||
// forbid copying and moving
|
// forbid copying
|
||||||
requester(const requester&) = delete;
|
requester(const requester&) = delete;
|
||||||
requester& operator=(const requester&) = delete;
|
requester& operator=(const requester&) = delete;
|
||||||
requester(requester&&) = delete;
|
|
||||||
requester& operator=(requester&&) = delete;
|
// allow move
|
||||||
|
requester(requester&&);
|
||||||
|
requester& operator=(requester&&);
|
||||||
|
|
||||||
// optional logger
|
// optional logger
|
||||||
void logger(sc::logger* logger) { _logger = logger; }
|
void logger(sc::logger* logger) { _logger = logger; }
|
||||||
|
Loading…
x
Reference in New Issue
Block a user