Skip to content

Commit

Permalink
General warning removal to fix #124
Browse files Browse the repository at this point in the history
  • Loading branch information
JosephP91 authored and JosephP91 committed Jun 3, 2020
1 parent 14b3ca1 commit cb42631
Show file tree
Hide file tree
Showing 28 changed files with 126 additions and 90 deletions.
6 changes: 3 additions & 3 deletions include/cookie.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ namespace curl {
*/
class cookie {
public:
/*
/**
* Default constructor.
*/
cookie() {}
cookie() = default;
/**
* The constructor allow a fast way to build a cookie.
* The overloaded constructor allow a fast way to build a cookie.
*/
cookie(const std::string&, const std::string&, const cookie_datetime &,
const std::string& = "", const std::string& = "", bool = false);
Expand Down
4 changes: 2 additions & 2 deletions include/cookie_date.h
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ namespace curl {
// Leave this alone :)
namespace details {
// Map months numbers with months short names (cookies likes it short XD)
static const std::map<int,std::string> months_names = {
static const std::map<int,std::string> monthsNames = {
{JANUARY,"Jan"}, {FEBRUARY,"Feb"}, {MARCH,"Mar"}, {APRIL,"Apr"}, {MAY,"May"}, {JUNE,"Jun"},
{JULY,"Jul"},{AUGUST,"Aug"},{SEPTEMBER,"Sep"},{OCTOBER,"Oct"},{NOVEMBER,"Nov"},{DECEMBER,"Dec"}
};
// Map week days numbers with days short names (cookies likes it, still, short XD)
static const std::map<int,std::string> weekday_names = {
static const std::map<int,std::string> weekdayNames = {
{MONDAY,"Mon"}, {TUESDAY,"Tue"}, {WEDNESDAY,"Wed"}, {THURSDAY,"Thu"}, {FRIDAY,"Fri"}, {SATURDAY,"Sat"},
{SUNDAY,"Sun"}
};
Expand Down
4 changes: 2 additions & 2 deletions include/cookie_datetime.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ namespace curl {
/**
* This method returns the time object.
*/
const cookie_time get_time() const NOEXCEPT;
cookie_time get_time() const NOEXCEPT;
/**
* This method returns the date object.
*/
const cookie_date get_date() const NOEXCEPT;
cookie_date get_date() const NOEXCEPT;
/**
* This method returns the cookie_datetime as a string.
*/
Expand Down
8 changes: 4 additions & 4 deletions include/cookie_time.h
Original file line number Diff line number Diff line change
Expand Up @@ -61,19 +61,19 @@ namespace curl {
/**
* This method returns the hours.
*/
const unsigned int get_hour() const NOEXCEPT;
unsigned int get_hour() const NOEXCEPT;
/**
* This method returns the minutes.
*/
const unsigned int get_minutes() const NOEXCEPT;
unsigned int get_minutes() const NOEXCEPT;
/**
* This method returns the seconds.
*/
const unsigned int get_seconds() const NOEXCEPT;
unsigned int get_seconds() const NOEXCEPT;
/**
* This method returns the time formatted as h:m:s
*/
std::string get_formatted() NOEXCEPT;
std::string get_formatted() const NOEXCEPT;
private:
/**
* The hours.
Expand Down
4 changes: 2 additions & 2 deletions include/curl_cookie.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ namespace curl {
* If you pass an empty string or a string containing a non existing file's path,
* the cookie engine will be initialized, but without reading initial cookies.
*/
void set_file(std::string);
void set_file(const std::string&);
/**
* This method allow you to specify a string that represents a cookie. Such a cookie
* can be either a single line in Netscape / Mozilla format or just regular HTTP-style
Expand All @@ -67,7 +67,7 @@ namespace curl {
/**
* This method allow you to get all known cookies for a specific domain.
*/
const curlcpp_cookies get() const NOEXCEPT;
curlcpp_cookies get() const NOEXCEPT;
/**
* This method erases all cookies held in memory.
*/
Expand Down
14 changes: 10 additions & 4 deletions include/curl_easy.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,10 +175,14 @@ namespace curl {
CURLCPP_DEFINE_OPTION(CURLOPT_ERRORBUFFER, char*);
/* Function that will be called to store the output (instead of fwrite). The
* parameters will use fwrite() syntax, make sure to follow them. */
CURLCPP_DEFINE_OPTION(CURLOPT_WRITEFUNCTION, size_t(*)(void *ptr, size_t size, size_t nmemb, void *userdata));
CURLCPP_DEFINE_OPTION(CURLOPT_WRITEFUNCTION,
size_t(*)(void *ptr, size_t size, size_t nmemb, void *userdata));

/* Function that will be called to read the input (instead of fread). The
* parameters will use fread() syntax, make sure to follow them. */
CURLCPP_DEFINE_OPTION(CURLOPT_READFUNCTION, size_t(*)(void *buffer, size_t size, size_t nitems, void *instream));
CURLCPP_DEFINE_OPTION(CURLOPT_READFUNCTION,
size_t(*)(void *buffer, size_t size, size_t nitems, void *instream));

/* Time-out the read operation after this amount of seconds */
CURLCPP_DEFINE_OPTION(CURLOPT_TIMEOUT, long);
/* If the CURLOPT_INFILE is used, this can be used to inform libcurl about
Expand Down Expand Up @@ -383,7 +387,8 @@ namespace curl {

/* Function that will be called to store headers (instead of fwrite). The
* parameters will use fwrite() syntax, make sure to follow them. */
CURLCPP_DEFINE_OPTION(CURLOPT_HEADERFUNCTION, size_t(*)(void *buffer, size_t size, size_t nitems, void *userdata));
CURLCPP_DEFINE_OPTION(CURLOPT_HEADERFUNCTION,
size_t(*)(void *buffer, size_t size, size_t nitems, void *userdata));

/* Set this to force the HTTP request to get back to GET. Only really usable
if POST, PUT or a custom request have been used first.
Expand Down Expand Up @@ -495,7 +500,8 @@ namespace curl {
/* Set the ssl context callback function, currently only for OpenSSL ssl_ctx
in second argument. The function must be matching the
curl_ssl_ctx_callback proto. */
CURLCPP_DEFINE_OPTION(CURLOPT_SSL_CTX_FUNCTION, CURLcode(*)(CURL *curl, void *ssl_ctx, void *userptr));
CURLCPP_DEFINE_OPTION(CURLOPT_SSL_CTX_FUNCTION,
CURLcode(*)(CURL *curl, void *ssl_ctx, void *userptr));

/* Set the userdata for the ssl context callback function's third
argument */
Expand Down
23 changes: 16 additions & 7 deletions include/curl_exception.h
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,9 @@ namespace curl {
// Implementation of print_traceback
inline void curl_exception::print_traceback() const {
curl_exception::tracebackLocker.lock();
std::for_each(curl_exception::traceback.begin(),curl_exception::traceback.end(),[](const curlcpp_traceback_object &value) {
std::for_each(curl_exception::traceback.begin(),curl_exception::traceback.end(),
[](const curlcpp_traceback_object &value) {

std::cout<<"ERROR: "<<value.first<<" ::::: FUNCTION: "<<value.second<<std::endl;
});
curl_exception::tracebackLocker.unlock();
Expand Down Expand Up @@ -141,11 +143,14 @@ namespace curl {
* This constructor allows to specify a custom error message and the method name where
* the exception has been thrown.
*/
curl_easy_exception(const std::string &error, const std::string &method) : curl_exception(error,method), code(CURLE_OK) {}
curl_easy_exception(const std::string &error, const std::string &method) :
curl_exception(error,method), code(CURLE_OK) {}

/**
* The constructor will transform a CURLcode error in a proper error message.
*/
curl_easy_exception(const CURLcode &code, const std::string &method) : curl_exception(curl_easy_strerror(code),method), code(code) {}
curl_easy_exception(const CURLcode &code, const std::string &method) :
curl_exception(curl_easy_strerror(code),method), code(code) {}

/**
* Returns the error code if there is one. Returns CURLE_OK if none has been set.
Expand All @@ -167,11 +172,13 @@ namespace curl {
* This constructor enables setting a custom error message and the method name where
* the exception has been thrown.
*/
curl_multi_exception(const std::string &error, const std::string &method) : curl_exception(error,method), code(CURLM_OK) {}
curl_multi_exception(const std::string &error, const std::string &method) :
curl_exception(error,method), code(CURLM_OK) {}
/**
* The constructor will transform a CURLMcode error to a proper error message.
*/
curl_multi_exception(const CURLMcode code, const std::string &method) : curl_exception(curl_multi_strerror(code),method), code(code) {}
curl_multi_exception(const CURLMcode code, const std::string &method) :
curl_exception(curl_multi_strerror(code),method), code(code) {}

/**
* Returns the error code if there is one. Returns CURLM_OK if none has been set.
Expand All @@ -193,11 +200,13 @@ namespace curl {
* This constructor enables setting a custom error message and the method name where
* the exception has been thrown.
*/
curl_share_exception(const std::string &error, const std::string &method) : curl_exception(error,method), code(CURLSHE_OK) {}
curl_share_exception(const std::string &error, const std::string &method) :
curl_exception(error,method), code(CURLSHE_OK) {}
/**
* The constructor will transform a CURLSHcode error in a proper error message.
*/
curl_share_exception(const CURLSHcode code, const std::string &method) : curl_exception(curl_share_strerror(code),method), code(code) {}
curl_share_exception(const CURLSHcode code, const std::string &method) :
curl_exception(curl_share_strerror(code),method), code(code) {}

/**
* Returns the error code if there is one. Returns CURLE_OK if none has been set.
Expand Down
15 changes: 10 additions & 5 deletions include/curl_form.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,28 +70,33 @@ namespace curl {
/**
* Overloaded add method.
*/
void add(const curl_pair<CURLformoption,std::string> &, const curl_pair<CURLformoption,std::string> &, const curl_pair<CURLformoption,std::string> &);
void add(const curl_pair<CURLformoption,std::string> &,
const curl_pair<CURLformoption,std::string> &, const curl_pair<CURLformoption,std::string> &);
/**
* Overloaded add method. It adds another curl_pair object to add more
* contents to the form contents list.
*/
void add(const curl_pair<CURLformoption,std::string> &, const curl_pair<CURLformoption,std::string> &, const curl_pair<CURLformoption,int> &);
void add(const curl_pair<CURLformoption,std::string> &,
const curl_pair<CURLformoption,std::string> &, const curl_pair<CURLformoption,int> &);
/**
* Overloaded add method. It adds another curl_pair object to add more
* contents to the form contents list.
*/
void add(const curl_pair<CURLformoption,std::string> &, const curl_pair<CURLformoption,int> &, const curl_pair<CURLformoption,std::string> &);
void add(const curl_pair<CURLformoption,std::string> &,
const curl_pair<CURLformoption,int> &, const curl_pair<CURLformoption,std::string> &);
/**
* Overloaded add method. It adds another curl_pair object to add more
* contents to the form contents list.
*/
void add(const curl_pair<CURLformoption,std::string> &, const curl_pair<CURLformoption,std::string> &, const curl_pair<CURLformoption,int> &, const curl_pair<CURLformoption,std::string> &);
void add(const curl_pair<CURLformoption,std::string> &,const curl_pair<CURLformoption,std::string> &,
const curl_pair<CURLformoption,int> &, const curl_pair<CURLformoption,std::string> &);
/**
* Overloaded add method. Used primarily to pass data via CURLFORM_BUFFERPTR.
* E.g. first option is content name, second is buffer name,
* third is buffer data pointer, fourth is buffer length.
*/
void add(const curl_pair<CURLformoption,std::string> &, const curl_pair<CURLformoption,std::string> &, const curl_pair<CURLformoption, char*> &, const curl_pair<CURLformoption,long> &);
void add(const curl_pair<CURLformoption,std::string> &, const curl_pair<CURLformoption,std::string> &,
const curl_pair<CURLformoption, char*> &, const curl_pair<CURLformoption,long> &);
/**
* Overloaded add method. This version is primarily used to upload multiple files.
* You can pass a vector of filenames to upload them.
Expand Down
1 change: 1 addition & 0 deletions include/curl_option.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
#define __curlcpp__curl_option__

#include <string>
#include <curl/curl.h>
#include "curl_pair.h"

namespace curl {
Expand Down
3 changes: 2 additions & 1 deletion include/curl_pair.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ namespace curl {
* The two parameters constructor gives users a fast way to
* build an object of this type.
*/
curl_pair(const T option, const std::string &value) : option(option == CURLOPT_POSTFIELDS ? CURLOPT_COPYPOSTFIELDS : option), value(value) {};
curl_pair(const T option, const std::string &value) :
option(option == CURLOPT_POSTFIELDS ? CURLOPT_COPYPOSTFIELDS : option), value(value) {};
/**
* Simple method that returns the first field of the pair.
*/
Expand Down
2 changes: 1 addition & 1 deletion include/curl_receiver.h
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace curl {
/**
* In this case the destructor does not have to release any resource.
*/
~curl_receiver() {}
~curl_receiver() = default;
/**
* The receive method wraps curl_easy_recv function and receives raw
* data from the established connection on an easy handler.
Expand Down
8 changes: 4 additions & 4 deletions include/curl_sender.h
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,12 @@ namespace curl {
* The constructor initializes the easy handler and the number of
* sent bytes.
*/
curl_sender(curl_easy &easy);
explicit curl_sender(curl_easy &easy);
/**
* This method wraps the curl_easy_send function that sends raw data
* on an established connection on an easy handler.
*/
void send(const T, const size_t);
void send(T, size_t);
/**
* Simple getter method that returns sent's current byte number.
*/
Expand Down Expand Up @@ -83,13 +83,13 @@ namespace curl {
* The constructor initializes the easy handler and the number of
* sent bytes.
*/
curl_sender(curl_easy &easy) : _easy(easy), _sent_bytes(0) {}
explicit curl_sender(curl_easy &easy) : _easy(easy), _sent_bytes(0) {}
/**
* This method wraps the curl_easy_send function that sends raw data
* on an established connection on an easy handler, treating strings
* as const char pointers.
*/
void send(const std::string buffer) {
void send(const std::string& buffer) {
const CURLcode code = curl_easy_send(_easy.get_curl(),buffer.c_str(),buffer.length(),&_sent_bytes);
if (code != CURLE_OK) {
throw curl_easy_exception(code,__FUNCTION__);
Expand Down
6 changes: 3 additions & 3 deletions include/curl_utility.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,17 @@ namespace curl {
* online documentation for more information about the datetime
* parameter.
*/
static time_t get_date(const std::string);
static time_t get_date(const std::string&);
private:
/**
* Build an object of this type have no sense. So let's hide
* the constructor.
*/
curl_utility() {};
curl_utility() = default;
};

// Implementation of get_date method.
time_t curl_utility::get_date(const std::string format) {
time_t curl_utility::get_date(const std::string& format) {
const time_t value = curl_getdate(format.c_str(),nullptr);
if (value == -1) {
throw curl_exception("*** Error while parsing the date ***",__FUNCTION__);
Expand Down
20 changes: 11 additions & 9 deletions src/cookie_date.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,39 +9,41 @@ using std::out_of_range;
using std::ostringstream;

// Implementation of constructor with parameters.
curl::cookie_date::cookie_date(const unsigned int week_day, const unsigned int day, const unsigned int month, const unsigned int year) NOEXCEPT {
curl::cookie_date::cookie_date(const unsigned int week_day, const unsigned int day,
const unsigned int month, const unsigned int year) NOEXCEPT {

this->set_week_day(week_day)->set_day(day)->set_month(month)->set_year(year);
}

// Implementation of set_week_day method.
curl::cookie_date *curl::cookie_date::set_week_day(const unsigned int week_day) NOEXCEPT {
curl::cookie_date *curl::cookie_date::set_week_day(const unsigned int weekDay) NOEXCEPT {
try {
this->week_day = details::weekday_names.at(week_day);
this->week_day = details::weekdayNames.at(weekDay);
} catch (const out_of_range &exception) {
this->week_day = "Mon";
}
return this;
}

// Implementation of set_day method.
curl::cookie_date *curl::cookie_date::set_day(const unsigned int day) NOEXCEPT {
this->day = (day < 1 or day > 31) ? 1 : day;
curl::cookie_date *curl::cookie_date::set_day(const unsigned int cookieDay) NOEXCEPT {
this->day = (cookieDay < 1 or cookieDay > 31) ? 1 : cookieDay;
return this;
}

// Implementation of set_month method.
curl::cookie_date *curl::cookie_date::set_month(const unsigned int month) {
curl::cookie_date *curl::cookie_date::set_month(const unsigned int cookieMonth) {
try {
this->month = details::months_names.at(month);
this->month = details::monthsNames.at(cookieMonth);
} catch (const out_of_range &exception) {
this->month = "Jan";
}
return this;
}

// Implementation of set_year method.
curl::cookie_date *curl::cookie_date::set_year(const unsigned int year) NOEXCEPT {
this->year = (year < 1970 ) ? 1970 : year;
curl::cookie_date *curl::cookie_date::set_year(const unsigned int cookieYear) NOEXCEPT {
this->year = (cookieYear < 1970 ) ? 1970 : cookieYear;
return this;
}

Expand Down
12 changes: 6 additions & 6 deletions src/cookie_datetime.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,24 +11,24 @@ curl::cookie_datetime::cookie_datetime(const cookie_time &time, const cookie_dat
}

// Implementation of set_time method.
curl::cookie_datetime *curl::cookie_datetime::set_time(const cookie_time &time) NOEXCEPT {
this->time = time;
curl::cookie_datetime *curl::cookie_datetime::set_time(const cookie_time &cookieTime) NOEXCEPT {
this->time = cookieTime;
return this;
}

// Implementation of set_date method.
curl::cookie_datetime *curl::cookie_datetime::set_date(const cookie_date &date) NOEXCEPT {
this->date = date;
curl::cookie_datetime *curl::cookie_datetime::set_date(const cookie_date &cookieDate) NOEXCEPT {
this->date = cookieDate;
return this;
}

// Implementation of get_time method.
const curl::cookie_time curl::cookie_datetime::get_time() const NOEXCEPT {
curl::cookie_time curl::cookie_datetime::get_time() const NOEXCEPT {
return this->time;
}

// Implementation of get_date method.
const curl::cookie_date curl::cookie_datetime::get_date() const NOEXCEPT {
curl::cookie_date curl::cookie_datetime::get_date() const NOEXCEPT {
return this->date;
}

Expand Down
Loading

0 comments on commit cb42631

Please sign in to comment.