Skip to content

Commit 03fecb2

Browse files
authored
Fix modernize warnings (yhirose#1720)
1 parent 7fc8682 commit 03fecb2

File tree

1 file changed

+26
-32
lines changed

1 file changed

+26
-32
lines changed

httplib.h

Lines changed: 26 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -392,7 +392,7 @@ class DataSink {
392392
explicit data_sink_streambuf(DataSink &sink) : sink_(sink) {}
393393

394394
protected:
395-
std::streamsize xsputn(const char *s, std::streamsize n) {
395+
std::streamsize xsputn(const char *s, std::streamsize n) override {
396396
sink_.write(s, static_cast<size_t>(n));
397397
return n;
398398
}
@@ -1679,7 +1679,7 @@ class SSLClient : public ClientImpl {
16791679
private:
16801680
bool create_and_connect_socket(Socket &socket, Error &error) override;
16811681
void shutdown_ssl(Socket &socket, bool shutdown_gracefully) override;
1682-
void shutdown_ssl_impl(Socket &socket, bool shutdown_socket);
1682+
void shutdown_ssl_impl(Socket &socket, bool shutdown_gracefully);
16831683

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

20662066
class nocompressor : public compressor {
20672067
public:
2068-
virtual ~nocompressor() = default;
2068+
~nocompressor() override = default;
20692069

20702070
bool compress(const char *data, size_t data_length, bool /*last*/,
20712071
Callback callback) override;
@@ -2075,7 +2075,7 @@ class nocompressor : public compressor {
20752075
class gzip_compressor : public compressor {
20762076
public:
20772077
gzip_compressor();
2078-
~gzip_compressor();
2078+
~gzip_compressor() override;
20792079

20802080
bool compress(const char *data, size_t data_length, bool last,
20812081
Callback callback) override;
@@ -2088,7 +2088,7 @@ class gzip_compressor : public compressor {
20882088
class gzip_decompressor : public decompressor {
20892089
public:
20902090
gzip_decompressor();
2091-
~gzip_decompressor();
2091+
~gzip_decompressor() override;
20922092

20932093
bool is_valid() const override;
20942094

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

5298-
inline SocketStream::~SocketStream() {}
5298+
inline SocketStream::~SocketStream() = default;
52995299

53005300
inline bool SocketStream::is_readable() const {
53015301
return select_read(sock_, read_timeout_sec_, read_timeout_usec_) > 0;
@@ -5509,7 +5509,7 @@ inline Server::Server()
55095509
#endif
55105510
}
55115511

5512-
inline Server::~Server() {}
5512+
inline Server::~Server() = default;
55135513

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

55235523
inline Server &Server::Get(const std::string &pattern, Handler handler) {
5524-
get_handlers_.push_back(
5525-
std::make_pair(make_matcher(pattern), std::move(handler)));
5524+
get_handlers_.emplace_back(make_matcher(pattern), std::move(handler));
55265525
return *this;
55275526
}
55285527

55295528
inline Server &Server::Post(const std::string &pattern, Handler handler) {
5530-
post_handlers_.push_back(
5531-
std::make_pair(make_matcher(pattern), std::move(handler)));
5529+
post_handlers_.emplace_back(make_matcher(pattern), std::move(handler));
55325530
return *this;
55335531
}
55345532

55355533
inline Server &Server::Post(const std::string &pattern,
55365534
HandlerWithContentReader handler) {
5537-
post_handlers_for_content_reader_.push_back(
5538-
std::make_pair(make_matcher(pattern), std::move(handler)));
5535+
post_handlers_for_content_reader_.emplace_back(make_matcher(pattern),
5536+
std::move(handler));
55395537
return *this;
55405538
}
55415539

55425540
inline Server &Server::Put(const std::string &pattern, Handler handler) {
5543-
put_handlers_.push_back(
5544-
std::make_pair(make_matcher(pattern), std::move(handler)));
5541+
put_handlers_.emplace_back(make_matcher(pattern), std::move(handler));
55455542
return *this;
55465543
}
55475544

55485545
inline Server &Server::Put(const std::string &pattern,
55495546
HandlerWithContentReader handler) {
5550-
put_handlers_for_content_reader_.push_back(
5551-
std::make_pair(make_matcher(pattern), std::move(handler)));
5547+
put_handlers_for_content_reader_.emplace_back(make_matcher(pattern),
5548+
std::move(handler));
55525549
return *this;
55535550
}
55545551

55555552
inline Server &Server::Patch(const std::string &pattern, Handler handler) {
5556-
patch_handlers_.push_back(
5557-
std::make_pair(make_matcher(pattern), std::move(handler)));
5553+
patch_handlers_.emplace_back(make_matcher(pattern), std::move(handler));
55585554
return *this;
55595555
}
55605556

55615557
inline Server &Server::Patch(const std::string &pattern,
55625558
HandlerWithContentReader handler) {
5563-
patch_handlers_for_content_reader_.push_back(
5564-
std::make_pair(make_matcher(pattern), std::move(handler)));
5559+
patch_handlers_for_content_reader_.emplace_back(make_matcher(pattern),
5560+
std::move(handler));
55655561
return *this;
55665562
}
55675563

55685564
inline Server &Server::Delete(const std::string &pattern, Handler handler) {
5569-
delete_handlers_.push_back(
5570-
std::make_pair(make_matcher(pattern), std::move(handler)));
5565+
delete_handlers_.emplace_back(make_matcher(pattern), std::move(handler));
55715566
return *this;
55725567
}
55735568

55745569
inline Server &Server::Delete(const std::string &pattern,
55755570
HandlerWithContentReader handler) {
5576-
delete_handlers_for_content_reader_.push_back(
5577-
std::make_pair(make_matcher(pattern), std::move(handler)));
5571+
delete_handlers_for_content_reader_.emplace_back(make_matcher(pattern),
5572+
std::move(handler));
55785573
return *this;
55795574
}
55805575

55815576
inline Server &Server::Options(const std::string &pattern, Handler handler) {
5582-
options_handlers_.push_back(
5583-
std::make_pair(make_matcher(pattern), std::move(handler)));
5577+
options_handlers_.emplace_back(make_matcher(pattern), std::move(handler));
55845578
return *this;
55855579
}
55865580

@@ -8147,7 +8141,7 @@ inline SSLSocketStream::SSLSocketStream(socket_t sock, SSL *ssl,
81478141
SSL_clear_mode(ssl, SSL_MODE_AUTO_RETRY);
81488142
}
81498143

8150-
inline SSLSocketStream::~SSLSocketStream() {}
8144+
inline SSLSocketStream::~SSLSocketStream() = default;
81518145

81528146
inline bool SSLSocketStream::is_readable() const {
81538147
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,
83638357

83648358
detail::split(&host_[0], &host_[host_.size()], '.',
83658359
[&](const char *b, const char *e) {
8366-
host_components_.emplace_back(std::string(b, e));
8360+
host_components_.emplace_back(b, e);
83678361
});
83688362

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

83858379
detail::split(&host_[0], &host_[host_.size()], '.',
83868380
[&](const char *b, const char *e) {
8387-
host_components_.emplace_back(std::string(b, e));
8381+
host_components_.emplace_back(b, e);
83888382
});
83898383

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

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

8816-
inline Client::~Client() {}
8810+
inline Client::~Client() = default;
88178811

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

0 commit comments

Comments
 (0)