|
crawlserv++
[under development]
Application for crawling and analyzing textual content of websites.
|
RAII wrapper for handles of the libcurl API.
More...
#include <Curl.hpp>
Construction and Destruction | |
| Curl () | |
Constructor initializing the libcurl API locally and globally, if necessary. More... | |
| virtual | ~Curl () |
Destructor cleaning up the libcurl API locally and globally, if necessary. More... | |
Getters | |
| CURL * | get () noexcept |
Gets a pointer to the underlying libcurl handle. More... | |
| CURL ** | getPtr () noexcept |
Gets a pointer to the pointer containing the address of the underlying libcurl handle. More... | |
| bool | valid () const noexcept |
Checks whether the underlying libcurl handle is valid. More... | |
Initialization and Cleanup | |
| void | init () |
Initializes the underlying libcurl handle. More... | |
| void | clear () noexcept |
Clears the underlying libcurl handle. More... | |
Copy and Move | |
| Curl (Curl &)=delete | |
| Deleted copy constructor. More... | |
| Curl & | operator= (Curl &)=delete |
| Deleted copy assignment operator. More... | |
| Curl (Curl &&other) noexcept | |
| Move constructor. More... | |
| Curl & | operator= (Curl &&other) noexcept |
| Move assignment operator. More... | |
RAII wrapper for handles of the libcurl API.
Initializes the libcurl API locally and globally, if still necessary. Automatically resets the API 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.
|
inline |
Constructor initializing the libcurl API locally and globally, if necessary.
| std::runtime_error | if the initialization of the API failed. |
References init().
|
inlinevirtual |
Destructor cleaning up the libcurl API locally and globally, if necessary.
Also globally deinitializes the libcurl API if it was initialized during construction or the reponsibility for it received during move assignment.
References clear().
|
delete |
Deleted copy constructor.
|
inlinenoexcept |
Move constructor.
Moves the libcurl handle from the specified location into this instance of the class.
| other | The libcurl handle to move from. |
|
inlinenoexcept |
Clears the underlying libcurl handle.
If the handle is not initialized, the function will have no effect.
libcurl API, which will only be released on destruction or the responsibility for it transferred away during move assignment.Referenced by init(), operator=(), crawlservpp::Network::Curl::resetConnection(), and ~Curl().
|
inlinenoexcept |
Gets a pointer to the underlying libcurl handle.
libcurl handle or nullptr if the initialization failed or the handle has already been cleared. Referenced by crawlservpp::Network::Curl::Curl(), crawlservpp::Network::Curl::escape(), crawlservpp::Network::Curl::escapeUrl(), crawlservpp::Network::Curl::getContent(), crawlservpp::Network::Downloader::getError(), crawlservpp::Network::Curl::resetConnection(), crawlservpp::Network::Curl::unescape(), crawlservpp::Network::FTPUpload::write(), and crawlservpp::Network::Curl::writerInClass().
|
inlinenoexcept |
Gets a pointer to the pointer containing the address of the underlying libcurl handle.
libcurl handle or a pointer to a pointer containing nullptr if the initialization failed or the handle has already been cleared.
|
inline |
Initializes the underlying libcurl handle.
If the underlying handle is already initialized, it will be cleared.
References clear().
Referenced by Curl(), and crawlservpp::Network::Curl::resetConnection().
Move assignment operator.
Moves the libcurl handle from the specified location into this instance of the class.
The responsibility to clear the libcurl API globally will be kept in this instance or transferred from the other instance if necessary.
| other | The libcurl handle to move from. |
libcurl handle after moving (i.e. *this).References clear().
|
inlinenoexcept |
Checks whether the underlying libcurl handle is valid.
Referenced by crawlservpp::Network::Curl::Curl(), crawlservpp::Network::Curl::escape(), crawlservpp::Network::Curl::escapeUrl(), crawlservpp::Network::Downloader::getError(), crawlservpp::Network::Curl::setConfigGlobal(), crawlservpp::Network::Curl::unescape(), and crawlservpp::Network::FTPUpload::write().