|
8 | 8 | #include <cstring> |
9 | 9 | #include <getopt.h> |
10 | 10 | #include <osmium/version.hpp> |
11 | | -#include <sstream> |
12 | 11 | #include <stdexcept> |
13 | 12 | #include <thread> // for number of threads |
14 | 13 |
|
@@ -257,33 +256,27 @@ void long_usage(char const *arg0, bool verbose = false) |
257 | 256 |
|
258 | 257 | } // anonymous namespace |
259 | 258 |
|
260 | | -database_options_t::database_options_t() |
261 | | -: db(boost::none), username(boost::none), host(boost::none), |
262 | | - password(boost::none), port(boost::none) |
263 | | -{} |
264 | | - |
265 | 259 | std::string database_options_t::conninfo() const |
266 | 260 | { |
267 | | - std::ostringstream out; |
| 261 | + std::string out{"fallback_application_name='osm2pgsql'"}; |
268 | 262 |
|
269 | | - out << "fallback_application_name='osm2pgsql'"; |
270 | | - if (db) { |
271 | | - out << " dbname='" << *db << "'"; |
| 263 | + if (!db.empty()) { |
| 264 | + out += " dbname='{}'"_format(db); |
272 | 265 | } |
273 | | - if (username) { |
274 | | - out << " user='" << *username << "'"; |
| 266 | + if (!username.empty()) { |
| 267 | + out += " user='{}'"_format(username); |
275 | 268 | } |
276 | | - if (password) { |
277 | | - out << " password='" << *password << "'"; |
| 269 | + if (!password.empty()) { |
| 270 | + out += " password='{}'"_format(password); |
278 | 271 | } |
279 | | - if (host) { |
280 | | - out << " host='" << *host << "'"; |
| 272 | + if (!host.empty()) { |
| 273 | + out += " host='{}'"_format(host); |
281 | 274 | } |
282 | | - if (port) { |
283 | | - out << " port='" << *port << "'"; |
| 275 | + if (!port.empty()) { |
| 276 | + out += " port='{}'"_format(port); |
284 | 277 | } |
285 | 278 |
|
286 | | - return out.str(); |
| 279 | + return out; |
287 | 280 | } |
288 | 281 |
|
289 | 282 | options_t::options_t() |
@@ -581,11 +574,9 @@ options_t::options_t(int argc, char *argv[]) : options_t() |
581 | 574 | check_options(); |
582 | 575 |
|
583 | 576 | if (pass_prompt) { |
584 | | - char *prompt = simple_prompt("Password:", 100, 0); |
585 | | - if (prompt == nullptr) { |
586 | | - database_options.password = boost::none; |
587 | | - } else { |
588 | | - database_options.password = std::string(prompt); |
| 577 | + char const *prompt = simple_prompt("Password:", 100, 0); |
| 578 | + if (prompt != nullptr) { |
| 579 | + database_options.password = prompt; |
589 | 580 | } |
590 | 581 | } |
591 | 582 | } |
|
0 commit comments