2#ifndef _KURLYK_TYPES_TYPE_UTILS_HPP_INCLUDED
3#define _KURLYK_TYPES_TYPE_UTILS_HPP_INCLUDED
12 static const std::vector<std::string> names = {
13 "PROXY_HTTP",
"PROXY_HTTPS",
"PROXY_HTTP_1_0",
14 "PROXY_SOCKS4",
"PROXY_SOCKS4A",
"PROXY_SOCKS5",
"PROXY_SOCKS5_HOSTNAME"
16 return names[
static_cast<size_t>(value)];
21 static const std::vector<std::string> names = {
22 "RL_GENERAL",
"RL_SPECIFIC"
24 return names[
static_cast<size_t>(value)];
29 static const std::vector<std::string> names = {
30 "WS_OPEN",
"WS_MESSAGE",
"WS_CLOSE",
"WS_ERROR"
32 return names[
static_cast<size_t>(value)];
41 static const std::unordered_map<std::string, ProxyType> map = {
51 if (it != map.end())
return it->second;
52 throw std::invalid_argument(
"Invalid ProxyType: " + str);
57 static const std::unordered_map<std::string, RateLimitType> map = {
62 if (it != map.end())
return it->second;
63 throw std::invalid_argument(
"Invalid RateLimitType: " + str);
68 static const std::unordered_map<std::string, WebSocketEventType> map = {
75 if (it != map.end())
return it->second;
76 throw std::invalid_argument(
"Invalid WebSocketEventType: " + str);
93 inline void to_json(nlohmann::json& j,
const ProxyType& value) {
119#if KURLYK_HTTP_SUPPORT
124 inline long to_curl_proxy_type(
ProxyType type) {
125 static const long values[] = {
132 CURLPROXY_SOCKS5_HOSTNAME
134 return values[
static_cast<size_t>(type)];
void to_json(nlohmann::json &j, const ProxyConfig &config)
Serializes ProxyConfig to JSON.
void from_json(const nlohmann::json &j, ProxyConfig &config)
Deserializes ProxyConfig from JSON.
std::string to_upper_case(std::string str)
Converts a string to uppercase.
Primary namespace for the Kurlyk library, encompassing initialization, request management,...
WebSocketEventType to_enum< WebSocketEventType >(const std::string &str)
RateLimitType to_enum< RateLimitType >(const std::string &str)
T to_enum(const std::string &str)
Template specialization to convert string to enum value.
RateLimitType
Defines rate limit scope categories.
@ RL_GENERAL
Applies globally to all requests.
@ RL_SPECIFIC
Applies to specific client/request.
ProxyType
Enumeration of supported proxy types compatible with libcurl.
@ PROXY_SOCKS4A
SOCKS4A proxy.
@ PROXY_SOCKS5_HOSTNAME
SOCKS5 proxy with hostname resolution.
@ PROXY_HTTPS
HTTPS proxy.
@ PROXY_HTTP_1_0
HTTP/1.0 proxy.
@ PROXY_SOCKS4
SOCKS4 proxy.
@ PROXY_SOCKS5
SOCKS5 proxy.
ProxyType to_enum< ProxyType >(const std::string &str)
WebSocketEventType
Types of WebSocket events.
@ WS_ERROR
Error occurred.
@ WS_MESSAGE
Message received.
@ WS_CLOSE
Connection closed.
@ WS_OPEN
Connection established.
const std::string & to_str(ProxyType value) noexcept
Converts a ProxyType enum value to its string representation.
std::ostream & operator<<(std::ostream &os, ProxyType type)