Skip to content

Commit

Permalink
Remove inconsistent using std::
Browse files Browse the repository at this point in the history
  • Loading branch information
Woazboat committed Mar 5, 2025
1 parent 623509a commit 625eec9
Show file tree
Hide file tree
Showing 17 changed files with 57 additions and 91 deletions.
1 change: 0 additions & 1 deletion include/cgimap/backend/apidb/changeset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
#define CHANGESET_HPP

#include "cgimap/types.hpp"
#include <map>
#include <set>
#include <string>
#include <pqxx/pqxx>
Expand Down
1 change: 0 additions & 1 deletion src/api06/changeset_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include <ranges>
#include <fmt/core.h>

using std::vector;

namespace api06 {

Expand Down
12 changes: 5 additions & 7 deletions src/api06/nodes_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,15 @@
#include <fmt/core.h>
#include <fmt/format.h>

using std::vector;
using std::string;

namespace api06 {

nodes_responder::nodes_responder(mime::type mt, const vector<id_version> &ids,
nodes_responder::nodes_responder(mime::type mt, const std::vector<id_version> &ids,
data_selection &w)
: osm_current_responder(mt, w) {

vector<osm_nwr_id_t> current_ids;
vector<osm_edition_t> historic_ids;
std::vector<osm_nwr_id_t> current_ids;
std::vector<osm_edition_t> historic_ids;

for (const auto &idv : ids) {
if (idv.version) {
Expand Down Expand Up @@ -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<id_version> nodes_handler::validate_request(const request &req) {
vector<id_version> ids = parse_id_list_params(req, "nodes");
std::vector<id_version> nodes_handler::validate_request(const request &req) {
std::vector<id_version> ids = parse_id_list_params(req, "nodes");

if (ids.empty()) {
throw http::bad_request(
Expand Down
1 change: 0 additions & 1 deletion src/api06/relation_full_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
#include "cgimap/logger.hpp"
#include <fmt/core.h>

using std::vector;

namespace api06 {

Expand Down
12 changes: 5 additions & 7 deletions src/api06/relations_handler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,15 @@
#include <string>
#include <vector>

using std::vector;
using std::string;

namespace api06 {

relations_responder::relations_responder(mime::type mt, const vector<id_version> &ids,
relations_responder::relations_responder(mime::type mt, const std::vector<id_version> &ids,
data_selection &s)
: osm_current_responder(mt, s) {

vector<osm_nwr_id_t> current_ids;
vector<osm_edition_t> historic_ids;
std::vector<osm_nwr_id_t> current_ids;
std::vector<osm_edition_t> historic_ids;

for (id_version idv : ids) {
if (idv.version) {
Expand Down Expand Up @@ -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<id_version> relations_handler::validate_request(const request &req) {
vector<id_version> myids = parse_id_list_params(req, "relations");
std::vector<id_version> relations_handler::validate_request(const request &req) {
std::vector<id_version> myids = parse_id_list_params(req, "relations");

if (myids.empty()) {
throw http::bad_request("The parameter relations is required, and must be "
Expand Down
29 changes: 14 additions & 15 deletions src/backend/apidb/apidb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,40 +16,39 @@
#include <memory>

namespace po = boost::program_options;
using std::string;


namespace {
struct apidb_backend : public backend {
apidb_backend() {
// clang-format off
m_options.add_options()
("dbname", po::value<string>()->required(), "database name")
("host", po::value<string>(), "database server host")
("username", po::value<string>(), "database user name")
("password", po::value<string>(), "database password")
("charset", po::value<string>()->default_value("utf8"),
("dbname", po::value<std::string>()->required(), "database name")
("host", po::value<std::string>(), "database server host")
("username", po::value<std::string>(), "database user name")
("password", po::value<std::string>(), "database password")
("charset", po::value<std::string>()->default_value("utf8"),
"database character set")
("disable-api-write", "disable API write operations")
("dbport", po::value<string>(),
("dbport", po::value<std::string>(),
"database port number or UNIX socket file name")
("update-dbname", po::value<string>(),
("update-dbname", po::value<std::string>(),
"database name to use for API write operations, if different from --dbname")
("update-host", po::value<string>(),
("update-host", po::value<std::string>(),
"database server host for API write operations, if different from --host")
("update-username", po::value<string>(),
("update-username", po::value<std::string>(),
"database user name for API write operations, if different from --username")
("update-password", po::value<string>(),
("update-password", po::value<std::string>(),
"database password for API write operations, if different from --password")
("update-charset", po::value<string>(),
("update-charset", po::value<std::string>(),
"database character set for API write operations, if different from --charset")
("update-dbport", po::value<string>(),
("update-dbport", po::value<std::string>(),
"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<data_selection::factory> create(const po::variables_map &opts) override {
Expand All @@ -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"};
};
}
Expand Down
6 changes: 2 additions & 4 deletions src/backend/apidb/changeset.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@
#include "cgimap/backend/apidb/changeset.hpp"
#include "cgimap/logger.hpp"
#include "cgimap/http.hpp"
#include <map>
#include <fmt/core.h>

using std::string;
#include <fmt/core.h>


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) {}


Expand Down
6 changes: 1 addition & 5 deletions src/backend/apidb/readonly_pgsql_selection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@
#include <vector>

namespace po = boost::program_options;
using std::set;
using std::stringstream;
using std::list;
using std::vector;


namespace {
Expand Down Expand Up @@ -87,7 +83,7 @@ osm_edition_t id_of<osm_edition_t>(const pqxx_tuple &row, pqxx::row_size_type co
}

template <typename T>
inline int insert_results(const pqxx::result &res, set<T> &elems) {
inline int insert_results(const pqxx::result &res, std::set<T> &elems) {

auto const id_col = res.column_number("id");

Expand Down
7 changes: 3 additions & 4 deletions src/fcgi_request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@
#include <cerrno>
#include <cstring>

using std::runtime_error;

namespace {
struct fcgi_buffer : public output_buffer {
Expand Down Expand Up @@ -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<pimpl>()) {
// 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<fcgi_buffer>(m_impl->req);
Expand Down Expand Up @@ -165,7 +164,7 @@ int fcgi_request::accept_r() {
}
}

throw runtime_error(out.str());
throw std::runtime_error(out.str());
}
}

Expand Down
36 changes: 16 additions & 20 deletions src/http.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,6 @@
#include <string_view>


using std::string;
using std::vector;
using std::pair;

namespace {
/**
* Functions hexToChar and form_urldecode were taken from GNU CGICC by
Expand Down Expand Up @@ -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_; }
Expand All @@ -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)
Expand All @@ -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;
Expand All @@ -202,9 +198,9 @@ string urlencode(const string &s) {
return rv;
}

vector<pair<string, string> > parse_params(const string &p) {
std::vector<std::pair<std::string, std::string>> parse_params(const std::string &p) {
// Split the query string into components
vector<pair<string, string> > queryKVPairs;
std::vector<std::pair<std::string, std::string>> queryKVPairs;
if (!p.empty()) {
auto temp = split(p, '&');

Expand Down
16 changes: 7 additions & 9 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>()->default_value(5), "number of daemon instances to run")
("pidfile", po::value<string>(), "file to write pid to")
("logfile", po::value<string>(), "file to write log messages to")
("memcache", po::value<string>(), "memcache server specification")
("pidfile", po::value<std::string>(), "file to write pid to")
("logfile", po::value<std::string>(), "file to write log messages to")
("memcache", po::value<std::string>(), "memcache server specification")
("ratelimit", po::value<long>(), "average number of bytes/s to allow each client")
("moderator-ratelimit", po::value<long>(), "average number of bytes/s to allow each moderator")
("maxdebt", po::value<long>(), "maximum debt (in Mb) to allow each client before rate limiting")
("moderator-maxdebt", po::value<long>(), "maximum debt (in Mb) to allow each moderator before rate limiting")
("port", po::value<int>(), "FCGI port number (e.g. 8000) to listen on. This option is for backwards compatibility, please use --socket for new configurations.")
("socket", po::value<string>(), "FCGI port number (e.g. :8000, or 127.0.0.1:8000) or UNIX domain socket to listen on")
("configfile", po::value<string>(), "Config file")
("socket", po::value<std::string>(), "FCGI port number (e.g. :8000, or 127.0.0.1:8000) or UNIX domain socket to listen on")
("configfile", po::value<std::string>(), "Config file")
;
// clang-format on

Expand All @@ -133,8 +131,8 @@ void get_options(int argc, char **argv, po::variables_map &options) {
("max-payload", po::value<long>(), "max size of HTTP payload allowed for uploads, after decompression (in bytes)")
("map-nodes", po::value<int>(), "max number of nodes allowed for /map endpoint")
("map-area", po::value<double>(), "max area size allowed for /map endpoint")
("changeset-timeout-open", po::value<string>(), "max open time period for a changeset")
("changeset-timeout-idle", po::value<string>(), "time period a changeset will remain open after last edit")
("changeset-timeout-open", po::value<std::string>(), "max open time period for a changeset")
("changeset-timeout-idle", po::value<std::string>(), "time period a changeset will remain open after last edit")
("max-changeset-elements", po::value<int>(), "max number of elements allowed in one changeset")
("max-way-nodes", po::value<int>(), "max number of nodes allowed in one way")
("scale", po::value<long>(), "conversion factor from double lat/lon to internal int format")
Expand Down
3 changes: 0 additions & 3 deletions src/osm_changeset_responder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@

#include <fmt/core.h>

#include <optional>

using std::list;

osm_changeset_responder::osm_changeset_responder(mime::type mt,
data_selection &s,
Expand Down
1 change: 0 additions & 1 deletion src/osm_current_responder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

#include <optional>

using std::list;

osm_current_responder::osm_current_responder(mime::type mt,
data_selection &s,
Expand Down
1 change: 0 additions & 1 deletion src/osm_diffresult_responder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#include <chrono>
#include <fmt/core.h>

using std::list;

namespace {

Expand Down
Loading

0 comments on commit 625eec9

Please sign in to comment.