Skip to content

Commit

Permalink
Prefer brace-initialisation.
Browse files Browse the repository at this point in the history
  • Loading branch information
jtv committed Dec 24, 2018
1 parent d408b4f commit c93a462
Show file tree
Hide file tree
Showing 78 changed files with 751 additions and 738 deletions.
4 changes: 2 additions & 2 deletions include/pqxx/basic_connection.hxx
Expand Up @@ -48,7 +48,7 @@ template<typename CONNECTPOLICY> class basic_connection_base :
public:
basic_connection_base() :
connection_base(m_policy),
m_options(std::string()),
m_options(std::string{}),
m_policy(m_options)
{ init(); }

Expand All @@ -62,7 +62,7 @@ public:

/// See: @c basic_connection(const std::string &opt)
explicit basic_connection_base(const char opt[]) :
basic_connection_base(opt ? std::string(opt) : std::string()) {}
basic_connection_base(opt ? std::string{opt} : std::string{}) {}

explicit basic_connection_base(std::nullptr_t) : basic_connection_base() {}

Expand Down
8 changes: 4 additions & 4 deletions include/pqxx/binarystring.hxx
Expand Up @@ -92,10 +92,10 @@ public:
{ return *(data()+m_size-1); }

const_reverse_iterator rbegin() const //[t62]
{ return const_reverse_iterator(end()); }
{ return const_reverse_iterator{end()}; }
const_reverse_iterator crbegin() const { return rbegin(); }
const_reverse_iterator rend() const //[t62]
{ return const_reverse_iterator(begin()); }
{ return const_reverse_iterator{begin()}; }
const_reverse_iterator crend() const { return rend(); }

/// Unescaped field contents
Expand Down Expand Up @@ -138,9 +138,9 @@ private:
/// Shorthand: construct a smart_pointer_type.
static smart_pointer_type make_smart_pointer(unsigned char *buf=nullptr)
{
return smart_pointer_type(
return smart_pointer_type{
buf,
internal::freemallocmem_templated<unsigned char>);
internal::freemallocmem_templated<unsigned char>};
}

smart_pointer_type m_buf;
Expand Down
6 changes: 3 additions & 3 deletions include/pqxx/connection.hxx
Expand Up @@ -89,7 +89,7 @@ class PQXX_LIBEXPORT connect_direct : public connectionpolicy
public:
/// The parsing of options is the same as in libpq's PQconnect.
/// See: https://www.postgresql.org/docs/10/static/libpq-connect.html
explicit connect_direct(const std::string &opts) : connectionpolicy(opts) {}
explicit connect_direct(const std::string &opts) : connectionpolicy{opts} {}
virtual handle do_startconnect(handle) override;
};

Expand All @@ -107,7 +107,7 @@ class PQXX_LIBEXPORT connect_lazy : public connectionpolicy
public:
/// The parsing of options is the same as in libpq's PQconnect.
/// See: https://www.postgresql.org/docs/10/static/libpq-connect.html
explicit connect_lazy(const std::string &opts) : connectionpolicy(opts) {}
explicit connect_lazy(const std::string &opts) : connectionpolicy{opts} {}
virtual handle do_completeconnect(handle) override;
};

Expand Down Expand Up @@ -152,7 +152,7 @@ using asyncconnection = basic_connection_base<connect_async>;
class PQXX_LIBEXPORT connect_null : public connectionpolicy
{
public:
explicit connect_null(const std::string &opts) : connectionpolicy(opts) {}
explicit connect_null(const std::string &opts) : connectionpolicy{opts} {}
};


Expand Down
6 changes: 3 additions & 3 deletions include/pqxx/connection_base.hxx
Expand Up @@ -504,9 +504,9 @@ public:
* void foo(connection_base &C)
* {
* C.prepare("findtable", "select * from pg_tables where name=$1");
* work W(C);
* work W{C};
* result R = W.exec_prepared("findtable", "mytable");
* if (R.empty()) throw runtime_error("mytable not found!");
* if (R.empty()) throw runtime_error{"mytable not found!"};
* }
* @endcode
*
Expand Down Expand Up @@ -679,7 +679,7 @@ public:

protected:
explicit connection_base(connectionpolicy &pol) :
m_policy(pol)
m_policy{pol}
{
// Check library version. The check_library_version template is declared
// for any library version, but only actually defined for the version of
Expand Down
4 changes: 2 additions & 2 deletions include/pqxx/cursor.hxx
Expand Up @@ -271,15 +271,15 @@ public:
const std::string &query,
const std::string &cname,
bool hold) :
m_cur(trans, query, cname, cursor_base::random_access, up, op, hold)
m_cur{trans, query, cname, cursor_base::random_access, up, op, hold}
{
}

/// Adopt existing scrolling SQL cursor.
stateless_cursor(
transaction_base &trans,
const std::string adopted_cursor) :
m_cur(trans, adopted_cursor, op)
m_cur{trans, adopted_cursor, op}
{
// Put cursor in known position
m_cur.move(cursor_base::backward_all());
Expand Down
2 changes: 1 addition & 1 deletion include/pqxx/errorhandler.hxx
Expand Up @@ -75,7 +75,7 @@ private:
class quiet_errorhandler : public errorhandler
{
public:
quiet_errorhandler(connection_base &conn) : errorhandler(conn) {}
quiet_errorhandler(connection_base &conn) : errorhandler{conn} {}

virtual bool operator()(const char[]) noexcept override { return false; }
};
Expand Down
50 changes: 25 additions & 25 deletions include/pqxx/except.hxx
Expand Up @@ -262,7 +262,7 @@ class PQXX_LIBEXPORT unexpected_rows : public range_error
virtual const std::exception &base() const noexcept override
{ return *this; }
public:
explicit unexpected_rows(const std::string &msg) : range_error(msg) {}
explicit unexpected_rows(const std::string &msg) : range_error{msg} {}
};


Expand All @@ -274,7 +274,7 @@ public:
const std::string &err,
const std::string &Q="",
const char sqlstate[]=nullptr) :
sql_error(err, Q, sqlstate) {}
sql_error{err, Q, sqlstate} {}
};

/// Error in data provided to SQL statement
Expand All @@ -285,7 +285,7 @@ public:
const std::string &err,
const std::string &Q="",
const char sqlstate[]=nullptr) :
sql_error(err, Q, sqlstate) {}
sql_error{err, Q, sqlstate} {}
};

class PQXX_LIBEXPORT integrity_constraint_violation : public sql_error
Expand All @@ -295,7 +295,7 @@ public:
const std::string &err,
const std::string &Q="",
const char sqlstate[]=nullptr) :
sql_error(err, Q, sqlstate) {}
sql_error{err, Q, sqlstate} {}
};

class PQXX_LIBEXPORT restrict_violation :
Expand All @@ -306,7 +306,7 @@ public:
const std::string &err,
const std::string &Q="",
const char sqlstate[]=nullptr) :
integrity_constraint_violation(err, Q, sqlstate) {}
integrity_constraint_violation{err, Q, sqlstate} {}
};

class PQXX_LIBEXPORT not_null_violation :
Expand All @@ -317,7 +317,7 @@ public:
const std::string &err,
const std::string &Q="",
const char sqlstate[]=nullptr) :
integrity_constraint_violation(err, Q, sqlstate) {}
integrity_constraint_violation{err, Q, sqlstate} {}
};

class PQXX_LIBEXPORT foreign_key_violation :
Expand All @@ -328,7 +328,7 @@ public:
const std::string &err,
const std::string &Q="",
const char sqlstate[]=nullptr) :
integrity_constraint_violation(err, Q, sqlstate) {}
integrity_constraint_violation{err, Q, sqlstate} {}
};

class PQXX_LIBEXPORT unique_violation :
Expand All @@ -339,7 +339,7 @@ public:
const std::string &err,
const std::string &Q="",
const char sqlstate[]=nullptr) :
integrity_constraint_violation(err, Q, sqlstate) {}
integrity_constraint_violation{err, Q, sqlstate} {}
};

class PQXX_LIBEXPORT check_violation :
Expand All @@ -350,7 +350,7 @@ public:
const std::string &err,
const std::string &Q="",
const char sqlstate[]=nullptr) :
integrity_constraint_violation(err, Q, sqlstate) {}
integrity_constraint_violation{err, Q, sqlstate} {}
};

class PQXX_LIBEXPORT invalid_cursor_state : public sql_error
Expand All @@ -360,7 +360,7 @@ public:
const std::string &err,
const std::string &Q="",
const char sqlstate[]=nullptr) :
sql_error(err, Q, sqlstate) {}
sql_error{err, Q, sqlstate} {}
};

class PQXX_LIBEXPORT invalid_sql_statement_name : public sql_error
Expand All @@ -370,7 +370,7 @@ public:
const std::string &err,
const std::string &Q="",
const char sqlstate[]=nullptr) :
sql_error(err, Q, sqlstate) {}
sql_error{err, Q, sqlstate} {}
};

class PQXX_LIBEXPORT invalid_cursor_name : public sql_error
Expand All @@ -380,7 +380,7 @@ public:
const std::string &err,
const std::string &Q="",
const char sqlstate[]=nullptr) :
sql_error(err, Q, sqlstate) {}
sql_error{err, Q, sqlstate} {}
};

class PQXX_LIBEXPORT syntax_error : public sql_error
Expand All @@ -394,7 +394,7 @@ public:
const std::string &Q="",
const char sqlstate[]=nullptr,
int pos=-1) :
sql_error(err, Q, sqlstate), error_position(pos) {}
sql_error{err, Q, sqlstate}, error_position{pos} {}
};

class PQXX_LIBEXPORT undefined_column : public syntax_error
Expand All @@ -404,7 +404,7 @@ public:
const std::string &err,
const std::string &Q="",
const char sqlstate[]=nullptr) :
syntax_error(err, Q, sqlstate) {}
syntax_error{err, Q, sqlstate} {}
};

class PQXX_LIBEXPORT undefined_function : public syntax_error
Expand All @@ -414,7 +414,7 @@ public:
const std::string &err,
const std::string &Q="",
const char sqlstate[]=nullptr) :
syntax_error(err, Q, sqlstate) {}
syntax_error{err, Q, sqlstate} {}
};

class PQXX_LIBEXPORT undefined_table : public syntax_error
Expand All @@ -424,7 +424,7 @@ public:
const std::string &err,
const std::string &Q="",
const char sqlstate[]=nullptr) :
syntax_error(err, Q, sqlstate) {}
syntax_error{err, Q, sqlstate} {}
};

class PQXX_LIBEXPORT insufficient_privilege : public sql_error
Expand All @@ -434,7 +434,7 @@ public:
const std::string &err,
const std::string &Q="",
const char sqlstate[]=nullptr) :
sql_error(err, Q, sqlstate) {}
sql_error{err, Q, sqlstate} {}
};

/// Resource shortage on the server
Expand All @@ -445,7 +445,7 @@ public:
const std::string &err,
const std::string &Q="",
const char sqlstate[]=nullptr) :
sql_error(err,Q, sqlstate) {}
sql_error{err,Q, sqlstate} {}
};

class PQXX_LIBEXPORT disk_full : public insufficient_resources
Expand All @@ -455,7 +455,7 @@ public:
const std::string &err,
const std::string &Q="",
const char sqlstate[]=nullptr) :
insufficient_resources(err, Q, sqlstate) {}
insufficient_resources{err, Q, sqlstate} {}
};

class PQXX_LIBEXPORT out_of_memory : public insufficient_resources
Expand All @@ -465,14 +465,14 @@ public:
const std::string &err,
const std::string &Q="",
const char sqlstate[]=nullptr) :
insufficient_resources(err, Q, sqlstate) {}
insufficient_resources{err, Q, sqlstate} {}
};

class PQXX_LIBEXPORT too_many_connections : public broken_connection
{
public:
explicit too_many_connections(const std::string &err) :
broken_connection(err) {}
broken_connection{err} {}
};

/// PL/pgSQL error
Expand All @@ -485,7 +485,7 @@ public:
const std::string &err,
const std::string &Q="",
const char sqlstate[]=nullptr) :
sql_error(err, Q, sqlstate) {}
sql_error{err, Q, sqlstate} {}
};

/// Exception raised in PL/pgSQL procedure
Expand All @@ -496,7 +496,7 @@ public:
const std::string &err,
const std::string &Q="",
const char sqlstate[]=nullptr) :
plpgsql_error(err, Q, sqlstate) {}
plpgsql_error{err, Q, sqlstate} {}
};

class PQXX_LIBEXPORT plpgsql_no_data_found : public plpgsql_error
Expand All @@ -506,7 +506,7 @@ public:
const std::string &err,
const std::string &Q="",
const char sqlstate[]=nullptr) :
plpgsql_error(err, Q, sqlstate) {}
plpgsql_error{err, Q, sqlstate} {}
};

class PQXX_LIBEXPORT plpgsql_too_many_rows : public plpgsql_error
Expand All @@ -516,7 +516,7 @@ public:
const std::string &err,
const std::string &Q="",
const char sqlstate[]=nullptr) :
plpgsql_error(err, Q, sqlstate) {}
plpgsql_error{err, Q, sqlstate} {}
};

/**
Expand Down
8 changes: 4 additions & 4 deletions include/pqxx/field.hxx
Expand Up @@ -207,7 +207,7 @@ public:
* you keep the @c row of @c field object alive, it will keep the @c result
* object alive as well.
*/
array_parser as_array() const { return array_parser(c_str()); }
array_parser as_array() const { return array_parser{c_str()}; }
//@}


Expand All @@ -234,7 +234,7 @@ inline bool field::to<std::string>(std::string &Obj) const
{
const char *const bytes = c_str();
if (bytes[0] == '\0' and is_null()) return false;
Obj = std::string(bytes, size());
Obj = std::string{bytes, size()};
return true;
}

Expand Down Expand Up @@ -267,7 +267,7 @@ public:
using seekdir = std::ios::seekdir;

explicit field_streambuf(const field &F) : //[t74]
m_field(F)
m_field{F}
{
initialize();
}
Expand Down Expand Up @@ -320,7 +320,7 @@ public:
using pos_type = typename traits_type::pos_type;
using off_type = typename traits_type::off_type;

basic_fieldstream(const field &F) : super(nullptr), m_buf(F)
basic_fieldstream(const field &F) : super{nullptr}, m_buf{F}
{ super::init(&m_buf); }

private:
Expand Down
2 changes: 1 addition & 1 deletion include/pqxx/internal/gates/transaction-stream_to.hxx
Expand Up @@ -14,7 +14,7 @@ class PQXX_PRIVATE transaction_stream_to : callgate<transaction_base>

void BeginCopyWrite(
const std::string &table,
const std::string &columns = std::string())
const std::string &columns = std::string{})
{ home().BeginCopyWrite(table, columns); }

void write_copy_line(const std::string &line)
Expand Down
2 changes: 1 addition & 1 deletion include/pqxx/internal/gates/transaction-tablewriter.hxx
Expand Up @@ -14,7 +14,7 @@ class PQXX_PRIVATE transaction_tablewriter : callgate<transaction_base>

void BeginCopyWrite(
const std::string &table,
const std::string &columns = std::string())
const std::string &columns = std::string{})
{ home().BeginCopyWrite(table, columns); }

void write_copy_line(const std::string &line)
Expand Down

0 comments on commit c93a462

Please sign in to comment.