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 /examples | |
parent | ac8300539d154e6fb4d3663ed331971887df029d (diff) | |
download | glibmm-b5e068e288a0e9d031c725d5c9423d63daef6a44.tar.gz |
C++11: examples/tests: More use of auto.
Diffstat (limited to 'examples')
-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 |
9 files changed, 18 insertions, 18 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 |