32 #ifndef WRAPPER_CURLLIST_HPP_ 33 #define WRAPPER_CURLLIST_HPP_ 35 #ifndef CRAWLSERVPP_TESTING 37 #include <curl/curl.h> 41 #include "FakeCurl/FakeCurl.hpp" 89 [[nodiscard]] curl_slist *
get() noexcept;
90 [[nodiscard]]
const curl_slist *
getc()
const noexcept;
91 [[nodiscard]]
bool valid()
const noexcept;
92 [[nodiscard]] std::size_t
size()
const noexcept;
93 [[nodiscard]]
bool empty()
const noexcept;
100 void append(
const std::vector<std::string>& newElements);
101 void append(
const std::string& newElement);
102 void clear() noexcept;
119 curl_slist * ptr{
nullptr};
169 return this->ptr !=
nullptr;
182 const auto * element{this->ptr};
184 while(element !=
nullptr) {
185 if(element->data !=
nullptr) {
189 element = element->next;
203 const auto * element{this->ptr};
205 while(element !=
nullptr) {
206 if(element->data !=
nullptr) {
235 auto * item = other.ptr;
237 while(item !=
nullptr) {
254 for(
const auto& element : newElements) {
277 curl_slist_append(this->ptr, newElement.c_str())
280 if(temp ==
nullptr) {
281 throw std::runtime_error(
"curl_slist_append() failed");
298 if(this->ptr !=
nullptr) {
299 curl_slist_free_all(this->ptr);
399 this->ptr = other.ptr;
curl_slist * get() noexcept
Gets a pointer to the underlying list.
Definition: CurlList.hpp:146
virtual ~CurlList()
Destructor resetting the list if necessary.
Definition: CurlList.hpp:131
RAII wrapper for lists used by the libcurl API.
Definition: CurlList.hpp:75
CurlList()=default
Default constructor.
void append(const CurlList &other)
Appends another list to the list.
Definition: CurlList.hpp:230
bool empty() const noexcept
Checks whether the list is empty.
Definition: CurlList.hpp:202
std::size_t size() const noexcept
Gets the current number of elements in the list.
Definition: CurlList.hpp:180
Namespace for RAII wrappers and Wrapper::Database.
Definition: Database.hpp:109
CurlList & operator=(const CurlList &other)
Copy assignment operator.
Definition: CurlList.hpp:348
bool valid() const noexcept
Checks whether the underlying list is valid.
Definition: CurlList.hpp:168
const curl_slist * getc() const noexcept
Gets a const pointer to the underlying list.
Definition: CurlList.hpp:158
void clear() noexcept
Resets the list and frees its memory.
Definition: CurlList.hpp:297