Fix modernize warnings (#1720)
This commit is contained in:
parent
7fc8682a0a
commit
03fecb2f78
58
httplib.h
58
httplib.h
@ -392,7 +392,7 @@ private:
|
|||||||
explicit data_sink_streambuf(DataSink &sink) : sink_(sink) {}
|
explicit data_sink_streambuf(DataSink &sink) : sink_(sink) {}
|
||||||
|
|
||||||
protected:
|
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));
|
sink_.write(s, static_cast<size_t>(n));
|
||||||
return n;
|
return n;
|
||||||
}
|
}
|
||||||
@ -1679,7 +1679,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
bool create_and_connect_socket(Socket &socket, Error &error) override;
|
bool create_and_connect_socket(Socket &socket, Error &error) override;
|
||||||
void shutdown_ssl(Socket &socket, bool shutdown_gracefully) 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,
|
bool process_socket(const Socket &socket,
|
||||||
std::function<bool(Stream &strm)> callback) override;
|
std::function<bool(Stream &strm)> callback) override;
|
||||||
@ -2065,7 +2065,7 @@ public:
|
|||||||
|
|
||||||
class nocompressor : public compressor {
|
class nocompressor : public compressor {
|
||||||
public:
|
public:
|
||||||
virtual ~nocompressor() = default;
|
~nocompressor() override = default;
|
||||||
|
|
||||||
bool compress(const char *data, size_t data_length, bool /*last*/,
|
bool compress(const char *data, size_t data_length, bool /*last*/,
|
||||||
Callback callback) override;
|
Callback callback) override;
|
||||||
@ -2075,7 +2075,7 @@ public:
|
|||||||
class gzip_compressor : public compressor {
|
class gzip_compressor : public compressor {
|
||||||
public:
|
public:
|
||||||
gzip_compressor();
|
gzip_compressor();
|
||||||
~gzip_compressor();
|
~gzip_compressor() override;
|
||||||
|
|
||||||
bool compress(const char *data, size_t data_length, bool last,
|
bool compress(const char *data, size_t data_length, bool last,
|
||||||
Callback callback) override;
|
Callback callback) override;
|
||||||
@ -2088,7 +2088,7 @@ private:
|
|||||||
class gzip_decompressor : public decompressor {
|
class gzip_decompressor : public decompressor {
|
||||||
public:
|
public:
|
||||||
gzip_decompressor();
|
gzip_decompressor();
|
||||||
~gzip_decompressor();
|
~gzip_decompressor() override;
|
||||||
|
|
||||||
bool is_valid() const override;
|
bool is_valid() const override;
|
||||||
|
|
||||||
@ -5295,7 +5295,7 @@ inline SocketStream::SocketStream(socket_t sock, time_t read_timeout_sec,
|
|||||||
write_timeout_sec_(write_timeout_sec),
|
write_timeout_sec_(write_timeout_sec),
|
||||||
write_timeout_usec_(write_timeout_usec), read_buff_(read_buff_size_, 0) {}
|
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 {
|
inline bool SocketStream::is_readable() const {
|
||||||
return select_read(sock_, read_timeout_sec_, read_timeout_usec_) > 0;
|
return select_read(sock_, read_timeout_sec_, read_timeout_usec_) > 0;
|
||||||
@ -5509,7 +5509,7 @@ inline Server::Server()
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Server::~Server() {}
|
inline Server::~Server() = default;
|
||||||
|
|
||||||
inline std::unique_ptr<detail::MatcherBase>
|
inline std::unique_ptr<detail::MatcherBase>
|
||||||
Server::make_matcher(const std::string &pattern) {
|
Server::make_matcher(const std::string &pattern) {
|
||||||
@ -5521,66 +5521,60 @@ Server::make_matcher(const std::string &pattern) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
inline Server &Server::Get(const std::string &pattern, Handler handler) {
|
inline Server &Server::Get(const std::string &pattern, Handler handler) {
|
||||||
get_handlers_.push_back(
|
get_handlers_.emplace_back(make_matcher(pattern), std::move(handler));
|
||||||
std::make_pair(make_matcher(pattern), std::move(handler)));
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Server &Server::Post(const std::string &pattern, Handler handler) {
|
inline Server &Server::Post(const std::string &pattern, Handler handler) {
|
||||||
post_handlers_.push_back(
|
post_handlers_.emplace_back(make_matcher(pattern), std::move(handler));
|
||||||
std::make_pair(make_matcher(pattern), std::move(handler)));
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Server &Server::Post(const std::string &pattern,
|
inline Server &Server::Post(const std::string &pattern,
|
||||||
HandlerWithContentReader handler) {
|
HandlerWithContentReader handler) {
|
||||||
post_handlers_for_content_reader_.push_back(
|
post_handlers_for_content_reader_.emplace_back(make_matcher(pattern),
|
||||||
std::make_pair(make_matcher(pattern), std::move(handler)));
|
std::move(handler));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Server &Server::Put(const std::string &pattern, Handler handler) {
|
inline Server &Server::Put(const std::string &pattern, Handler handler) {
|
||||||
put_handlers_.push_back(
|
put_handlers_.emplace_back(make_matcher(pattern), std::move(handler));
|
||||||
std::make_pair(make_matcher(pattern), std::move(handler)));
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Server &Server::Put(const std::string &pattern,
|
inline Server &Server::Put(const std::string &pattern,
|
||||||
HandlerWithContentReader handler) {
|
HandlerWithContentReader handler) {
|
||||||
put_handlers_for_content_reader_.push_back(
|
put_handlers_for_content_reader_.emplace_back(make_matcher(pattern),
|
||||||
std::make_pair(make_matcher(pattern), std::move(handler)));
|
std::move(handler));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Server &Server::Patch(const std::string &pattern, Handler handler) {
|
inline Server &Server::Patch(const std::string &pattern, Handler handler) {
|
||||||
patch_handlers_.push_back(
|
patch_handlers_.emplace_back(make_matcher(pattern), std::move(handler));
|
||||||
std::make_pair(make_matcher(pattern), std::move(handler)));
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Server &Server::Patch(const std::string &pattern,
|
inline Server &Server::Patch(const std::string &pattern,
|
||||||
HandlerWithContentReader handler) {
|
HandlerWithContentReader handler) {
|
||||||
patch_handlers_for_content_reader_.push_back(
|
patch_handlers_for_content_reader_.emplace_back(make_matcher(pattern),
|
||||||
std::make_pair(make_matcher(pattern), std::move(handler)));
|
std::move(handler));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Server &Server::Delete(const std::string &pattern, Handler handler) {
|
inline Server &Server::Delete(const std::string &pattern, Handler handler) {
|
||||||
delete_handlers_.push_back(
|
delete_handlers_.emplace_back(make_matcher(pattern), std::move(handler));
|
||||||
std::make_pair(make_matcher(pattern), std::move(handler)));
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Server &Server::Delete(const std::string &pattern,
|
inline Server &Server::Delete(const std::string &pattern,
|
||||||
HandlerWithContentReader handler) {
|
HandlerWithContentReader handler) {
|
||||||
delete_handlers_for_content_reader_.push_back(
|
delete_handlers_for_content_reader_.emplace_back(make_matcher(pattern),
|
||||||
std::make_pair(make_matcher(pattern), std::move(handler)));
|
std::move(handler));
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline Server &Server::Options(const std::string &pattern, Handler handler) {
|
inline Server &Server::Options(const std::string &pattern, Handler handler) {
|
||||||
options_handlers_.push_back(
|
options_handlers_.emplace_back(make_matcher(pattern), std::move(handler));
|
||||||
std::make_pair(make_matcher(pattern), std::move(handler)));
|
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -8147,7 +8141,7 @@ inline SSLSocketStream::SSLSocketStream(socket_t sock, SSL *ssl,
|
|||||||
SSL_clear_mode(ssl, SSL_MODE_AUTO_RETRY);
|
SSL_clear_mode(ssl, SSL_MODE_AUTO_RETRY);
|
||||||
}
|
}
|
||||||
|
|
||||||
inline SSLSocketStream::~SSLSocketStream() {}
|
inline SSLSocketStream::~SSLSocketStream() = default;
|
||||||
|
|
||||||
inline bool SSLSocketStream::is_readable() const {
|
inline bool SSLSocketStream::is_readable() const {
|
||||||
return detail::select_read(sock_, read_timeout_sec_, read_timeout_usec_) > 0;
|
return detail::select_read(sock_, read_timeout_sec_, read_timeout_usec_) > 0;
|
||||||
@ -8363,7 +8357,7 @@ inline SSLClient::SSLClient(const std::string &host, int port,
|
|||||||
|
|
||||||
detail::split(&host_[0], &host_[host_.size()], '.',
|
detail::split(&host_[0], &host_[host_.size()], '.',
|
||||||
[&](const char *b, const char *e) {
|
[&](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()) {
|
if (!client_cert_path.empty() && !client_key_path.empty()) {
|
||||||
@ -8384,7 +8378,7 @@ inline SSLClient::SSLClient(const std::string &host, int port,
|
|||||||
|
|
||||||
detail::split(&host_[0], &host_[host_.size()], '.',
|
detail::split(&host_[0], &host_[host_.size()], '.',
|
||||||
[&](const char *b, const char *e) {
|
[&](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) {
|
if (client_cert != nullptr && client_key != nullptr) {
|
||||||
@ -8734,7 +8728,7 @@ inline bool SSLClient::check_host_name(const char *pattern,
|
|||||||
std::vector<std::string> pattern_components;
|
std::vector<std::string> pattern_components;
|
||||||
detail::split(&pattern[0], &pattern[pattern_len], '.',
|
detail::split(&pattern[0], &pattern[pattern_len], '.',
|
||||||
[&](const char *b, const char *e) {
|
[&](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; }
|
if (host_components_.size() != pattern_components.size()) { return false; }
|
||||||
@ -8813,7 +8807,7 @@ inline Client::Client(const std::string &host, int port,
|
|||||||
: cli_(detail::make_unique<ClientImpl>(host, port, client_cert_path,
|
: cli_(detail::make_unique<ClientImpl>(host, port, client_cert_path,
|
||||||
client_key_path)) {}
|
client_key_path)) {}
|
||||||
|
|
||||||
inline Client::~Client() {}
|
inline Client::~Client() = default;
|
||||||
|
|
||||||
inline bool Client::is_valid() const {
|
inline bool Client::is_valid() const {
|
||||||
return cli_ != nullptr && cli_->is_valid();
|
return cli_ != nullptr && cli_->is_valid();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user