Code formatting

This commit is contained in:
yhirose 2021-04-13 12:38:45 -04:00
parent 14c6d526b4
commit d122ff3ca8

View file

@ -200,11 +200,11 @@ using socket_t = int;
#include <mutex>
#include <random>
#include <regex>
#include <set>
#include <sstream>
#include <string>
#include <sys/stat.h>
#include <thread>
#include <set>
#ifdef CPPHTTPLIB_OPENSSL_SUPPORT
#include <openssl/err.h>
@ -257,7 +257,7 @@ namespace detail {
template <class T, class... Args>
typename std::enable_if<!std::is_array<T>::value, std::unique_ptr<T>>::type
make_unique(Args &&... args) {
make_unique(Args &&...args) {
return std::unique_ptr<T>(new T(std::forward<Args>(args)...));
}
@ -487,7 +487,7 @@ public:
virtual socket_t socket() const = 0;
template <typename... Args>
ssize_t write_format(const char *fmt, const Args &... args);
ssize_t write_format(const char *fmt, const Args &...args);
ssize_t write(const char *ptr);
ssize_t write(const std::string &s);
};
@ -976,7 +976,8 @@ public:
void set_connection_timeout(time_t sec, time_t usec = 0);
template <class Rep, class Period>
void set_connection_timeout(const std::chrono::duration<Rep, Period> &duration);
void
set_connection_timeout(const std::chrono::duration<Rep, Period> &duration);
void set_read_timeout(time_t sec, time_t usec = 0);
template <class Rep, class Period>
@ -1286,7 +1287,8 @@ public:
void set_connection_timeout(time_t sec, time_t usec = 0);
template <class Rep, class Period>
void set_connection_timeout(const std::chrono::duration<Rep, Period> &duration);
void
set_connection_timeout(const std::chrono::duration<Rep, Period> &duration);
void set_read_timeout(time_t sec, time_t usec = 0);
template <class Rep, class Period>
@ -3200,9 +3202,7 @@ inline void parse_query_text(const std::string &s, Params &params) {
std::set<std::string> cache;
split(s.data(), s.data() + s.size(), '&', [&](const char *b, const char *e) {
std::string kv(b, e);
if (cache.find(kv) != cache.end()) {
return;
}
if (cache.find(kv) != cache.end()) { return; }
cache.insert(kv);
std::string key;
@ -3744,9 +3744,9 @@ inline std::pair<std::string, std::string> make_digest_authentication_header(
string response;
{
auto H = algo == "SHA-256"
? detail::SHA_256
: algo == "SHA-512" ? detail::SHA_512 : detail::MD5;
auto H = algo == "SHA-256" ? detail::SHA_256
: algo == "SHA-512" ? detail::SHA_512
: detail::MD5;
auto A1 = username + ":" + auth.at("realm") + ":" + password;
@ -4058,7 +4058,7 @@ inline ssize_t Stream::write(const std::string &s) {
}
template <typename... Args>
inline ssize_t Stream::write_format(const char *fmt, const Args &... args) {
inline ssize_t Stream::write_format(const char *fmt, const Args &...args) {
const auto bufsiz = 2048;
std::array<char, bufsiz> buf;
@ -4333,13 +4333,11 @@ inline Server &
Server::set_file_extension_and_mimetype_mapping(const char *ext,
const char *mime) {
file_extension_and_mimetype_map_[ext] = mime;
return *this;
}
inline Server &Server::set_file_request_handler(Handler handler) {
file_request_handler_ = std::move(handler);
return *this;
}
@ -4373,7 +4371,6 @@ inline Server &Server::set_post_routing_handler(Handler handler) {
inline Server &Server::set_logger(Logger logger) {
logger_ = std::move(logger);
return *this;
}
@ -4386,79 +4383,68 @@ Server::set_expect_100_continue_handler(Expect100ContinueHandler handler) {
inline Server &Server::set_tcp_nodelay(bool on) {
tcp_nodelay_ = on;
return *this;
}
inline Server &Server::set_socket_options(SocketOptions socket_options) {
socket_options_ = std::move(socket_options);
return *this;
}
inline Server &Server::set_keep_alive_max_count(size_t count) {
keep_alive_max_count_ = count;
return *this;
}
inline Server &Server::set_keep_alive_timeout(time_t sec) {
keep_alive_timeout_sec_ = sec;
return *this;
}
inline Server &Server::set_read_timeout(time_t sec, time_t usec) {
read_timeout_sec_ = sec;
read_timeout_usec_ = usec;
return *this;
}
template <class Rep, class Period>
inline Server &Server::set_read_timeout(
const std::chrono::duration<Rep, Period> &duration) {
detail::duration_to_sec_and_usec(duration, [&](time_t sec, time_t usec) {
set_read_timeout(sec, usec);
});
inline Server &
Server::set_read_timeout(const std::chrono::duration<Rep, Period> &duration) {
detail::duration_to_sec_and_usec(
duration, [&](time_t sec, time_t usec) { set_read_timeout(sec, usec); });
return *this;
}
inline Server &Server::set_write_timeout(time_t sec, time_t usec) {
write_timeout_sec_ = sec;
write_timeout_usec_ = usec;
return *this;
}
template <class Rep, class Period>
inline Server &Server::set_write_timeout(
const std::chrono::duration<Rep, Period> &duration) {
detail::duration_to_sec_and_usec(duration, [&](time_t sec, time_t usec) {
set_write_timeout(sec, usec);
});
inline Server &
Server::set_write_timeout(const std::chrono::duration<Rep, Period> &duration) {
detail::duration_to_sec_and_usec(
duration, [&](time_t sec, time_t usec) { set_write_timeout(sec, usec); });
return *this;
}
inline Server &Server::set_idle_interval(time_t sec, time_t usec) {
idle_interval_sec_ = sec;
idle_interval_usec_ = usec;
return *this;
}
template <class Rep, class Period>
inline Server &Server::set_idle_interval(
const std::chrono::duration<Rep, Period> &duration) {
detail::duration_to_sec_and_usec(duration, [&](time_t sec, time_t usec) {
set_idle_interval(sec, usec);
});
inline Server &
Server::set_idle_interval(const std::chrono::duration<Rep, Period> &duration) {
detail::duration_to_sec_and_usec(
duration, [&](time_t sec, time_t usec) { set_idle_interval(sec, usec); });
return *this;
}
inline Server &Server::set_payload_max_length(size_t length) {
payload_max_length_ = length;
return *this;
}
@ -6339,7 +6325,7 @@ inline void ClientImpl::set_connection_timeout(time_t sec, time_t usec) {
template <class Rep, class Period>
inline void ClientImpl::set_connection_timeout(
const std::chrono::duration<Rep, Period> &duration) {
const std::chrono::duration<Rep, Period> &duration) {
detail::duration_to_sec_and_usec(duration, [&](time_t sec, time_t usec) {
set_connection_timeout(sec, usec);
});
@ -6352,10 +6338,9 @@ inline void ClientImpl::set_read_timeout(time_t sec, time_t usec) {
template <class Rep, class Period>
inline void ClientImpl::set_read_timeout(
const std::chrono::duration<Rep, Period> &duration) {
detail::duration_to_sec_and_usec(duration, [&](time_t sec, time_t usec) {
set_read_timeout(sec, usec);
});
const std::chrono::duration<Rep, Period> &duration) {
detail::duration_to_sec_and_usec(
duration, [&](time_t sec, time_t usec) { set_read_timeout(sec, usec); });
}
inline void ClientImpl::set_write_timeout(time_t sec, time_t usec) {
@ -6365,10 +6350,9 @@ inline void ClientImpl::set_write_timeout(time_t sec, time_t usec) {
template <class Rep, class Period>
inline void ClientImpl::set_write_timeout(
const std::chrono::duration<Rep, Period> &duration) {
detail::duration_to_sec_and_usec(duration, [&](time_t sec, time_t usec) {
set_write_timeout(sec, usec);
});
const std::chrono::duration<Rep, Period> &duration) {
detail::duration_to_sec_and_usec(
duration, [&](time_t sec, time_t usec) { set_write_timeout(sec, usec); });
}
inline void ClientImpl::set_basic_auth(const char *username,
@ -7471,7 +7455,7 @@ inline void Client::set_connection_timeout(time_t sec, time_t usec) {
template <class Rep, class Period>
inline void Client::set_connection_timeout(
const std::chrono::duration<Rep, Period> &duration) {
const std::chrono::duration<Rep, Period> &duration) {
cli_->set_connection_timeout(duration);
}
@ -7480,8 +7464,8 @@ inline void Client::set_read_timeout(time_t sec, time_t usec) {
}
template <class Rep, class Period>
inline void Client::set_read_timeout(
const std::chrono::duration<Rep, Period> &duration) {
inline void
Client::set_read_timeout(const std::chrono::duration<Rep, Period> &duration) {
cli_->set_read_timeout(duration);
}
@ -7490,8 +7474,8 @@ inline void Client::set_write_timeout(time_t sec, time_t usec) {
}
template <class Rep, class Period>
inline void Client::set_write_timeout(
const std::chrono::duration<Rep, Period> &duration) {
inline void
Client::set_write_timeout(const std::chrono::duration<Rep, Period> &duration) {
cli_->set_write_timeout(duration);
}