/** 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 . */ #ifndef RAII_CURL_LLIST_HPP #define RAII_CURL_LLIST_HPP #include #include //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 curl_llist(Args&&... args){ assign(std::forward(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 void assign(T&& t, Args&&... args){ (*this) += std::forward(t); if constexpr(sizeof...(args) > 0){ assign(std::forward(args)...); } } }; } #endif