CurlHandle.cpp 390 B

12345678910111213141516171819
  1. #include "CurlHandle.h"
  2. #include <curl/curl.h>
  3. #include <stdexcept>
  4. CurlHandle::CurlHandle() {
  5. const auto eCode = curl_global_init(CURL_GLOBAL_ALL);
  6. if (eCode != CURLE_OK) {
  7. throw std::runtime_error{"Error initializing libCURL"};
  8. }
  9. }
  10. CurlHandle::~CurlHandle() { curl_global_cleanup(); }
  11. CurlHandle &CurlHandle::instance() {
  12. static CurlHandle inst{};
  13. return inst;
  14. }