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

Classes

struct  curl_string_deleter
 

Public Types

enum  set_code { ok, set_code::malform_input, bad_port_number, unsupported_scheme }
 
enum  get_code {
  no_scheme, no_user, no_passwd, no_options,
  no_host, no_port, no_query, no_fragment
}
 
using string = std::unique_ptr< char, curl_string_deleter >
 

Public Member Functions

auto set_url (const char *url_arg) noexcept -> Ret_except< set_code, std::bad_alloc >
 
auto set_scheme (const char *scheme) noexcept -> Ret_except< set_code, std::bad_alloc >
 
auto set_options (const char *options) noexcept -> Ret_except< set_code, std::bad_alloc >
 
auto set_query (const char *query) noexcept -> Ret_except< set_code, std::bad_alloc >
 
auto get_url () const noexcept -> Ret_except< string, get_code, std::bad_alloc >
 
auto get_scheme () const noexcept -> Ret_except< string, get_code, std::bad_alloc >
 
auto get_options () const noexcept -> Ret_except< string, get_code, std::bad_alloc >
 
auto get_query () const noexcept -> Ret_except< string, get_code, std::bad_alloc >
 

Public Attributes

char * url
 

Static Protected Member Functions

static void check_url (int code)
 

Detailed Description

Examples
curl_easy_get.cc, and curl_url.cc.

Definition at line 24 of file curl_url.hpp.

Member Typedef Documentation

◆ string

using curl::Url_ref_t::string = std::unique_ptr<char, curl_string_deleter>

std::unique_ptr for any libcurl-returned string that requires deallocation.

Definition at line 78 of file curl_url.hpp.

Member Enumeration Documentation

◆ set_code

Enumerator
malform_input 

For url, it could be:

  • url is longer than 8000000 bytes (7MiB)
  • scheme too long (newest libcurl support up to 40 bytes)
  • url does not match standard syntax
  • lack necessary part, e.g. scheme, host
  • contain junk character <= 0x1f || == 0x7f

Definition at line 35 of file curl_url.hpp.

35  {
36  ok,
45  malform_input,
46  bad_port_number,
47  unsupported_scheme,
48  };

◆ get_code

get_code::no_* can be returned by respective get_*() function.

Definition at line 83 of file curl_url.hpp.

83  {
84  no_scheme,
85  no_user,
86  no_passwd,
87  no_options,
88  no_host,
89  no_port,
90  no_query,
91  no_fragment,
92  };

Member Function Documentation

◆ set_url()

auto curl::Url_ref_t::set_url ( const char *  url_arg) -> Ret_except<set_code, std::bad_alloc>
noexcept
Returns
all of set_code

Definition at line 49 of file curl_url.cc.

50 {
51  return curl_urlset_wrapper(url, CURLUPART_URL, url_arg);
52 }

◆ set_scheme()

auto curl::Url_ref_t::set_scheme ( const char *  scheme) -> Ret_except<set_code, std::bad_alloc>
noexcept
Returns
only set_code::unsupported_scheme, malform_input, ok

Definition at line 53 of file curl_url.cc.

54 {
55  return curl_urlset_wrapper(url, CURLUPART_SCHEME, scheme);
56 }

◆ set_options()

auto curl::Url_ref_t::set_options ( const char *  options) -> Ret_except<set_code, std::bad_alloc>
noexcept
Returns
only set_code::malform_input, ok

Definition at line 57 of file curl_url.cc.

58 {
59  return curl_urlset_wrapper(url, CURLUPART_OPTIONS, options);
60 }

◆ set_query()

auto curl::Url_ref_t::set_query ( const char *  query) -> Ret_except<set_code, std::bad_alloc>
noexcept
Returns
only set_code::malform_input, ok

Definition at line 61 of file curl_url.cc.

62 {
63  return curl_urlset_wrapper(url, CURLUPART_QUERY, query);
64 }

◆ get_url()

auto curl::Url_ref_t::get_url ( ) const -> Ret_except<string, get_code, std::bad_alloc>
noexcept
Returns
no_scheme or no_host

Definition at line 104 of file curl_url.cc.

105 {
106  return curl_urlget_wrapper(url, CURLUPART_URL);
107 }

Member Data Documentation

◆ url

char* curl::Url_ref_t::url

If url == nullptr, then calling any member function has undefined behavior.

Definition at line 33 of file curl_url.hpp.


The documentation for this class was generated from the following files:
curl::Url_ref_t::url
char * url
Definition: curl_url.hpp:33