68 lines
1.7 KiB
C++
68 lines
1.7 KiB
C++
/**
|
|
This file is a part of r0nk, atlas_moon, and rexy's matrix client
|
|
Copyright (C) 2019 rexy712
|
|
|
|
This program is free software: you can redistribute it and/or modify
|
|
it under the terms of the GNU Affero General Public License as published by
|
|
the Free Software Foundation, either version 3 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU Affero General Public License for more details.
|
|
|
|
You should have received a copy of the GNU Affero General Public License
|
|
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef RAII_CURL_LLIST_HPP
|
|
#define RAII_CURL_LLIST_HPP
|
|
|
|
#include <curl/curl.h>
|
|
#include <utility> //forward
|
|
|
|
namespace raii{
|
|
//RAII wrapper for curl's slist (singly linked list?)
|
|
class curl_llist
|
|
{
|
|
private:
|
|
curl_slist* m_data = nullptr;
|
|
|
|
public:
|
|
curl_llist(void) = default;
|
|
template<class... Args>
|
|
curl_llist(Args&&... args){
|
|
assign(std::forward<Args>(args)...);
|
|
}
|
|
curl_llist(const curl_llist&) = delete;
|
|
curl_llist(curl_llist&& l)noexcept;
|
|
~curl_llist(void);
|
|
|
|
curl_llist& operator=(const curl_llist&) = delete;
|
|
curl_llist& operator=(curl_llist&& l)noexcept;
|
|
|
|
curl_llist& operator+=(const char* data);
|
|
|
|
operator curl_slist*(void);
|
|
operator const curl_slist*(void)const;
|
|
curl_slist* get(void);
|
|
const curl_slist* get(void)const;
|
|
|
|
void reset(curl_slist* nd = nullptr);
|
|
|
|
private:
|
|
template<class T, class... Args>
|
|
void assign(T&& t, Args&&... args){
|
|
(*this) += std::forward<T>(t);
|
|
if constexpr(sizeof...(args) > 0){
|
|
assign(std::forward<Args>(args)...);
|
|
}
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
#endif
|