diff --git a/include/cgimap/backend/apidb/changeset.hpp b/include/cgimap/backend/apidb/changeset.hpp index 1a5376f4..abdb3071 100644 --- a/include/cgimap/backend/apidb/changeset.hpp +++ b/include/cgimap/backend/apidb/changeset.hpp @@ -11,7 +11,6 @@ #define CHANGESET_HPP #include "cgimap/types.hpp" -#include #include #include #include diff --git a/src/api06/changeset_handler.cpp b/src/api06/changeset_handler.cpp index 0022cab8..33e169a3 100644 --- a/src/api06/changeset_handler.cpp +++ b/src/api06/changeset_handler.cpp @@ -14,7 +14,6 @@ #include #include -using std::vector; namespace api06 { diff --git a/src/api06/nodes_handler.cpp b/src/api06/nodes_handler.cpp index 5d908bfe..b05ec81f 100644 --- a/src/api06/nodes_handler.cpp +++ b/src/api06/nodes_handler.cpp @@ -15,17 +15,15 @@ #include #include -using std::vector; -using std::string; namespace api06 { -nodes_responder::nodes_responder(mime::type mt, const vector &ids, +nodes_responder::nodes_responder(mime::type mt, const std::vector &ids, data_selection &w) : osm_current_responder(mt, w) { - vector current_ids; - vector historic_ids; + std::vector current_ids; + std::vector historic_ids; for (const auto &idv : ids) { if (idv.version) { @@ -59,8 +57,8 @@ responder_ptr_t nodes_handler::responder(data_selection &x) const { * Validates an FCGI request, returning the valid list of ids or * throwing an error if there was no valid list of node ids. */ -vector nodes_handler::validate_request(const request &req) { - vector ids = parse_id_list_params(req, "nodes"); +std::vector nodes_handler::validate_request(const request &req) { + std::vector ids = parse_id_list_params(req, "nodes"); if (ids.empty()) { throw http::bad_request( diff --git a/src/api06/relation_full_handler.cpp b/src/api06/relation_full_handler.cpp index 9473c003..e55fbcc4 100644 --- a/src/api06/relation_full_handler.cpp +++ b/src/api06/relation_full_handler.cpp @@ -12,7 +12,6 @@ #include "cgimap/logger.hpp" #include -using std::vector; namespace api06 { diff --git a/src/api06/relations_handler.cpp b/src/api06/relations_handler.cpp index 7e7396c9..a81b1e2e 100644 --- a/src/api06/relations_handler.cpp +++ b/src/api06/relations_handler.cpp @@ -19,17 +19,15 @@ #include #include -using std::vector; -using std::string; namespace api06 { -relations_responder::relations_responder(mime::type mt, const vector &ids, +relations_responder::relations_responder(mime::type mt, const std::vector &ids, data_selection &s) : osm_current_responder(mt, s) { - vector current_ids; - vector historic_ids; + std::vector current_ids; + std::vector historic_ids; for (id_version idv : ids) { if (idv.version) { @@ -64,8 +62,8 @@ responder_ptr_t relations_handler::responder(data_selection &x) const { * Validates an FCGI request, returning the valid list of ids or * throwing an error if there was no valid list of node ids. */ -vector relations_handler::validate_request(const request &req) { - vector myids = parse_id_list_params(req, "relations"); +std::vector relations_handler::validate_request(const request &req) { + std::vector myids = parse_id_list_params(req, "relations"); if (myids.empty()) { throw http::bad_request("The parameter relations is required, and must be " diff --git a/src/backend/apidb/apidb.cpp b/src/backend/apidb/apidb.cpp index a79437d5..99805e65 100644 --- a/src/backend/apidb/apidb.cpp +++ b/src/backend/apidb/apidb.cpp @@ -16,7 +16,6 @@ #include namespace po = boost::program_options; -using std::string; namespace { @@ -24,32 +23,32 @@ struct apidb_backend : public backend { apidb_backend() { // clang-format off m_options.add_options() - ("dbname", po::value()->required(), "database name") - ("host", po::value(), "database server host") - ("username", po::value(), "database user name") - ("password", po::value(), "database password") - ("charset", po::value()->default_value("utf8"), + ("dbname", po::value()->required(), "database name") + ("host", po::value(), "database server host") + ("username", po::value(), "database user name") + ("password", po::value(), "database password") + ("charset", po::value()->default_value("utf8"), "database character set") ("disable-api-write", "disable API write operations") - ("dbport", po::value(), + ("dbport", po::value(), "database port number or UNIX socket file name") - ("update-dbname", po::value(), + ("update-dbname", po::value(), "database name to use for API write operations, if different from --dbname") - ("update-host", po::value(), + ("update-host", po::value(), "database server host for API write operations, if different from --host") - ("update-username", po::value(), + ("update-username", po::value(), "database user name for API write operations, if different from --username") - ("update-password", po::value(), + ("update-password", po::value(), "database password for API write operations, if different from --password") - ("update-charset", po::value(), + ("update-charset", po::value(), "database character set for API write operations, if different from --charset") - ("update-dbport", po::value(), + ("update-dbport", po::value(), "database port for API write operations, if different from --dbport"); // clang-format on } ~apidb_backend() override = default; - [[nodiscard]] const string &name() const override { return m_name; } + [[nodiscard]] const std::string &name() const override { return m_name; } [[nodiscard]] const po::options_description &options() const override { return m_options; } std::unique_ptr create(const po::variables_map &opts) override { @@ -61,7 +60,7 @@ struct apidb_backend : public backend { } private: - string m_name{"apidb"}; + std::string m_name{"apidb"}; po::options_description m_options{"ApiDB backend options"}; }; } diff --git a/src/backend/apidb/changeset.cpp b/src/backend/apidb/changeset.cpp index ec73d850..c757d908 100644 --- a/src/backend/apidb/changeset.cpp +++ b/src/backend/apidb/changeset.cpp @@ -11,13 +11,11 @@ #include "cgimap/backend/apidb/changeset.hpp" #include "cgimap/logger.hpp" #include "cgimap/http.hpp" -#include -#include -using std::string; +#include -changeset::changeset(bool dp, const string &dn, osm_user_id_t id) +changeset::changeset(bool dp, const std::string &dn, osm_user_id_t id) : data_public(dp), display_name(dn), user_id(id) {} diff --git a/src/backend/apidb/readonly_pgsql_selection.cpp b/src/backend/apidb/readonly_pgsql_selection.cpp index a5d2ecab..0e6af796 100644 --- a/src/backend/apidb/readonly_pgsql_selection.cpp +++ b/src/backend/apidb/readonly_pgsql_selection.cpp @@ -23,10 +23,6 @@ #include namespace po = boost::program_options; -using std::set; -using std::stringstream; -using std::list; -using std::vector; namespace { @@ -87,7 +83,7 @@ osm_edition_t id_of(const pqxx_tuple &row, pqxx::row_size_type co } template -inline int insert_results(const pqxx::result &res, set &elems) { +inline int insert_results(const pqxx::result &res, std::set &elems) { auto const id_col = res.column_number("id"); diff --git a/src/fcgi_request.cpp b/src/fcgi_request.cpp index 52a074ed..1c92a517 100644 --- a/src/fcgi_request.cpp +++ b/src/fcgi_request.cpp @@ -24,7 +24,6 @@ #include #include -using std::runtime_error; namespace { struct fcgi_buffer : public output_buffer { @@ -67,10 +66,10 @@ struct fcgi_request::pimpl { fcgi_request::fcgi_request(int socket, const std::chrono::system_clock::time_point &now) : m_impl(std::make_unique()) { // initialise FCGI if (FCGX_Init() != 0) { - throw runtime_error("Couldn't initialise FCGX library."); + throw std::runtime_error("Couldn't initialise FCGX library."); } if (FCGX_InitRequest(&m_impl->req, socket, FCGI_FAIL_ACCEPT_ON_INTR) != 0) { - throw runtime_error("Couldn't initialise FCGX request structure."); + throw std::runtime_error("Couldn't initialise FCGX request structure."); } m_impl->now = now; m_buffer = std::make_unique(m_impl->req); @@ -165,7 +164,7 @@ int fcgi_request::accept_r() { } } - throw runtime_error(out.str()); + throw std::runtime_error(out.str()); } } diff --git a/src/http.cpp b/src/http.cpp index 2d2744a4..d36e65bb 100644 --- a/src/http.cpp +++ b/src/http.cpp @@ -21,10 +21,6 @@ #include -using std::string; -using std::vector; -using std::pair; - namespace { /** * Functions hexToChar and form_urldecode were taken from GNU CGICC by @@ -119,7 +115,7 @@ std::string format_header(int status, const headers_t &headers) { return hdr; } -exception::exception(int c, string m) +exception::exception(int c, std::string m) : code_(c), message_(std::move(m)) {} int exception::code() const { return code_; } @@ -128,43 +124,43 @@ const char *exception::header() const { return status_message(code()); } const char *exception::what() const noexcept { return message_.c_str(); } -server_error::server_error(const string &message) +server_error::server_error(const std::string &message) : exception(500, message) {} -bad_request::bad_request(const string &message) +bad_request::bad_request(const std::string &message) : exception(400, message) {} -forbidden::forbidden(const string &message) +forbidden::forbidden(const std::string &message) : exception(403, message) {} -not_found::not_found(const string &uri) +not_found::not_found(const std::string &uri) : exception(404, uri) {} -not_acceptable::not_acceptable(const string &message) +not_acceptable::not_acceptable(const std::string &message) : exception(406, message) {} -conflict::conflict(const string &message) +conflict::conflict(const std::string &message) : exception(409, message) {} -precondition_failed::precondition_failed(const string &message) +precondition_failed::precondition_failed(const std::string &message) : exception(412, message), fullstring("Precondition failed: " + message) {} const char *precondition_failed::what() const noexcept { return fullstring.c_str(); } -payload_too_large::payload_too_large(const string &message) +payload_too_large::payload_too_large(const std::string &message) : exception(413, message) {} -too_many_requests::too_many_requests(const string &message) +too_many_requests::too_many_requests(const std::string &message) : exception(429, message) {} bandwidth_limit_exceeded::bandwidth_limit_exceeded(int retry_seconds) : exception(509, fmt::format("You have downloaded too much data. Please try again in {} seconds.", retry_seconds)), retry_seconds(retry_seconds) {} -gone::gone(const string &message) +gone::gone(const std::string &message) : exception(410, message) {} -unsupported_media_type::unsupported_media_type(const string &message) +unsupported_media_type::unsupported_media_type(const std::string &message) : exception(415, message) {} unauthorized::unauthorized(const std::string &message) @@ -175,9 +171,9 @@ method_not_allowed::method_not_allowed(http::method method) allowed_methods(method) {} -string urldecode(const string &s) { return form_urldecode(s); } +std::string urldecode(const std::string &s) { return form_urldecode(s); } -string urlencode(const string &s) { +std::string urlencode(const std::string &s) { static const char hex[] = { '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F' }; std::ostringstream ostr; @@ -202,9 +198,9 @@ string urlencode(const string &s) { return rv; } -vector > parse_params(const string &p) { +std::vector> parse_params(const std::string &p) { // Split the query string into components - vector > queryKVPairs; + std::vector> queryKVPairs; if (!p.empty()) { auto temp = split(p, '&'); diff --git a/src/main.cpp b/src/main.cpp index 6cccf9f4..df0918cc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -103,23 +103,21 @@ std::string get_generator_string() { void get_options(int argc, char **argv, po::variables_map &options) { po::options_description desc(PACKAGE_STRING ": Allowed options"); - using std::string; - // clang-format off desc.add_options() ("help", "display this help and exit") ("daemon", "run as a daemon") ("instances", po::value()->default_value(5), "number of daemon instances to run") - ("pidfile", po::value(), "file to write pid to") - ("logfile", po::value(), "file to write log messages to") - ("memcache", po::value(), "memcache server specification") + ("pidfile", po::value(), "file to write pid to") + ("logfile", po::value(), "file to write log messages to") + ("memcache", po::value(), "memcache server specification") ("ratelimit", po::value(), "average number of bytes/s to allow each client") ("moderator-ratelimit", po::value(), "average number of bytes/s to allow each moderator") ("maxdebt", po::value(), "maximum debt (in Mb) to allow each client before rate limiting") ("moderator-maxdebt", po::value(), "maximum debt (in Mb) to allow each moderator before rate limiting") ("port", po::value(), "FCGI port number (e.g. 8000) to listen on. This option is for backwards compatibility, please use --socket for new configurations.") - ("socket", po::value(), "FCGI port number (e.g. :8000, or 127.0.0.1:8000) or UNIX domain socket to listen on") - ("configfile", po::value(), "Config file") + ("socket", po::value(), "FCGI port number (e.g. :8000, or 127.0.0.1:8000) or UNIX domain socket to listen on") + ("configfile", po::value(), "Config file") ; // clang-format on @@ -133,8 +131,8 @@ void get_options(int argc, char **argv, po::variables_map &options) { ("max-payload", po::value(), "max size of HTTP payload allowed for uploads, after decompression (in bytes)") ("map-nodes", po::value(), "max number of nodes allowed for /map endpoint") ("map-area", po::value(), "max area size allowed for /map endpoint") - ("changeset-timeout-open", po::value(), "max open time period for a changeset") - ("changeset-timeout-idle", po::value(), "time period a changeset will remain open after last edit") + ("changeset-timeout-open", po::value(), "max open time period for a changeset") + ("changeset-timeout-idle", po::value(), "time period a changeset will remain open after last edit") ("max-changeset-elements", po::value(), "max number of elements allowed in one changeset") ("max-way-nodes", po::value(), "max number of nodes allowed in one way") ("scale", po::value(), "conversion factor from double lat/lon to internal int format") diff --git a/src/osm_changeset_responder.cpp b/src/osm_changeset_responder.cpp index 9afb9a7d..85d0aae9 100644 --- a/src/osm_changeset_responder.cpp +++ b/src/osm_changeset_responder.cpp @@ -12,9 +12,6 @@ #include -#include - -using std::list; osm_changeset_responder::osm_changeset_responder(mime::type mt, data_selection &s, diff --git a/src/osm_current_responder.cpp b/src/osm_current_responder.cpp index e2479d0f..6da1b7cf 100644 --- a/src/osm_current_responder.cpp +++ b/src/osm_current_responder.cpp @@ -14,7 +14,6 @@ #include -using std::list; osm_current_responder::osm_current_responder(mime::type mt, data_selection &s, diff --git a/src/osm_diffresult_responder.cpp b/src/osm_diffresult_responder.cpp index 821d7c0e..8cdbc9c5 100644 --- a/src/osm_diffresult_responder.cpp +++ b/src/osm_diffresult_responder.cpp @@ -13,7 +13,6 @@ #include #include -using std::list; namespace { diff --git a/src/request_helpers.cpp b/src/request_helpers.cpp index f91ab630..5f731c9c 100644 --- a/src/request_helpers.cpp +++ b/src/request_helpers.cpp @@ -16,9 +16,8 @@ #include -using std::string; -string fcgi_get_env(const request &req, const char *name, const char *default_value) { +std::string fcgi_get_env(const request &req, const char *name, const char *default_value) { assert(name); const char *v = req.get_param(name); @@ -32,10 +31,10 @@ string fcgi_get_env(const request &req, const char *name, const char *default_va } } - return string(v); + return std::string(v); } -string get_query_string(const request &req) { +std::string get_query_string(const request &req) { // try the query string that's supposed to be present first auto *query_string = req.get_param("QUERY_STRING"); @@ -95,7 +94,7 @@ std::unique_ptr get_encoding(const request &req) { const char *accept_encoding = req.get_param("HTTP_ACCEPT_ENCODING"); if (accept_encoding) { - return http::choose_encoding(string(accept_encoding)); + return http::choose_encoding(std::string(accept_encoding)); } else { return std::make_unique(); } diff --git a/src/text_formatter.cpp b/src/text_formatter.cpp index c395566f..a8251b18 100644 --- a/src/text_formatter.cpp +++ b/src/text_formatter.cpp @@ -11,10 +11,6 @@ #include #include -using std::string; -using std::transform; - - text_formatter::text_formatter(std::unique_ptr w) : writer(std::move(w)) {} diff --git a/src/xml_formatter.cpp b/src/xml_formatter.cpp index 79da53e2..10f56586 100644 --- a/src/xml_formatter.cpp +++ b/src/xml_formatter.cpp @@ -11,9 +11,6 @@ #include #include -using std::string; -using std::transform; - xml_formatter::xml_formatter(std::unique_ptr w) : writer(std::move(w)) {}