Rename some functions and classes to make more sense
This commit is contained in:
parent
fb14afe8d9
commit
3f9171737c
@ -78,19 +78,19 @@ namespace rcw{
|
|||||||
void reset(void);
|
void reset(void);
|
||||||
response perform(void);
|
response perform(void);
|
||||||
|
|
||||||
string escape_to_str(const char* data, int len = 0);
|
string escape(const char* data, int len = 0);
|
||||||
string escape_to_str(const rexy::string_base<char>& data);
|
string escape(const rexy::string_base<char>& data);
|
||||||
std::string escape_to_std(const char* data, int len = 0);
|
std::string escape_to_std(const char* data, int len = 0);
|
||||||
std::string escape_to_std(const rexy::string_base<char>& data);
|
std::string escape_to_std(const rexy::string_base<char>& data);
|
||||||
char* escape_to_cstr(const char* data, int* outlen, int len = 0);
|
char* escape_to_cstr(const char* data, int* outlen, int len = 0);
|
||||||
char* escape_to_cstr(const rexy::string_base<char>& data, int* outlen);
|
char* escape_to_cstr(const rexy::string_base<char>& data, int* outlen);
|
||||||
|
|
||||||
std::string decode_to_std(const char* data, int len = 0);
|
std::string unescape_to_std(const char* data, int len = 0);
|
||||||
std::string decode_to_std(const rexy::string_base<char>& data);
|
std::string unescape_to_std(const rexy::string_base<char>& data);
|
||||||
string decode_to_str(const char* data, int len = 0);
|
string unescape(const char* data, int len = 0);
|
||||||
string decode_to_str(const rexy::string_base<char>& data);
|
string unescape(const rexy::string_base<char>& data);
|
||||||
char* decode_to_cstr(const char* data, int* outlen, int len = 0);
|
char* unescape_to_cstr(const char* data, int* outlen, int len = 0);
|
||||||
char* decode_to_cstr(const rexy::string_base<char>& data, int* outlen);
|
char* unescape_to_cstr(const rexy::string_base<char>& data, int* outlen);
|
||||||
|
|
||||||
long get_last_status(void)const;
|
long get_last_status(void)const;
|
||||||
CURL* get(void);
|
CURL* get(void);
|
||||||
|
|||||||
@ -22,17 +22,17 @@
|
|||||||
namespace rcw{
|
namespace rcw{
|
||||||
|
|
||||||
//class representing http status codes where 200-299 is valid and 300+ is invalid
|
//class representing http status codes where 200-299 is valid and 300+ is invalid
|
||||||
class http_status
|
class httpint
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
long m_code = 200;
|
long m_code = 200;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
http_status(void) = default;
|
httpint(void) = default;
|
||||||
http_status(long x);
|
httpint(long x);
|
||||||
http_status(const http_status&) = default;
|
httpint(const httpint&) = default;
|
||||||
http_status& operator=(const http_status&) = default;
|
httpint& operator=(const httpint&) = default;
|
||||||
http_status& operator=(long x);
|
httpint& operator=(long x);
|
||||||
|
|
||||||
bool ok(void)const;
|
bool ok(void)const;
|
||||||
operator long(void)const;
|
operator long(void)const;
|
||||||
|
|||||||
@ -21,13 +21,13 @@
|
|||||||
|
|
||||||
#define RCW_VERSION @librcw_VERSION_STRING@
|
#define RCW_VERSION @librcw_VERSION_STRING@
|
||||||
|
|
||||||
#include <sync.hpp>
|
#include <rcw/sync.hpp>
|
||||||
#include <async.hpp>
|
#include <rcw/async.hpp>
|
||||||
#include <response.hpp>
|
#include <rcw/response.hpp>
|
||||||
#include <curl_easy_handle.hpp>
|
#include <rcw/curl_easy_handle.hpp>
|
||||||
#include <curl_header_list.hpp>
|
#include <rcw/curl_header_list.hpp>
|
||||||
#include <httpint.hpp>
|
#include <rcw/httpint.hpp>
|
||||||
#include <string.hpp>
|
#include <rcw/string.hpp>
|
||||||
#include <types.hpp>
|
#include <rcw/types.hpp>
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -27,7 +27,7 @@ namespace rcw{
|
|||||||
class response
|
class response
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
http_status status;
|
httpint status;
|
||||||
size_t elapsed_time_us; //CURLINFO_TOTAL_TIME_T
|
size_t elapsed_time_us; //CURLINFO_TOTAL_TIME_T
|
||||||
size_t uploaded_bytes; //CURLINFO_SIZE_UPLOAD_T
|
size_t uploaded_bytes; //CURLINFO_SIZE_UPLOAD_T
|
||||||
size_t downloaded_bytes; //CURLINFO_SIZE_DOWNLOAD_T
|
size_t downloaded_bytes; //CURLINFO_SIZE_DOWNLOAD_T
|
||||||
|
|||||||
@ -162,25 +162,25 @@ namespace rcw{
|
|||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string curl_easy_handle::decode_to_std(const char* data, int len){
|
std::string curl_easy_handle::unescape_to_std(const char* data, int len){
|
||||||
char* tmp = decode_to_cstr(data, &len, len);
|
char* tmp = unescape_to_cstr(data, &len, len);
|
||||||
std::string ret(tmp, len);
|
std::string ret(tmp, len);
|
||||||
curl_free(tmp);
|
curl_free(tmp);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
char* curl_easy_handle::decode_to_cstr(const char* data, int* outlen, int len){
|
char* curl_easy_handle::unescape_to_cstr(const char* data, int* outlen, int len){
|
||||||
if(!len)
|
if(!len)
|
||||||
len = strlen(data);
|
len = strlen(data);
|
||||||
char* tmp = curl_easy_unescape(m_curl, data, len, outlen);
|
char* tmp = curl_easy_unescape(m_curl, data, len, outlen);
|
||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
string curl_easy_handle::escape_to_str(const char* data, int len){
|
string curl_easy_handle::escape(const char* data, int len){
|
||||||
char* tmp = escape_to_cstr(data, &len, len);
|
char* tmp = escape_to_cstr(data, &len, len);
|
||||||
return string(rexy::steal(tmp), len, len);
|
return string(rexy::steal(tmp), len, len);
|
||||||
}
|
}
|
||||||
string curl_easy_handle::escape_to_str(const rexy::string_base<char>& data){
|
string curl_easy_handle::escape(const rexy::string_base<char>& data){
|
||||||
return escape_to_str(data.get(), data.length());
|
return escape(data.get(), data.length());
|
||||||
}
|
}
|
||||||
std::string curl_easy_handle::escape_to_std(const rexy::string_base<char>& data){
|
std::string curl_easy_handle::escape_to_std(const rexy::string_base<char>& data){
|
||||||
return escape_to_std(data.get(), data.length());
|
return escape_to_std(data.get(), data.length());
|
||||||
@ -189,17 +189,17 @@ namespace rcw{
|
|||||||
return escape_to_cstr(data.get(), outlen, data.length());
|
return escape_to_cstr(data.get(), outlen, data.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
string curl_easy_handle::decode_to_str(const char* data, int len){
|
string curl_easy_handle::unescape(const char* data, int len){
|
||||||
char* tmp = decode_to_cstr(data, &len, len);
|
char* tmp = unescape_to_cstr(data, &len, len);
|
||||||
return string(rexy::steal(tmp), len, len);
|
return string(rexy::steal(tmp), len, len);
|
||||||
}
|
}
|
||||||
string curl_easy_handle::decode_to_str(const rexy::string_base<char>& data){
|
string curl_easy_handle::unescape(const rexy::string_base<char>& data){
|
||||||
return decode_to_str(data.get(), data.length());
|
return unescape(data.get(), data.length());
|
||||||
}
|
}
|
||||||
std::string curl_easy_handle::decode_to_std(const rexy::string_base<char>& data){
|
std::string curl_easy_handle::unescape_to_std(const rexy::string_base<char>& data){
|
||||||
return decode_to_std(data.get(), data.length());
|
return unescape_to_std(data.get(), data.length());
|
||||||
}
|
}
|
||||||
char* curl_easy_handle::decode_to_cstr(const rexy::string_base<char>& data, int* outlen){
|
char* curl_easy_handle::unescape_to_cstr(const rexy::string_base<char>& data, int* outlen){
|
||||||
return escape_to_cstr(data.get(), outlen, data.length());
|
return escape_to_cstr(data.get(), outlen, data.length());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -20,20 +20,20 @@
|
|||||||
|
|
||||||
namespace rcw{
|
namespace rcw{
|
||||||
|
|
||||||
http_status::http_status(long x):
|
httpint::httpint(long x):
|
||||||
m_code(x){}
|
m_code(x){}
|
||||||
http_status& http_status::operator=(long x){
|
httpint& httpint::operator=(long x){
|
||||||
m_code = x;
|
m_code = x;
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool http_status::ok(void)const{
|
bool httpint::ok(void)const{
|
||||||
return (m_code >= 200 && m_code < 300);
|
return (m_code >= 200 && m_code < 300);
|
||||||
}
|
}
|
||||||
http_status::operator long(void)const{
|
httpint::operator long(void)const{
|
||||||
return m_code;
|
return m_code;
|
||||||
}
|
}
|
||||||
long http_status::get(void)const{
|
long httpint::get(void)const{
|
||||||
return m_code;
|
return m_code;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user