curl-cpp
static c++17 wrapper for curl with -fno-exceptions support
Classes | Public Types | Public Member Functions | Protected Attributes | List of all members
curl::utils::slist Class Reference

#include <curl_slist.hpp>

Collaboration diagram for curl::utils::slist:
Collaboration graph

Classes

struct  const_iterator
 

Public Types

using value_type = const char *
 
using size_type = std::size_t
 
using difference_type = std::ptrdiff_t
 
using reference = value_type &
 
using const_reference = const value_type &
 
using pointer = value_type *
 
using const_pointer = const value_type *
 

Public Member Functions

 slist (void *l) noexcept
 
 slist (const slist &)=delete
 
 slist (slist &&other) noexcept
 
slistoperator= (const slist &)=delete
 
slistoperator= (slist &&other) noexcept
 
void swap (slist &other) noexcept
 
void clear () noexcept
 
bool is_empty () const noexcept
 
auto begin () const noexcept -> const_iterator
 
auto end () const noexcept -> const_iterator
 
auto cbegin () const noexcept -> const_iterator
 
auto cend () const noexcept -> const_iterator
 
auto get_underlying_ptr () const noexcept -> void *
 
auto push_back (const char *str) noexcept -> Ret_except< void, std::bad_alloc >
 

Protected Attributes

void * list = nullptr
 

Detailed Description

Container wrapper for curl's struct curl_slist, which is a single-linked list storing string.

Thread-safety:

Definition at line 21 of file curl_slist.hpp.

Member Function Documentation

◆ clear()

void curl::utils::slist::clear ( )
noexcept

Free all elements stored in the slist and the slist itself.

Set protected member slist::list to nullptr.

Definition at line 26 of file curl_slist.cc.

27 {
28  if (list)
29  curl_slist_free_all(static_cast<struct curl_slist*>(list));
30  list = nullptr;
31 }

◆ get_underlying_ptr()

auto curl::utils::slist::get_underlying_ptr ( ) const -> void*
noexcept

Get underlying struct curl_slist* pointer.

Definition at line 81 of file curl_slist.cc.

82 {
83  return list;
84 }
Here is the caller graph for this function:

◆ push_back()

auto curl::utils::slist::push_back ( const char *  str) -> Ret_except<void, std::bad_alloc>
noexcept
Parameters
stris dupped before adding to the list. Must not be CRLF-terminated for use in curl::Easy_ref_t::set_http_header.

Definition at line 91 of file curl_slist.cc.

92 {
93  auto temp = curl_slist_append(static_cast<struct curl_slist*>(list), str);
94  if (!temp)
95  return {std::bad_alloc{}};
96 
97  list = temp;
98 
99  return {};
100 }

The documentation for this class was generated from the following files: