Commit 299f34f6 authored by Murray Cumming's avatar Murray Cumming
Browse files

C++11: Use {} initialization for std::vectors.

Instead of lots of push_back().
parent 899d88f4
......@@ -465,8 +465,7 @@ void AppWindow::on_menu_help_about()
m_pAbout->set_comments(_("A Database GUI"));
m_pAbout->set_version(PACKAGE_VERSION);
m_pAbout->set_copyright(_("© 2000-2011 Murray Cumming, Openismus GmbH"));
std::vector<Glib::ustring> vecAuthors;
vecAuthors.push_back("Murray Cumming <murrayc@murrayc.com>");
const std::vector<Glib::ustring> vecAuthors({"Murray Cumming <murrayc@murrayc.com>"});
m_pAbout->set_authors(vecAuthors);
//For some reason this use of the resource:// syntax does not work:
......
......@@ -33,16 +33,15 @@ namespace ConnectionPoolBackends
{
MySQLCentralHosted::MySQLCentralHosted()
: m_try_other_ports(true)
: m_list_ports( {
//TODO_MySQL:
"5432", //Ubuntu Breezy seems to default to this for MySQL 7.4, and this is probably the default for most mysql installations, including Fedora.
"5433", //Ubuntu Dapper seems to default to this for MySQL 8.1, probably to avoid a clash with MySQL 7.4
"5434", //Earlier versions of Ubuntu Feisty defaulted to this for MySQL 8.2.
"5435", //In case Ubuntu increases the port number again in future.
"5436"} ), //In case Ubuntu increases the port number again in future.
m_try_other_ports(true)
{
//TODO_MySQL:
m_list_ports.push_back("5432"); //Ubuntu Breezy seems to default to this for MySQL 7.4, and this is probably the default for most mysql installations, including Fedora.
m_list_ports.push_back("5433"); //Ubuntu Dapper seems to default to this for MySQL 8.1, probably to avoid a clash with MySQL 7.4
m_list_ports.push_back("5434"); //Earlier versions of Ubuntu Feisty defaulted to this for MySQL 8.2.
m_list_ports.push_back("5435"); //In case Ubuntu increases the port number again in future.
m_list_ports.push_back("5436"); //In case Ubuntu increases the port number again in future.
}
void MySQLCentralHosted::set_host(const Glib::ustring& value)
......
......@@ -33,15 +33,14 @@ namespace ConnectionPoolBackends
{
PostgresCentralHosted::PostgresCentralHosted()
: m_try_other_ports(true)
: m_list_ports( {
"5432", //Ubuntu Breezy seems to default to this for Postgres 7.4, and this is probably the default for most postgres installations, including Fedora.
"5433", //Ubuntu Dapper seems to default to this for Postgres 8.1, probably to avoid a clash with Postgres 7.4
"5434", //Earlier versions of Ubuntu Feisty defaulted to this for Postgres 8.2.
"5435", //In case Ubuntu increases the port number again in future.
"5436"} ), //In case Ubuntu increases the port number again in future.
m_try_other_ports(true)
{
m_list_ports.push_back("5432"); //Ubuntu Breezy seems to default to this for Postgres 7.4, and this is probably the default for most postgres installations, including Fedora.
m_list_ports.push_back("5433"); //Ubuntu Dapper seems to default to this for Postgres 8.1, probably to avoid a clash with Postgres 7.4
m_list_ports.push_back("5434"); //Earlier versions of Ubuntu Feisty defaulted to this for Postgres 8.2.
m_list_ports.push_back("5435"); //In case Ubuntu increases the port number again in future.
m_list_ports.push_back("5436"); //In case Ubuntu increases the port number again in future.
}
void PostgresCentralHosted::set_host(const Glib::ustring& value)
......
......@@ -691,44 +691,41 @@ void Field::init_map()
//These are the conversions know to be supported by the used version of postgres
m_map_conversions.clear();
type_list_conversion_targets list_conversions;
//Numeric:
list_conversions.clear();
list_conversions.push_back(Field::TYPE_BOOLEAN);
list_conversions.push_back(Field::TYPE_TEXT);
type_list_conversion_targets list_conversions( {
Field::TYPE_BOOLEAN,
Field::TYPE_TEXT} );
//to_date(numeric) was supported in 8.2 but not in 8.3: list_conversions.push_back(Field::TYPE_DATE);
//to_timestamp(numeric) was supported in 8.2 but not in 8.3: list_conversions.push_back(Field::TYPE_TIME);
m_map_conversions[Field::TYPE_NUMERIC] = list_conversions;
//Text:
list_conversions.clear();
list_conversions.push_back(Field::TYPE_BOOLEAN);
list_conversions.push_back(Field::TYPE_NUMERIC);
list_conversions.push_back(Field::TYPE_DATE);
list_conversions.push_back(Field::TYPE_TIME);
list_conversions = {
Field::TYPE_BOOLEAN,
Field::TYPE_NUMERIC,
Field::TYPE_DATE,
Field::TYPE_TIME};
m_map_conversions[Field::TYPE_TEXT] = list_conversions;
//Boolean:
list_conversions.clear();
list_conversions.push_back(Field::TYPE_TEXT);
list_conversions.push_back(Field::TYPE_NUMERIC);
list_conversions = {
Field::TYPE_TEXT,
Field::TYPE_NUMERIC};
//to_timestamp(numeric) was supported in 8.2 but not in 8.3: list_conversions.push_back(Field::TYPE_DATE);
//to_timestamp(numeric) was supported in 8.2 but not in 8.3: list_conversions.push_back(Field::TYPE_TIME);
m_map_conversions[Field::TYPE_BOOLEAN] = list_conversions;
//Date:
list_conversions.clear();
list_conversions.push_back(Field::TYPE_TEXT);
list_conversions = {
Field::TYPE_TEXT};
//to_number(textcat()) was supported in 8.2 but not in 8.3: list_conversions.push_back(Field::TYPE_NUMERIC);
//to_number(textcat()) was supported in 8.2 but not in 8.3: list_conversions.push_back(Field::TYPE_BOOLEAN);
m_map_conversions[Field::TYPE_DATE] = list_conversions;
//Time:
list_conversions.clear();
list_conversions.push_back(Field::TYPE_TEXT);
list_conversions.push_back(Field::TYPE_NUMERIC);
list_conversions.push_back(Field::TYPE_BOOLEAN);
list_conversions = {
Field::TYPE_TEXT,
Field::TYPE_NUMERIC,
Field::TYPE_BOOLEAN};
m_map_conversions[Field::TYPE_TIME] = list_conversions;
......
......@@ -132,12 +132,12 @@ static bool test(Glom::Document::HostingMode hosting_mode)
typedef std::vector<Glib::ustring> type_vec_strings;
type_vec_strings table_names;
table_names.push_back("sometable");
table_names.push_back("SomeTableWithUpperCase");
table_names.push_back("sometable with space characters");
table_names.push_back("sometable with a \" doublequote character");
table_names.push_back("sometable with a ' quote character");
type_vec_strings table_names( {
"sometable",
"SomeTableWithUpperCase",
"sometable with space characters",
"sometable with a \" doublequote character",
"sometable with a ' quote character"} );
//MySQL has a 64-character limit on SQL identifiers:
if(hosting_mode != Glom::Document::HOSTING_MODE_MYSQL_SELF)
......@@ -180,12 +180,12 @@ static bool test(Glom::Document::HostingMode hosting_mode)
//Add groups:
type_vec_strings group_names;
group_names.push_back("somegroup1");
group_names.push_back("somegroup with space characters");
group_names.push_back("somegroup with a \" doublequote character");
group_names.push_back("somegroup with a ' quote character");
group_names.push_back("somegroupwithaverylongnameyaddayaddayaddayaddayaddyaddayaddayad"); //Almost too big.
type_vec_strings group_names( {
"somegroup1",
"somegroup with space characters",
"somegroup with a \" doublequote character",
"somegroup with a ' quote character",
"somegroupwithaverylongnameyaddayaddayaddayaddayaddyaddayaddayad"} ); //Almost too big.
//We expect this to fail because of an apparently-undocumented max pg_user size of 63 characters in PostgreSQL:
//group_names.push_back("somegroupwithaverylongnameyaddayaddayaddayaddayaddyaddayaddayadd");
......@@ -200,12 +200,12 @@ static bool test(Glom::Document::HostingMode hosting_mode)
//Add users:
//TODO: Test strange passwords.
type_vec_strings user_names;
user_names.push_back("someuser1");
user_names.push_back("someuser with space characters");
user_names.push_back("someuser with a \" doublequote character");
user_names.push_back("someuser with a ' quote character");
user_names.push_back("someuserwithaverylongnameyaddayaddayaddayaddayaddyaddayadda"); //Almost too big, with space for the numeric suffix below.
type_vec_strings user_names( {
"someuser1",
"someuser with space characters",
"someuser with a \" doublequote character",
"someuser with a ' quote character",
"someuserwithaverylongnameyaddayaddayaddayaddayaddyaddayadda"} ); //Almost too big, with space for the numeric suffix below.
//We expect this to fail because of an apparently-undocumented max pg_user size of 63 characters in PostgreSQL:
//user_names.push_back("someuserwithaverylongnameyaddayaddayaddayaddayaddyaddayaddayadd");
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment