Skip to content

Commit

Permalink
Fix modernize warnings (#1720)
Browse files Browse the repository at this point in the history
  • Loading branch information
jfsimoneau authored Nov 21, 2023
1 parent 7fc8682 commit 03fecb2
Showing 1 changed file with 26 additions and 32 deletions.
58 changes: 26 additions & 32 deletions httplib.h
Original file line number Diff line number Diff line change
Expand Up @@ -392,7 +392,7 @@ class DataSink {
explicit data_sink_streambuf(DataSink &sink) : sink_(sink) {}

protected:
std::streamsize xsputn(const char *s, std::streamsize n) {
std::streamsize xsputn(const char *s, std::streamsize n) override {
sink_.write(s, static_cast<size_t>(n));
return n;
}
Expand Down Expand Up @@ -1679,7 +1679,7 @@ class SSLClient : public ClientImpl {
private:
bool create_and_connect_socket(Socket &socket, Error &error) override;
void shutdown_ssl(Socket &socket, bool shutdown_gracefully) override;
void shutdown_ssl_impl(Socket &socket, bool shutdown_socket);
void shutdown_ssl_impl(Socket &socket, bool shutdown_gracefully);

bool process_socket(const Socket &socket,
std::function<bool(Stream &strm)> callback) override;
Expand Down Expand Up @@ -2065,7 +2065,7 @@ class decompressor {

class nocompressor : public compressor {
public:
virtual ~nocompressor() = default;
~nocompressor() override = default;

bool compress(const char *data, size_t data_length, bool /*last*/,
Callback callback) override;
Expand All @@ -2075,7 +2075,7 @@ class nocompressor : public compressor {
class gzip_compressor : public compressor {
public:
gzip_compressor();
~gzip_compressor();
~gzip_compressor() override;

bool compress(const char *data, size_t data_length, bool last,
Callback callback) override;
Expand All @@ -2088,7 +2088,7 @@ class gzip_compressor : public compressor {
class gzip_decompressor : public decompressor {
public:
gzip_decompressor();
~gzip_decompressor();
~gzip_decompressor() override;

bool is_valid() const override;

Expand Down Expand Up @@ -5295,7 +5295,7 @@ inline SocketStream::SocketStream(socket_t sock, time_t read_timeout_sec,
write_timeout_sec_(write_timeout_sec),
write_timeout_usec_(write_timeout_usec), read_buff_(read_buff_size_, 0) {}

inline SocketStream::~SocketStream() {}
inline SocketStream::~SocketStream() = default;

inline bool SocketStream::is_readable() const {
return select_read(sock_, read_timeout_sec_, read_timeout_usec_) > 0;
Expand Down Expand Up @@ -5509,7 +5509,7 @@ inline Server::Server()
#endif
}

inline Server::~Server() {}
inline Server::~Server() = default;

inline std::unique_ptr<detail::MatcherBase>
Server::make_matcher(const std::string &pattern) {
Expand All @@ -5521,66 +5521,60 @@ Server::make_matcher(const std::string &pattern) {
}

inline Server &Server::Get(const std::string &pattern, Handler handler) {
get_handlers_.push_back(
std::make_pair(make_matcher(pattern), std::move(handler)));
get_handlers_.emplace_back(make_matcher(pattern), std::move(handler));
return *this;
}

inline Server &Server::Post(const std::string &pattern, Handler handler) {
post_handlers_.push_back(
std::make_pair(make_matcher(pattern), std::move(handler)));
post_handlers_.emplace_back(make_matcher(pattern), std::move(handler));
return *this;
}

inline Server &Server::Post(const std::string &pattern,
HandlerWithContentReader handler) {
post_handlers_for_content_reader_.push_back(
std::make_pair(make_matcher(pattern), std::move(handler)));
post_handlers_for_content_reader_.emplace_back(make_matcher(pattern),
std::move(handler));
return *this;
}

inline Server &Server::Put(const std::string &pattern, Handler handler) {
put_handlers_.push_back(
std::make_pair(make_matcher(pattern), std::move(handler)));
put_handlers_.emplace_back(make_matcher(pattern), std::move(handler));
return *this;
}

inline Server &Server::Put(const std::string &pattern,
HandlerWithContentReader handler) {
put_handlers_for_content_reader_.push_back(
std::make_pair(make_matcher(pattern), std::move(handler)));
put_handlers_for_content_reader_.emplace_back(make_matcher(pattern),
std::move(handler));
return *this;
}

inline Server &Server::Patch(const std::string &pattern, Handler handler) {
patch_handlers_.push_back(
std::make_pair(make_matcher(pattern), std::move(handler)));
patch_handlers_.emplace_back(make_matcher(pattern), std::move(handler));
return *this;
}

inline Server &Server::Patch(const std::string &pattern,
HandlerWithContentReader handler) {
patch_handlers_for_content_reader_.push_back(
std::make_pair(make_matcher(pattern), std::move(handler)));
patch_handlers_for_content_reader_.emplace_back(make_matcher(pattern),
std::move(handler));
return *this;
}

inline Server &Server::Delete(const std::string &pattern, Handler handler) {
delete_handlers_.push_back(
std::make_pair(make_matcher(pattern), std::move(handler)));
delete_handlers_.emplace_back(make_matcher(pattern), std::move(handler));
return *this;
}

inline Server &Server::Delete(const std::string &pattern,
HandlerWithContentReader handler) {
delete_handlers_for_content_reader_.push_back(
std::make_pair(make_matcher(pattern), std::move(handler)));
delete_handlers_for_content_reader_.emplace_back(make_matcher(pattern),
std::move(handler));
return *this;
}

inline Server &Server::Options(const std::string &pattern, Handler handler) {
options_handlers_.push_back(
std::make_pair(make_matcher(pattern), std::move(handler)));
options_handlers_.emplace_back(make_matcher(pattern), std::move(handler));
return *this;
}

Expand Down Expand Up @@ -8147,7 +8141,7 @@ inline SSLSocketStream::SSLSocketStream(socket_t sock, SSL *ssl,
SSL_clear_mode(ssl, SSL_MODE_AUTO_RETRY);
}

inline SSLSocketStream::~SSLSocketStream() {}
inline SSLSocketStream::~SSLSocketStream() = default;

inline bool SSLSocketStream::is_readable() const {
return detail::select_read(sock_, read_timeout_sec_, read_timeout_usec_) > 0;
Expand Down Expand Up @@ -8363,7 +8357,7 @@ inline SSLClient::SSLClient(const std::string &host, int port,

detail::split(&host_[0], &host_[host_.size()], '.',
[&](const char *b, const char *e) {
host_components_.emplace_back(std::string(b, e));
host_components_.emplace_back(b, e);
});

if (!client_cert_path.empty() && !client_key_path.empty()) {
Expand All @@ -8384,7 +8378,7 @@ inline SSLClient::SSLClient(const std::string &host, int port,

detail::split(&host_[0], &host_[host_.size()], '.',
[&](const char *b, const char *e) {
host_components_.emplace_back(std::string(b, e));
host_components_.emplace_back(b, e);
});

if (client_cert != nullptr && client_key != nullptr) {
Expand Down Expand Up @@ -8734,7 +8728,7 @@ inline bool SSLClient::check_host_name(const char *pattern,
std::vector<std::string> pattern_components;
detail::split(&pattern[0], &pattern[pattern_len], '.',
[&](const char *b, const char *e) {
pattern_components.emplace_back(std::string(b, e));
pattern_components.emplace_back(b, e);
});

if (host_components_.size() != pattern_components.size()) { return false; }
Expand Down Expand Up @@ -8813,7 +8807,7 @@ inline Client::Client(const std::string &host, int port,
: cli_(detail::make_unique<ClientImpl>(host, port, client_cert_path,
client_key_path)) {}

inline Client::~Client() {}
inline Client::~Client() = default;

inline bool Client::is_valid() const {
return cli_ != nullptr && cli_->is_valid();
Expand Down

0 comments on commit 03fecb2

Please sign in to comment.