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