diff options
author | Murray Cumming <murrayc@murrayc.com> | 2015-07-15 14:22:59 +0200 |
---|---|---|
committer | Murray Cumming <murrayc@murrayc.com> | 2015-07-15 14:22:59 +0200 |
commit | b5e068e288a0e9d031c725d5c9423d63daef6a44 (patch) | |
tree | 115f6415d22600a0f1d3df8c5e6d8ce2ff80d1b4 | |
parent | ac8300539d154e6fb4d3663ed331971887df029d (diff) | |
download | glibmm-b5e068e288a0e9d031c725d5c9423d63daef6a44.tar.gz |
C++11: examples/tests: More use of auto.
-rw-r--r-- | examples/child_watch/main.cc | 2 | ||||
-rw-r--r-- | examples/dbus/client_bus_listnames.cc | 4 | ||||
-rw-r--r-- | examples/dbus/server_without_bus.cc | 6 | ||||
-rw-r--r-- | examples/dbus/session_bus_service.cc | 4 | ||||
-rw-r--r-- | examples/keyfile/main.cc | 2 | ||||
-rw-r--r-- | examples/network/resolver.cc | 8 | ||||
-rw-r--r-- | examples/network/socket-client.cc | 4 | ||||
-rw-r--r-- | examples/settings/settings.cc | 2 | ||||
-rw-r--r-- | examples/thread/dispatcher2.cc | 4 | ||||
-rw-r--r-- | gio/giomm/contenttype.cc | 4 | ||||
-rw-r--r-- | gio/giomm/slot_async.cc | 2 | ||||
-rw-r--r-- | gio/giomm/socketsource.h | 2 | ||||
-rw-r--r-- | glib/glibmm/dispatcher.cc | 2 | ||||
-rw-r--r-- | glib/glibmm/main.cc | 4 | ||||
-rw-r--r-- | glib/glibmm/main.h | 10 | ||||
-rw-r--r-- | tests/giomm_asyncresult_sourceobject/main.cc | 4 | ||||
-rw-r--r-- | tests/giomm_ioerror/main.cc | 4 | ||||
-rw-r--r-- | tests/giomm_memoryinputstream/main.cc | 2 | ||||
-rw-r--r-- | tests/giomm_simple/main.cc | 4 | ||||
-rw-r--r-- | tests/giomm_tls_client/main.cc | 18 | ||||
-rw-r--r-- | tests/glibmm_btree/main.cc | 4 | ||||
-rw-r--r-- | tests/glibmm_mainloop/main.cc | 6 | ||||
-rw-r--r-- | tests/glibmm_valuearray/main.cc | 4 | ||||
-rw-r--r-- | tests/glibmm_variant/main.cc | 44 |
24 files changed, 75 insertions, 75 deletions
diff --git a/examples/child_watch/main.cc b/examples/child_watch/main.cc index 883577a2..010992e3 100644 --- a/examples/child_watch/main.cc +++ b/examples/child_watch/main.cc @@ -59,7 +59,7 @@ void ChildWatch::on_child_exited(GPid pid, int status) int main() { - Glib::RefPtr<Glib::MainLoop> mainLoop = Glib::MainLoop::create(); + auto mainLoop = Glib::MainLoop::create(); ChildWatch cwatch(mainLoop); cwatch.run(); diff --git a/examples/dbus/client_bus_listnames.cc b/examples/dbus/client_bus_listnames.cc index 06fc5887..7b9adad6 100644 --- a/examples/dbus/client_bus_listnames.cc +++ b/examples/dbus/client_bus_listnames.cc @@ -56,7 +56,7 @@ void on_dbus_proxy_available(Glib::RefPtr<Gio::AsyncResult>& result) call_result.get_child(names_variant); // Get the vector of strings. - std::vector<Glib::ustring> names = names_variant.get(); + auto names = names_variant.get(); std::cout << "The names on the message bus are:" << std::endl; @@ -81,7 +81,7 @@ int main(int, char**) loop = Glib::MainLoop::create(); // Get the user session bus connection. - Glib::RefPtr<Gio::DBus::Connection> connection = + auto connection = Gio::DBus::Connection::get_sync(Gio::DBus::BUS_TYPE_SESSION); // Check for an unavailable connection. diff --git a/examples/dbus/server_without_bus.cc b/examples/dbus/server_without_bus.cc index 005dc554..6002c149 100644 --- a/examples/dbus/server_without_bus.cc +++ b/examples/dbus/server_without_bus.cc @@ -68,7 +68,7 @@ static void on_method_call(const Glib::RefPtr<Gio::DBus::Connection>& /* connect curr_time.assign_current_time(); const Glib::ustring time_str = curr_time.as_iso8601(); - const Glib::Variant<Glib::ustring> time_var = + const auto time_var = Glib::Variant<Glib::ustring>::create(time_str); // Create the tuple. @@ -114,7 +114,7 @@ const Gio::DBus::InterfaceVTable interface_vtable(sigc::ptr_fun(&on_method_call) bool on_server_new_connection(const Glib::RefPtr<Gio::DBus::Connection>& connection) { - Glib::RefPtr<Gio::Credentials> credentials = + auto credentials = connection->get_peer_credentials(); std::string credentials_str; @@ -200,7 +200,7 @@ int main(int, char**) server->signal_new_connection().connect(sigc::ptr_fun(&on_server_new_connection)); //Keep the server running until the process is killed: - Glib::RefPtr<Glib::MainLoop> loop = Glib::MainLoop::create(); + auto loop = Glib::MainLoop::create(); loop->run(); return EXIT_SUCCESS; diff --git a/examples/dbus/session_bus_service.cc b/examples/dbus/session_bus_service.cc index b5ec2a71..ed320b8b 100644 --- a/examples/dbus/session_bus_service.cc +++ b/examples/dbus/session_bus_service.cc @@ -66,7 +66,7 @@ static void on_method_call(const Glib::RefPtr<Gio::DBus::Connection>& /* connect curr_time.assign_current_time(); const Glib::ustring time_str = curr_time.as_iso8601(); - const Glib::Variant<Glib::ustring> time_var = + const auto time_var = Glib::Variant<Glib::ustring>::create(time_str); // Create the tuple. @@ -163,7 +163,7 @@ int main(int, char**) sigc::ptr_fun(&on_name_lost)); //Keep the service running until the process is killed: - Glib::RefPtr<Glib::MainLoop> loop = Glib::MainLoop::create(); + auto loop = Glib::MainLoop::create(); loop->run(); Gio::DBus::unown_name(id); diff --git a/examples/keyfile/main.cc b/examples/keyfile/main.cc index 2f56b21a..33e90677 100644 --- a/examples/keyfile/main.cc +++ b/examples/keyfile/main.cc @@ -66,7 +66,7 @@ int main(int, char**) // An exception will be thrown if the value is not in the file: try { - const std::vector<int> values = keyfile.get_integer_list("Another Group", "Numbers"); + const auto values = keyfile.get_integer_list("Another Group", "Numbers"); for(const auto& p : values) std::cout << "Number list value: item=" << p << std::endl; diff --git a/examples/network/resolver.cc b/examples/network/resolver.cc index c9195830..42f36a63 100644 --- a/examples/network/resolver.cc +++ b/examples/network/resolver.cc @@ -170,7 +170,7 @@ lookup_one_sync (const Glib::ustring& arg) } else if (Gio::hostname_is_ip_address (arg)) { - Glib::RefPtr<Gio::InetAddress> addr = Gio::InetAddress::create (arg); + auto addr = Gio::InetAddress::create (arg); try { Glib::ustring name = resolver->lookup_by_address (addr, cancellable); @@ -266,7 +266,7 @@ start_async_lookups (char **argv, int argc) if (arg.find ('/') != std::string::npos) { /* service/protocol/domain */ - std::vector<Glib::ustring> parts = split_service_parts (arg); + auto parts = split_service_parts (arg); if (parts.size () != 3) { usage (); return; @@ -281,7 +281,7 @@ start_async_lookups (char **argv, int argc) } else if (Gio::hostname_is_ip_address (argv[i])) { - Glib::RefPtr<Gio::InetAddress> addr = Gio::InetAddress::create (argv[i]); + auto addr = Gio::InetAddress::create (argv[i]); resolver->lookup_by_address_async (addr, sigc::bind (sigc::ptr_fun @@ -307,7 +307,7 @@ static void print_connectable_sockaddr (Glib::RefPtr<Gio::SocketAddress> sockaddr) { Glib::ustring phys; - Glib::RefPtr<Gio::InetSocketAddress> isa = + auto isa = Glib::RefPtr<Gio::InetSocketAddress>::cast_dynamic (sockaddr); if (!isa) diff --git a/examples/network/socket-client.cc b/examples/network/socket-client.cc index e6ecaba0..44fd94ce 100644 --- a/examples/network/socket-client.cc +++ b/examples/network/socket-client.cc @@ -61,7 +61,7 @@ socket_address_to_string (const Glib::RefPtr<Gio::SocketAddress>& address) Glib::ustring str, res; int port; - Glib::RefPtr<Gio::InetSocketAddress> isockaddr = + auto isockaddr = Glib::RefPtr<Gio::InetSocketAddress>::cast_dynamic (address); if (!isockaddr) return Glib::ustring (); @@ -90,7 +90,7 @@ ensure_condition (const Glib::RefPtr<Gio::Socket>& socket, if (use_source) { - Glib::RefPtr<Gio::SocketSource> source = socket->create_source(condition, cancellable); + auto source = socket->create_source(condition, cancellable); source->connect(sigc::ptr_fun(&source_ready)); source->attach(); loop->run(); diff --git a/examples/settings/settings.cc b/examples/settings/settings.cc index bbf1c19c..84df7a0e 100644 --- a/examples/settings/settings.cc +++ b/examples/settings/settings.cc @@ -75,7 +75,7 @@ int main(int, char**) Glib::setenv("GSETTINGS_SCHEMA_DIR", ".", true); Glib::setenv("GSETTINGS_BACKEND", "memory", true); - const Glib::RefPtr<Gio::Settings> settings = + const auto settings = Gio::Settings::create("org.gtkmm.demo"); settings->signal_changed().connect(sigc::bind(sigc::ptr_fun(&on_key_changed), settings)); diff --git a/examples/thread/dispatcher2.cc b/examples/thread/dispatcher2.cc index b9afebc1..cd0faf26 100644 --- a/examples/thread/dispatcher2.cc +++ b/examples/thread/dispatcher2.cc @@ -156,9 +156,9 @@ bool ThreadTimer::timeout_handler() void ThreadTimer::thread_function() { // create a new Main Context - Glib::RefPtr<Glib::MainContext> context = Glib::MainContext::create(); + auto context = Glib::MainContext::create(); // create a new Main Loop - Glib::RefPtr<Glib::MainLoop> mainloop = Glib::MainLoop::create(context, true); + auto mainloop = Glib::MainLoop::create(context, true); // attach a timeout handler, that is called every second, to the // newly created MainContext diff --git a/gio/giomm/contenttype.cc b/gio/giomm/contenttype.cc index a01a487e..74efd24a 100644 --- a/gio/giomm/contenttype.cc +++ b/gio/giomm/contenttype.cc @@ -50,7 +50,7 @@ Glib::ustring content_type_get_mime_type(const Glib::ustring& type) Glib::RefPtr<Gio::Icon> content_type_get_icon(const Glib::ustring& type) { - Glib::RefPtr<Icon> retvalue = Glib::wrap(g_content_type_get_icon(type.c_str())); + auto retvalue = Glib::wrap(g_content_type_get_icon(type.c_str())); if(retvalue) retvalue->reference(); //The function does not do a ref for us. return retvalue; @@ -59,7 +59,7 @@ Glib::RefPtr<Gio::Icon> content_type_get_icon(const Glib::ustring& type) #ifdef G_OS_UNIX Glib::RefPtr<Gio::Icon> content_type_get_symbolic_icon(const Glib::ustring& type) { - Glib::RefPtr<Icon> retvalue = Glib::wrap(g_content_type_get_symbolic_icon(type.c_str())); + auto retvalue = Glib::wrap(g_content_type_get_symbolic_icon(type.c_str())); if(retvalue) retvalue->reference(); //The function does not do a ref for us. return retvalue; diff --git a/gio/giomm/slot_async.cc b/gio/giomm/slot_async.cc index 8db82bc8..31f90778 100644 --- a/gio/giomm/slot_async.cc +++ b/gio/giomm/slot_async.cc @@ -31,7 +31,7 @@ SignalProxy_async_callback(GObject*, GAsyncResult* res, void* data) try { - Glib::RefPtr<Gio::AsyncResult> result = Glib::wrap(res, true /* take copy */); + auto result = Glib::wrap(res, true /* take copy */); (*the_slot)(result); } catch(...) diff --git a/gio/giomm/socketsource.h b/gio/giomm/socketsource.h index a86ed88f..77bec405 100644 --- a/gio/giomm/socketsource.h +++ b/gio/giomm/socketsource.h @@ -45,7 +45,7 @@ public: * is equivalent to: * @code * bool io_handler(Glib::IOCondition io_condition) { ... } - * const Glib::RefPtr<Gio::SocketSource> socket_source = Gio::SocketSource::create(socket, Glib::IO_IN | Glib::IO_OUT); + * const auto socket_source = Gio::SocketSource::create(socket, Glib::IO_IN | Glib::IO_OUT); * socket_source->connect(sigc::ptr_fun(&io_handler)); * socket_source->attach(Glib::MainContext::get_default()); * @endcode diff --git a/glib/glibmm/dispatcher.cc b/glib/glibmm/dispatcher.cc index f6257f36..4fa95dae 100644 --- a/glib/glibmm/dispatcher.cc +++ b/glib/glibmm/dispatcher.cc @@ -197,7 +197,7 @@ DispatchNotifier::DispatchNotifier(const Glib::RefPtr<MainContext>& context) // sigc::mem_fun(*this, &DispatchNotifier::pipe_io_handler), fd, Glib::IO_IN); // except for source->set_can_recurse(true). - const Glib::RefPtr<IOSource> source = IOSource::create(fd, Glib::IO_IN); + const auto source = IOSource::create(fd, Glib::IO_IN); // If the signal emission in pipe_io_handler() starts a new main loop, // the event source shall not be blocked while that loop runs. (E.g. while diff --git a/glib/glibmm/main.cc b/glib/glibmm/main.cc index 1d9d9152..81ffa403 100644 --- a/glib/glibmm/main.cc +++ b/glib/glibmm/main.cc @@ -497,7 +497,7 @@ SignalIO::SignalIO(GMainContext* context) sigc::connection SignalIO::connect(const sigc::slot<bool,IOCondition>& slot, int fd, IOCondition condition, int priority) { - const Glib::RefPtr<IOSource> source = IOSource::create(fd, condition); + const auto source = IOSource::create(fd, condition); if(priority != G_PRIORITY_DEFAULT) source->set_priority(priority); @@ -513,7 +513,7 @@ sigc::connection SignalIO::connect(const sigc::slot<bool,IOCondition>& slot, const Glib::RefPtr<IOChannel>& channel, IOCondition condition, int priority) { - const Glib::RefPtr<IOSource> source = IOSource::create(channel, condition); + const auto source = IOSource::create(channel, condition); if(priority != G_PRIORITY_DEFAULT) source->set_priority(priority); diff --git a/glib/glibmm/main.h b/glib/glibmm/main.h index 94d495c1..30b40a6e 100644 --- a/glib/glibmm/main.h +++ b/glib/glibmm/main.h @@ -107,7 +107,7 @@ public: * is equivalent to: * @code * bool timeout_handler() { ... } - * const Glib::RefPtr<Glib::TimeoutSource> timeout_source = Glib::TimeoutSource::create(1000); + * const auto timeout_source = Glib::TimeoutSource::create(1000); * timeout_source->connect(sigc::ptr_fun(&timeout_handler)); * timeout_source->attach(Glib::MainContext::get_default()); * @endcode @@ -165,7 +165,7 @@ public: * is equivalent to: * @code * bool timeout_handler() { ... } - * const Glib::RefPtr<Glib::TimeoutSource> timeout_source = Glib::TimeoutSource::create(5000); + * const auto timeout_source = Glib::TimeoutSource::create(5000); * timeout_source->connect(sigc::ptr_fun(&timeout_handler)); * timeout_source->attach(Glib::MainContext::get_default()); * @endcode @@ -232,7 +232,7 @@ public: * is equivalent to: * @code * bool idle_handler() { ... } - * const Glib::RefPtr<Glib::IdleSource> idle_source = Glib::IdleSource::create(); + * const auto idle_source = Glib::IdleSource::create(); * idle_source->connect(sigc::ptr_fun(&idle_handler)); * idle_source->attach(Glib::MainContext::get_default()); * @endcode @@ -291,7 +291,7 @@ public: * is equivalent to: * @code * bool io_handler(Glib::IOCondition io_condition) { ... } - * const Glib::RefPtr<Glib::IOSource> io_source = Glib::IOSource::create(fd, Glib::IO_IN | Glib::IO_HUP); + * const auto io_source = Glib::IOSource::create(fd, Glib::IO_IN | Glib::IO_HUP); * io_source->connect(sigc::ptr_fun(&io_handler)); * io_source->attach(Glib::MainContext::get_default()); * @endcode @@ -319,7 +319,7 @@ public: * is equivalent to: * @code * bool io_handler(Glib::IOCondition io_condition) { ... } - * const Glib::RefPtr<Glib::IOSource> io_source = Glib::IOSource::create(channel, Glib::IO_IN | Glib::IO_HUP); + * const auto io_source = Glib::IOSource::create(channel, Glib::IO_IN | Glib::IO_HUP); * io_source->connect(sigc::ptr_fun(&io_handler)); * io_source->attach(Glib::MainContext::get_default()); * @endcode diff --git a/tests/giomm_asyncresult_sourceobject/main.cc b/tests/giomm_asyncresult_sourceobject/main.cc index c9f79e58..12136fa8 100644 --- a/tests/giomm_asyncresult_sourceobject/main.cc +++ b/tests/giomm_asyncresult_sourceobject/main.cc @@ -29,9 +29,9 @@ int main(int, char**) Glib::init(); Gio::init(); - Glib::RefPtr<Glib::MainLoop> mainloop = Glib::MainLoop::create(); + auto mainloop = Glib::MainLoop::create(); - Glib::RefPtr<Gio::File> file = Gio::File::create_for_path("/etc/passwd"); + auto file = Gio::File::create_for_path("/etc/passwd"); file->read_async(&on_read_async); mainloop->run(); diff --git a/tests/giomm_ioerror/main.cc b/tests/giomm_ioerror/main.cc index ae51ec21..797ed22e 100644 --- a/tests/giomm_ioerror/main.cc +++ b/tests/giomm_ioerror/main.cc @@ -34,14 +34,14 @@ int main(int, char**) try { - Glib::RefPtr<Gio::File> file = Gio::File::create_for_path(TEST_FILE); + auto file = Gio::File::create_for_path(TEST_FILE); if(!file) { std::cerr << "Gio::File::create_for_path() returned an empty RefPtr." << std::endl; return EXIT_FAILURE; } - Glib::RefPtr<Gio::FileInputStream> stream = file->read(); + auto stream = file->read(); if(!stream) { std::cerr << "Gio::File::read() returned an empty RefPtr." << std::endl; diff --git a/tests/giomm_memoryinputstream/main.cc b/tests/giomm_memoryinputstream/main.cc index 813fa4e3..8228bd21 100644 --- a/tests/giomm_memoryinputstream/main.cc +++ b/tests/giomm_memoryinputstream/main.cc @@ -43,7 +43,7 @@ int main(int, char**) std::memset(buffer, 0, sizeof buffer); try { - Glib::RefPtr<Gio::MemoryInputStream> stream = Gio::MemoryInputStream::create(); + auto stream = Gio::MemoryInputStream::create(); if (!stream) { std::cerr << "Could not create a MemoryInputStream." << std::endl; diff --git a/tests/giomm_simple/main.cc b/tests/giomm_simple/main.cc index e88c4604..175cadf3 100644 --- a/tests/giomm_simple/main.cc +++ b/tests/giomm_simple/main.cc @@ -22,14 +22,14 @@ int main(int, char**) try { - Glib::RefPtr<Gio::File> file = Gio::File::create_for_path(TEST_FILE); + auto file = Gio::File::create_for_path(TEST_FILE); if(!file) { std::cerr << "Gio::File::create_for_path() returned an empty RefPtr." << std::endl; return EXIT_FAILURE; } - Glib::RefPtr<Gio::FileInputStream> stream = file->read(); + auto stream = file->read(); if(!stream) { std::cerr << "Gio::File::read() returned an empty RefPtr." << std::endl; diff --git a/tests/giomm_tls_client/main.cc b/tests/giomm_tls_client/main.cc index a8099b72..7a4d4bf2 100644 --- a/tests/giomm_tls_client/main.cc +++ b/tests/giomm_tls_client/main.cc @@ -29,7 +29,7 @@ bool on_accept_certificate(const Glib::RefPtr<const Gio::TlsCertificate>& cert, std::cout << "Outputing certificate data:" << std::endl << cert->property_certificate_pem().get_value(); - Glib::RefPtr<const Gio::TlsCertificate> issuer = cert->get_issuer(); + auto issuer = cert->get_issuer(); std::cout << "Outputing the issuer's certificate data:" << std::endl << issuer->property_certificate_pem().get_value(); @@ -74,16 +74,16 @@ int main(int, char**) std::cout << "Successfully resolved address of test host '" << test_host << "'." << std::endl; - Glib::RefPtr<Gio::InetAddress> first_inet_address = inet_addresses[0]; + auto first_inet_address = inet_addresses[0]; std::cout << "First address of test host is " << first_inet_address->to_string() << "." << std::endl; - Glib::RefPtr<Gio::Socket> socket = + auto socket = Gio::Socket::create(first_inet_address->get_family(), Gio::SOCKET_TYPE_STREAM, Gio::SOCKET_PROTOCOL_TCP); - Glib::RefPtr<Gio::InetSocketAddress> address = + auto address = Gio::InetSocketAddress::create(first_inet_address, 443); try @@ -105,7 +105,7 @@ int main(int, char**) "." << std::endl; } - Glib::RefPtr<Gio::TcpConnection> conn = Glib::RefPtr<Gio::TcpConnection>::cast_dynamic(Gio::SocketConnection::create(socket)); + auto conn = Glib::RefPtr<Gio::TcpConnection>::cast_dynamic(Gio::SocketConnection::create(socket)); if(!conn || !conn->is_connected()) { @@ -122,7 +122,7 @@ int main(int, char**) try { - Glib::RefPtr<Gio::TlsClientConnection> tls_connection = + auto tls_connection = Gio::TlsClientConnection::create(conn, address); tls_connection->signal_accept_certificate().connect( @@ -133,7 +133,7 @@ int main(int, char**) std::cout << "Attempting to get the issuer's certificate from the " "connection." << std::endl; - Glib::RefPtr<Gio::TlsCertificate> issuer_certificate = + auto issuer_certificate = tls_connection->get_peer_certificate()->get_issuer(); if(!issuer_certificate) @@ -146,12 +146,12 @@ int main(int, char**) std::endl; std::cout << "Attempting to use the connection's database." << std::endl; - Glib::RefPtr<Gio::TlsDatabase> database = tls_connection->get_database(); + auto database = tls_connection->get_database(); std::cout << "Looking up the certificate's issuer in the database." << std::endl; - Glib::RefPtr<Gio::TlsCertificate> db_certificate = + auto db_certificate = database->lookup_certificate_issuer(issuer_certificate); if(!db_certificate) diff --git a/tests/glibmm_btree/main.cc b/tests/glibmm_btree/main.cc index 8ee1114b..837b7ae7 100644 --- a/tests/glibmm_btree/main.cc +++ b/tests/glibmm_btree/main.cc @@ -74,7 +74,7 @@ my_p_key_compare(const type_p_key_value& key_a, const type_p_key_value& key_b) int main() { - Glib::RefPtr< Glib::BalancedTree<type_key_value, type_key_value> > tree = Glib::BalancedTree<type_key_value, type_key_value>::create(); + auto tree = Glib::BalancedTree<type_key_value, type_key_value>::create(); for (type_key_value::size_type i = 0; i < str.size(); ++i) tree->insert(str.substr(i, 1), str.substr(i, 1)); @@ -137,7 +137,7 @@ main() value = tree->search(sigc::ptr_fun(my_search), "|"); g_assert(value == NULL); - Glib::RefPtr< Glib::BalancedTree<type_p_key_value, type_p_key_value> > ptree = Glib::BalancedTree<type_p_key_value, type_p_key_value>::create(sigc::ptr_fun(my_p_key_compare)); + auto ptree = Glib::BalancedTree<type_p_key_value, type_p_key_value>::create(sigc::ptr_fun(my_p_key_compare)); for (type_key_value::size_type i = 0; i < str.size(); ++i) pstr.push_back(new type_key_value(str.substr(i, 1))); diff --git a/tests/glibmm_mainloop/main.cc b/tests/glibmm_mainloop/main.cc index fbf70027..56bd02d9 100644 --- a/tests/glibmm_mainloop/main.cc +++ b/tests/glibmm_mainloop/main.cc @@ -50,8 +50,8 @@ bool mark_and_quit(const Glib::Threads::Thread* expected_thread, void thread_function(const Glib::Threads::Thread* first_thread, const Glib::RefPtr<Glib::MainLoop>& first_mainloop) { - Glib::RefPtr<Glib::MainContext> second_context = Glib::MainContext::create(); - Glib::RefPtr<Glib::MainLoop> second_mainloop = Glib::MainLoop::create(second_context); + auto second_context = Glib::MainContext::create(); + auto second_mainloop = Glib::MainLoop::create(second_context); // Show how Glib::MainContext::invoke() can be used for calling a function, // possibly executed in another thread. @@ -75,7 +75,7 @@ int main(int, char**) { Glib::init(); - Glib::RefPtr<Glib::MainLoop> first_mainloop = Glib::MainLoop::create(); + auto first_mainloop = Glib::MainLoop::create(); // This thread shall be the owner of the default main context, when // thread_function() calls mark_and_quit() via Glib::MainContext::invoke(), diff --git a/tests/glibmm_valuearray/main.cc b/tests/glibmm_valuearray/main.cc index 62b19ede..ca111432 100644 --- a/tests/glibmm_valuearray/main.cc +++ b/tests/glibmm_valuearray/main.cc @@ -69,7 +69,7 @@ int main(int, char**) break; } - Glib::Value<int> int_val = static_cast< Glib::Value<int>& >(value); + auto int_val = static_cast< Glib::Value<int>& >(value); ostr << int_val.get() << " "; } ostr << std::endl; // End of line for list of array elements. @@ -92,7 +92,7 @@ int main(int, char**) break; } - Glib::Value<int> int_val = static_cast< Glib::Value<int>& >(value); + auto int_val = static_cast< Glib::Value<int>& >(value); ostr << int_val.get() << " "; } ostr << std::endl; // End of line for list of array elements. diff --git a/tests/glibmm_variant/main.cc b/tests/glibmm_variant/main.cc index 943f75a8..47943de3 100644 --- a/tests/glibmm_variant/main.cc +++ b/tests/glibmm_variant/main.cc @@ -26,10 +26,10 @@ int main(int, char**) for(guint i = 0; i < int_vector.size(); i++) ostr << int_vector[i] << std::endl; - Glib::Variant< std::vector<int> > integers_variant = + auto integers_variant = Glib::Variant< std::vector<int> >::create(int_vector); - std::vector<int> int_vector2 = integers_variant.get(); + auto int_vector2 = integers_variant.get(); ostr << "The size of the copied vector is " << int_vector2.size() << '.' << std::endl; @@ -53,7 +53,7 @@ int main(int, char**) //vector<std::string>: std::vector<std::string> vec_strings; vec_strings.push_back("a"); - Glib::Variant<std::vector<std::string> > variant_vec_strings = + auto variant_vec_strings = Glib::Variant<std::vector<std::string> >::create(vec_strings); //Dict: @@ -65,7 +65,7 @@ int main(int, char**) ostr << "The original dictionary entry is (" << dict_entry.first << ", " << dict_entry.second << ")." << std::endl; - Glib::Variant<TypeDictEntry> dict_entry_variant = + auto dict_entry_variant = Glib::Variant<TypeDictEntry>::create(dict_entry); TypeDictEntry copy_entry = dict_entry_variant.get(); @@ -92,7 +92,7 @@ int main(int, char**) ostr << "(" << i << ", " << orig_dict[i] << ")." << std::endl; } - Glib::Variant<TypeDict> orig_dict_variant = + auto orig_dict_variant = Glib::Variant<TypeDict>::create(orig_dict); TypeDict dict_copy = orig_dict_variant.get(); @@ -106,7 +106,7 @@ int main(int, char**) index = 3; - std::pair<unsigned, Glib::ustring> a_pair = orig_dict_variant.get_child(index); + auto a_pair = orig_dict_variant.get_child(index); ostr << "Element number " << index + 1 << " in the variant is: (" << a_pair.first << ", " << a_pair.second << ")." << std::endl; @@ -134,7 +134,7 @@ int main(int, char**) Glib::ustring s = "String " + ss.str(); - Glib::Variant<int> v = Glib::Variant<int>::create(i); + auto v = Glib::Variant<int>::create(i); complex_dict1.insert( std::pair< Glib::ustring, Glib::Variant<int> >("Map 1 " + s, v)); @@ -150,7 +150,7 @@ int main(int, char**) complex_vector.push_back(complex_dict1); complex_vector.push_back(complex_dict2); - Glib::Variant<ComplexVecType> complex_variant = + auto complex_variant = Glib::Variant<ComplexVecType>::create(complex_vector); // This will output the type string aa{sv}. @@ -187,7 +187,7 @@ static void test_dynamic_cast_ustring_types() try { - Glib::Variant<Glib::ustring> derived = + auto derived = Glib::VariantBase::cast_dynamic< Glib::Variant<Glib::ustring> >(vbase_string); ostr << "Casted string Glib::Variant<Glib::ustring>: " << derived.get() << std::endl; } @@ -202,7 +202,7 @@ static void test_dynamic_cast_ustring_types() try { - Glib::Variant<Glib::ustring> derived = + auto derived = Glib::VariantBase::cast_dynamic< Glib::Variant<Glib::ustring> >(vbase_objectpath); ostr << "Casted object path Glib::Variant<Glib::ustring>: " << derived.get() << std::endl; } @@ -216,7 +216,7 @@ static void test_dynamic_cast_ustring_types() try { - Glib::Variant<Glib::ustring> derived = + auto derived = Glib::VariantBase::cast_dynamic< Glib::Variant<Glib::ustring> >(vbase_signature); ostr << "Casted signature Glib::Variant<Glib::ustring>: " << derived.get() << std::endl; } @@ -235,7 +235,7 @@ static void test_dynamic_cast_string_types() try { - Glib::Variant<std::string> derived = + auto derived = Glib::VariantBase::cast_dynamic< Glib::Variant<std::string> >(vbase_string); ostr << "Casted string Glib::Variant<std::string>: " << derived.get() << std::endl; } @@ -250,7 +250,7 @@ static void test_dynamic_cast_string_types() try { - Glib::Variant<std::string> derived = + auto derived = Glib::VariantBase::cast_dynamic< Glib::Variant<std::string> >(vbase_objectpath); ostr << "Casted object path Glib::Variant<std::string>: " << derived.get() << std::endl; } @@ -264,7 +264,7 @@ static void test_dynamic_cast_string_types() try { - Glib::Variant<std::string> derived = + auto derived = Glib::VariantBase::cast_dynamic< Glib::Variant<std::string> >(vbase_signature); ostr << "Casted signature Glib::Variant<std::string>: " << derived.get() << std::endl; } @@ -301,7 +301,7 @@ void test_dynamic_cast_composite_types() try { typedef std::map<Glib::ustring, std::vector<std::string> > composite_type; - Glib::Variant<composite_type> derived = + auto derived = Glib::VariantBase::cast_dynamic<Glib::Variant<composite_type> >(cppdict); ostr << "Cast composite type (get_type_string()=" << derived.get_type_string() @@ -323,7 +323,7 @@ void test_dynamic_cast_composite_types() try { - Glib::Variant<std::map<Glib::ustring, std::string > > derived = + auto derived = Glib::VariantBase::cast_dynamic<Glib::Variant<std::map<Glib::ustring, std::string> > >(cppdict); g_assert_not_reached(); } @@ -334,9 +334,9 @@ void test_dynamic_cast_composite_types() static void test_dynamic_cast() { - Glib::Variant<int> v1 = Glib::Variant<int>::create(10); + auto v1 = Glib::Variant<int>::create(10); Glib::VariantBase& v2 = v1; - Glib::Variant<int> v3 = Glib::VariantBase::cast_dynamic<Glib::Variant<int> >(v2); + auto v3 = Glib::VariantBase::cast_dynamic<Glib::Variant<int> >(v2); g_assert(v3.get() == 10); Glib::VariantBase v5 = v1; @@ -383,7 +383,7 @@ static void test_dynamic_cast() type_dict_sv var_map; type_map_sv map; - Glib::Variant<Glib::ustring> var_string = + auto var_string = Glib::Variant<Glib::ustring>::create("test variant"); map["test key"] = var_string; var_map = type_dict_sv::create(map); @@ -394,7 +394,7 @@ static void test_dynamic_cast() try { - Glib::Variant<std::map<Glib::ustring, Glib::ustring> > var_wrong_map = + auto var_wrong_map = Glib::VariantBase::cast_dynamic<Glib::Variant<std::map<Glib::ustring, Glib::ustring> > >(ref_var_base); g_assert_not_reached(); } @@ -407,9 +407,9 @@ static void test_dynamic_cast() g_assert(var_string.get() == "test variant"); // A variant of type v - Glib::Variant<Glib::VariantBase> var_v = Glib::Variant<Glib::VariantBase>::create(var_string); + auto var_v = Glib::Variant<Glib::VariantBase>::create(var_string); g_assert(var_v.get_type_string() == "v"); - Glib::Variant<Glib::ustring> var_s2 = + auto var_s2 = Glib::VariantBase::cast_dynamic<Glib::Variant<Glib::ustring> >(var_v.get()); g_assert(var_s2.get() == "test variant"); |