crawlserv++
[under development]
Application for crawling and analyzing textual content of websites.
|
RAII wrapper for lists used by the libcurl
API.
More...
#include <CurlList.hpp>
Construction and Destruction | |
CurlList ()=default | |
Default constructor. More... | |
virtual | ~CurlList () |
Destructor resetting the list if necessary. More... | |
Getters | |
curl_slist * | get () noexcept |
Gets a pointer to the underlying list. More... | |
const curl_slist * | getc () const noexcept |
Gets a const pointer to the underlying list. More... | |
bool | valid () const noexcept |
Checks whether the underlying list is valid. More... | |
std::size_t | size () const noexcept |
Gets the current number of elements in the list. More... | |
bool | empty () const noexcept |
Checks whether the list is empty. More... | |
Manipulation and Cleanup | |
void | append (const CurlList &other) |
Appends another list to the list. More... | |
void | append (const std::vector< std::string > &newElements) |
Appends the elements of a vector to the list. More... | |
void | append (const std::string &newElement) |
Appends an element to the list. More... | |
void | clear () noexcept |
Resets the list and frees its memory. More... | |
Copy and Move | |
CurlList (const CurlList &other) | |
Copy constructor. More... | |
CurlList & | operator= (const CurlList &other) |
Copy assignment operator. More... | |
CurlList (CurlList &&other) noexcept | |
Move constructor. More... | |
CurlList & | operator= (CurlList &&other) noexcept |
Move assignment operator. More... | |
RAII wrapper for lists used by the libcurl
API.
Sets the list to nullptr
on construction and automatically clears it on destruction, avoiding memory leaks.
At the moment, this class is used exclusively by Network::Curl.
For more information about the libcurl
API, see its website.
|
default |
Default constructor.
|
inlinevirtual |
Destructor resetting the list if necessary.
References clear().
|
inline |
Copy constructor.
Creates a new list and copies all elements of the given list into it.
other | The list to copy from. |
std::runtime_error | if the new list could not be created or any of the elements could not be appended to it. |
References append().
|
inlinenoexcept |
Move constructor.
Moves the list from the specified location into this instance of the class.
other | The list to move from. |
|
inline |
Appends another list to the list.
other | A const reference to the list which elements should be appended. |
std::runtime_error | if appending to the list failed. |
Referenced by append(), CurlList(), operator=(), crawlservpp::Network::Curl::setConfigGlobal(), and crawlservpp::Network::Curl::setHeaders().
|
inline |
Appends the elements of a vector to the list.
newElements | A const reference to the vector of strings that should be appended to the list. |
std::runtime_error | if appending to the list failed. |
References append().
|
inline |
Appends an element to the list.
A new list will be created if no list already exists.
newElement | A const reference to a string that should be appended at the end of the list. |
std::runtime_error | if the element could not be appended by the underlying API. |
|
inlinenoexcept |
Resets the list and frees its memory.
The list will be invalid and valid() will return false afterwards.
Referenced by operator=(), crawlservpp::Network::Curl::resetConnection(), crawlservpp::Network::Curl::setHeaders(), crawlservpp::Network::Curl::unsetHeaders(), and ~CurlList().
|
inlinenoexcept |
Checks whether the list is empty.
|
inlinenoexcept |
Gets a pointer to the underlying list.
libcurl
list or nullptr
if no list has been created or the list has already been resetted. Referenced by crawlservpp::Network::Curl::writerInClass().
|
inlinenoexcept |
Gets a const pointer to the underlying list.
libcurl
list or nullptr
if no list has been created or the list has already been resetted. Copy assignment operator.
Clears the existing list, creates a new one and copies all elements of the given list into it.
other | The buffer to copy from. |
*this
).std::runtime_error | if the new list could not be created or any of the elements could not be appended to it. |
Move assignment operator.
Moves the list from the specified location into this instance of the class.
other | The list to move from. |
*this
).References clear().
|
inlinenoexcept |
Gets the current number of elements in the list.
|
inlinenoexcept |
Checks whether the underlying list is valid.