From e1eb5c1d651a8906074feda2d2a0ad103e838949 Mon Sep 17 00:00:00 2001 From: Murray Cumming Date: Fri, 26 Feb 2016 22:46:55 +0100 Subject: Run clang-format on the .ccg files. This seems to work. --- gio/src/action.ccg | 3 +- gio/src/actionmap.ccg | 83 ++- gio/src/appinfo.ccg | 61 +- gio/src/application.ccg | 187 ++--- gio/src/applicationcommandline.ccg | 8 +- gio/src/asyncinitable.ccg | 110 +-- gio/src/asyncresult.ccg | 18 +- gio/src/bufferedinputstream.ccg | 37 +- gio/src/bufferedoutputstream.ccg | 5 +- gio/src/cancellable.ccg | 28 +- gio/src/charsetconverter.ccg | 7 +- gio/src/datainputstream.ccg | 225 +++--- gio/src/dbusactiongroup.ccg | 2 +- gio/src/dbusaddress.ccg | 91 +-- gio/src/dbusauthobserver.ccg | 2 +- gio/src/dbusconnection.ccg | 761 ++++++++----------- gio/src/dbuserrorutils.ccg | 9 +- gio/src/dbusinterfacevtable.ccg | 95 ++- gio/src/dbusintrospection.ccg | 20 +- gio/src/dbusmessage.ccg | 28 +- gio/src/dbusownname.ccg | 48 +- gio/src/dbusproxy.ccg | 382 ++++------ gio/src/dbusserver.ccg | 77 +- gio/src/dbussubtreevtable.ccg | 93 +-- gio/src/dbusutils.ccg | 18 +- gio/src/dbuswatchname.ccg | 62 +- gio/src/drive.ccg | 157 ++-- gio/src/emblem.ccg | 2 +- gio/src/emblemedicon.ccg | 6 +- gio/src/enums.ccg | 1 - gio/src/file.ccg | 1372 +++++++++++++++-------------------- gio/src/fileattributeinfo.ccg | 13 +- gio/src/fileattributeinfolist.ccg | 6 +- gio/src/fileenumerator.ccg | 45 +- gio/src/fileinfo.ccg | 6 +- gio/src/fileinputstream.ccg | 39 +- gio/src/fileiostream.ccg | 39 +- gio/src/filemonitor.ccg | 4 +- gio/src/filenamecompleter.ccg | 4 +- gio/src/fileoutputstream.ccg | 47 +- gio/src/icon.ccg | 11 +- gio/src/inetaddress.ccg | 12 +- gio/src/inetsocketaddress.ccg | 2 +- gio/src/inputstream.ccg | 100 +-- gio/src/iostream.ccg | 35 +- gio/src/loadableicon.ccg | 42 +- gio/src/memoryinputstream.ccg | 26 +- gio/src/menuattributeiter.ccg | 7 +- gio/src/menuitem.ccg | 33 +- gio/src/menulinkiter.ccg | 4 +- gio/src/menumodel.ccg | 20 +- gio/src/mount.ccg | 260 +++---- gio/src/networkaddress.ccg | 13 +- gio/src/networkmonitor.ccg | 14 +- gio/src/notification.ccg | 3 +- gio/src/outputstream.ccg | 182 ++--- gio/src/permission.ccg | 1 - gio/src/proxy.ccg | 27 +- gio/src/proxyaddress.ccg | 2 +- gio/src/proxyresolver.ccg | 32 +- gio/src/resolver.ccg | 137 ++-- gio/src/resource.ccg | 38 +- gio/src/seekable.ccg | 1 - gio/src/settings.ccg | 38 +- gio/src/settingsschema.ccg | 2 +- gio/src/settingsschemakey.ccg | 2 +- gio/src/settingsschemasource.ccg | 2 +- gio/src/simpleaction.ccg | 34 +- gio/src/simpleactiongroup.ccg | 2 +- gio/src/simplepermission.ccg | 1 - gio/src/socket.ccg | 60 +- gio/src/socketaddressenumerator.ccg | 27 +- gio/src/socketclient.ccg | 97 +-- gio/src/socketconnectable.ccg | 3 +- gio/src/socketconnection.ccg | 21 +- gio/src/socketlistener.ccg | 256 +++---- gio/src/srvtarget.ccg | 2 +- gio/src/themedicon.ccg | 8 +- gio/src/tlscertificate.ccg | 2 +- gio/src/tlsclientconnection.ccg | 3 +- gio/src/tlsserverconnection.ccg | 3 +- gio/src/unixconnection.ccg | 35 +- gio/src/unixfdlist.ccg | 12 +- gio/src/unixfdmessage.ccg | 3 +- gio/src/unixsocketaddress.ccg | 8 +- gio/src/volume.ccg | 129 ++-- gio/src/volumemonitor.ccg | 4 +- glib/src/binding.ccg | 63 +- glib/src/bytearray.ccg | 24 +- glib/src/bytes.ccg | 5 +- glib/src/checksum.ccg | 15 +- glib/src/convert.ccg | 187 ++--- glib/src/date.ccg | 223 +++--- glib/src/datetime.ccg | 2 +- glib/src/fileutils.ccg | 97 +-- glib/src/iochannel.ccg | 250 ++++--- glib/src/keyfile.ccg | 271 +++---- glib/src/markup.ccg | 223 +++--- glib/src/miscutils.ccg | 217 +++--- glib/src/module.ccg | 17 +- glib/src/optioncontext.ccg | 95 +-- glib/src/optionentry.ccg | 52 +- glib/src/optiongroup.ccg | 792 ++++++++++---------- glib/src/regex.ccg | 207 +++--- glib/src/shell.ccg | 21 +- glib/src/spawn.ccg | 218 +++--- glib/src/thread.ccg | 184 +++-- glib/src/threads.ccg | 94 ++- glib/src/timezone.ccg | 2 +- glib/src/unicode.ccg | 1 - glib/src/uriutils.ccg | 16 +- glib/src/valuearray.ccg | 45 +- glib/src/variant.ccg | 237 +++--- glib/src/variantdict.ccg | 18 +- glib/src/variantiter.ccg | 10 +- glib/src/varianttype.ccg | 21 +- 116 files changed, 4451 insertions(+), 5113 deletions(-) diff --git a/gio/src/action.ccg b/gio/src/action.ccg index 5b5d3bd6..9dbb598a 100644 --- a/gio/src/action.ccg +++ b/gio/src/action.ccg @@ -24,7 +24,8 @@ namespace Gio { -void Action::activate() +void +Action::activate() { g_action_activate(gobj(), nullptr); } diff --git a/gio/src/actionmap.ccg b/gio/src/actionmap.ccg index 20194d43..da803bb8 100644 --- a/gio/src/actionmap.ccg +++ b/gio/src/actionmap.ccg @@ -23,105 +23,114 @@ namespace Gio { -Glib::RefPtr ActionMap::add_action(const Glib::ustring& name) +Glib::RefPtr +ActionMap::add_action(const Glib::ustring& name) { auto action = SimpleAction::create(name); add_action(action); return action; } -Glib::RefPtr ActionMap::add_action_with_parameter(const Glib::ustring& name, const ActivateWithParameterSlot& slot) +Glib::RefPtr +ActionMap::add_action_with_parameter( + const Glib::ustring& name, const ActivateWithParameterSlot& slot) { auto action = add_action(name); action->signal_activate().connect(slot); return action; } -Glib::RefPtr ActionMap::add_action(const Glib::ustring& name, const ActivateSlot& slot) +Glib::RefPtr +ActionMap::add_action(const Glib::ustring& name, const ActivateSlot& slot) { auto action = add_action(name); - action->signal_activate().connect( - sigc::hide(slot)); + action->signal_activate().connect(sigc::hide(slot)); return action; } - -Glib::RefPtr ActionMap::add_action_bool(const Glib::ustring& name, bool state) +Glib::RefPtr +ActionMap::add_action_bool(const Glib::ustring& name, bool state) { auto action = SimpleAction::create_bool(name, state); add_action(action); return action; } -//TODO: Use a slot that takes a bool? -Glib::RefPtr ActionMap::add_action_bool(const Glib::ustring& name, const ActivateSlot& slot, bool state) +// TODO: Use a slot that takes a bool? +Glib::RefPtr +ActionMap::add_action_bool(const Glib::ustring& name, const ActivateSlot& slot, bool state) { auto action = add_action_bool(name, state); - action->signal_activate().connect( - sigc::hide(slot)); + action->signal_activate().connect(sigc::hide(slot)); return action; } -//TODO: Use a slot that takes a string? -Glib::RefPtr ActionMap::add_action_radio_string(const Glib::ustring& name, const Glib::ustring& state) +// TODO: Use a slot that takes a string? +Glib::RefPtr +ActionMap::add_action_radio_string(const Glib::ustring& name, const Glib::ustring& state) { auto action = SimpleAction::create_radio_string(name, state); add_action(action); return action; } +namespace +{ -namespace { - -//Handle the normal activate signal, calling instead a slot that takes the specific type: -static void on_action_radio_string(const Glib::VariantBase& parameter, const Gio::ActionMap::ActivateWithStringParameterSlot& slot) +// Handle the normal activate signal, calling instead a slot that takes the specific type: +static void +on_action_radio_string( + const Glib::VariantBase& parameter, const Gio::ActionMap::ActivateWithStringParameterSlot& slot) { - //TODO: This syntax is odd: - const auto variantDerived = - parameter.cast_dynamic< Glib::Variant >(parameter); + // TODO: This syntax is odd: + const auto variantDerived = parameter.cast_dynamic>(parameter); const auto str = variantDerived.get(); slot(str); } -} //anonymous namespace +} // anonymous namespace -Glib::RefPtr ActionMap::add_action_radio_string(const Glib::ustring& name, const ActivateWithStringParameterSlot& slot, const Glib::ustring& state) +Glib::RefPtr +ActionMap::add_action_radio_string(const Glib::ustring& name, + const ActivateWithStringParameterSlot& slot, const Glib::ustring& state) { auto action = add_action_radio_string(name, state); - action->signal_activate().connect( - sigc::bind(sigc::ptr_fun(&on_action_radio_string), slot)); + action->signal_activate().connect(sigc::bind(sigc::ptr_fun(&on_action_radio_string), slot)); return action; } -namespace { +namespace +{ -//Handle the normal activate signal, calling instead a slot that takes the specific type: -static void on_action_radio_int(const Glib::VariantBase& parameter, const Gio::ActionMap::ActivateWithIntParameterSlot& slot) +// Handle the normal activate signal, calling instead a slot that takes the specific type: +static void +on_action_radio_int( + const Glib::VariantBase& parameter, const Gio::ActionMap::ActivateWithIntParameterSlot& slot) { - //TODO: This syntax is odd: - const auto variantDerived = - parameter.cast_dynamic< Glib::Variant >(parameter); + // TODO: This syntax is odd: + const auto variantDerived = parameter.cast_dynamic>(parameter); const auto str = variantDerived.get(); slot(str); } -} //anonymous namespace +} // anonymous namespace -//TODO: Use a slot that takes an integer? -Glib::RefPtr ActionMap::add_action_radio_integer(const Glib::ustring& name, gint32 state) +// TODO: Use a slot that takes an integer? +Glib::RefPtr +ActionMap::add_action_radio_integer(const Glib::ustring& name, gint32 state) { auto action = SimpleAction::create_radio_integer(name, state); add_action(action); return action; } -Glib::RefPtr ActionMap::add_action_radio_integer(const Glib::ustring& name, const ActivateWithIntParameterSlot& slot, gint32 state) +Glib::RefPtr +ActionMap::add_action_radio_integer( + const Glib::ustring& name, const ActivateWithIntParameterSlot& slot, gint32 state) { auto action = add_action_radio_integer(name, state); - action->signal_activate().connect( - sigc::bind(sigc::ptr_fun(&on_action_radio_int), slot)); + action->signal_activate().connect(sigc::bind(sigc::ptr_fun(&on_action_radio_int), slot)); return action; } - } // namespace Gio diff --git a/gio/src/appinfo.ccg b/gio/src/appinfo.ccg index c9c251ea..57cb8665 100644 --- a/gio/src/appinfo.ccg +++ b/gio/src/appinfo.ccg @@ -26,17 +26,14 @@ namespace Gio { Glib::RefPtr -AppInfo::create_from_commandline(const std::string& commandline, - const std::string& application_name, - AppInfoCreateFlags flags) +AppInfo::create_from_commandline( + const std::string& commandline, const std::string& application_name, AppInfoCreateFlags flags) { GAppInfo* capp_info = nullptr; GError* gerror = nullptr; - capp_info = g_app_info_create_from_commandline(commandline.c_str(), - application_name.c_str(), - static_cast(flags), - &gerror); + capp_info = g_app_info_create_from_commandline(commandline.c_str(), application_name.c_str(), + static_cast(flags), &gerror); if (gerror) ::Glib::Error::throw_exception(gerror); @@ -44,62 +41,66 @@ AppInfo::create_from_commandline(const std::string& commandline, return Glib::wrap(capp_info); } -Glib::RefPtr AppInfo::create_duplicate() const +Glib::RefPtr +AppInfo::create_duplicate() const { - return Glib::wrap(g_app_info_dup(const_cast(gobj()))); + return Glib::wrap(g_app_info_dup(const_cast(gobj()))); } -bool AppInfo::launch(const Glib::RefPtr& file, const Glib::RefPtr& launch_context) +bool +AppInfo::launch( + const Glib::RefPtr& file, const Glib::RefPtr& launch_context) { - std::vector< Glib::RefPtr > vec = {file}; + std::vector> vec = { file }; GError* gerror = nullptr; const bool retvalue = g_app_info_launch(gobj(), - Glib::ListHandler >::vector_to_list(vec).data(), + Glib::ListHandler>::vector_to_list(vec).data(), Glib::unwrap(launch_context), &(gerror)); - if(gerror) + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } -bool AppInfo::launch(const Glib::RefPtr& file) +bool +AppInfo::launch(const Glib::RefPtr& file) { - std::vector< Glib::RefPtr > vec = {file}; + std::vector> vec = { file }; GError* gerror = nullptr; const bool retvalue = g_app_info_launch(gobj(), - Glib::ListHandler >::vector_to_list(vec).data (), - nullptr, &(gerror)); - if(gerror) + Glib::ListHandler>::vector_to_list(vec).data(), nullptr, &(gerror)); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } -bool AppInfo::launch_uri(const std::string& uri, const Glib::RefPtr& launch_context) +bool +AppInfo::launch_uri(const std::string& uri, const Glib::RefPtr& launch_context) { - std::vector vec = {uri}; + std::vector vec = { uri }; GError* gerror = nullptr; - const bool retvalue = g_app_info_launch_uris(gobj(), - Glib::ListHandler::vector_to_list(vec).data (), - Glib::unwrap(launch_context), &(gerror)); - if(gerror) + const bool retvalue = + g_app_info_launch_uris(gobj(), Glib::ListHandler::vector_to_list(vec).data(), + Glib::unwrap(launch_context), &(gerror)); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } -bool AppInfo::launch_uri(const std::string& uri) +bool +AppInfo::launch_uri(const std::string& uri) { - std::vector vec = {uri}; + std::vector vec = { uri }; GError* gerror = nullptr; - const bool retvalue = g_app_info_launch_uris(gobj(), - Glib::ListHandler::vector_to_list(vec).data (), nullptr, - &(gerror)); - if(gerror) + const bool retvalue = g_app_info_launch_uris( + gobj(), Glib::ListHandler::vector_to_list(vec).data(), nullptr, &(gerror)); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; diff --git a/gio/src/application.ccg b/gio/src/application.ccg index d8dd6e26..7b80eed1 100644 --- a/gio/src/application.ccg +++ b/gio/src/application.ccg @@ -25,7 +25,7 @@ namespace // anonymous { -//TODO: At the next ABI break, implement the pimpl idiom. Then we need not use +// TODO: At the next ABI break, implement the pimpl idiom. Then we need not use // a GQuark for ExtraApplicationData, which should be renamed to // struct Gio::Application::Impl. // These are new data members that can't be added to Gio::Application now, @@ -36,7 +36,7 @@ struct ExtraApplicationData ~ExtraApplicationData() { - for(auto str : option_entry_strings) + for (auto str : option_entry_strings) { g_free(str); } @@ -46,19 +46,21 @@ struct ExtraApplicationData GQuark quark_extra_application_data = g_quark_from_static_string("glibmm__Gio::Application::quark_extra_application_data"); -void Application_delete_extra_application_data(gpointer data) +void +Application_delete_extra_application_data(gpointer data) { ExtraApplicationData* extra_application_data = static_cast(data); delete extra_application_data; } -static void Application_signal_open_callback(GApplication* self, GFile** files, - gint n_files, const gchar* hint, void* data) +static void +Application_signal_open_callback( + GApplication* self, GFile** files, gint n_files, const gchar* hint, void* data) { - typedef sigc::slot< void, const Gio::Application::type_vec_files&, const Glib::ustring& > SlotType; + typedef sigc::slot SlotType; Gio::Application::type_vec_files vec_files(n_files); - for(int i = 0; i < n_files; ++i) + for (int i = 0; i < n_files; ++i) { vec_files[i] = Glib::wrap(files[i], true); } @@ -66,16 +68,17 @@ static void Application_signal_open_callback(GApplication* self, GFile** files, const auto hint_str = (hint ? hint : Glib::ustring()); // Do not try to call a signal on a disassociated wrapper. - if(Glib::ObjectBase::_get_current_wrapper((GObject*) self)) + if (Glib::ObjectBase::_get_current_wrapper((GObject*)self)) { try { - if(const auto slot = Glib::SignalProxyNormal::data_to_slot(data)) { + if (const auto slot = Glib::SignalProxyNormal::data_to_slot(data)) + { (*static_cast(slot))(vec_files, hint_str); return; } } - catch(...) + catch (...) { Glib::exception_handlers_invoke(); } @@ -84,11 +87,12 @@ static void Application_signal_open_callback(GApplication* self, GFile** files, return; } -static void Application_signal_open_notify_callback(GApplication* self, GFile** files, - gint n_files, const gchar *hint, void* data) +static void +Application_signal_open_notify_callback( + GApplication* self, GFile** files, gint n_files, const gchar* hint, void* data) { using namespace Gio; - typedef sigc::slot< void, const Application::type_vec_files&, const Glib::ustring& > SlotType; + typedef sigc::slot SlotType; Application::type_vec_files vec_files(n_files); for (int i = 0; i < n_files; i++) @@ -99,17 +103,17 @@ static void Application_signal_open_notify_callback(GApplication* self, GFile** const auto hint_str = (hint ? hint : Glib::ustring()); // Do not try to call a signal on a disassociated wrapper. - if(Glib::ObjectBase::_get_current_wrapper((GObject*) self)) + if (Glib::ObjectBase::_get_current_wrapper((GObject*)self)) { try { - if(const auto slot = Glib::SignalProxyNormal::data_to_slot(data)) + if (const auto slot = Glib::SignalProxyNormal::data_to_slot(data)) { (*static_cast(slot))(vec_files, hint_str); return; } } - catch(...) + catch (...) { Glib::exception_handlers_invoke(); } @@ -118,12 +122,9 @@ static void Application_signal_open_notify_callback(GApplication* self, GFile** return; } -static const Glib::SignalProxyInfo Application_signal_open_info = -{ - "open", - (GCallback) &Application_signal_open_callback, - (GCallback) &Application_signal_open_notify_callback -}; +static const Glib::SignalProxyInfo Application_signal_open_info = { "open", + (GCallback)&Application_signal_open_callback, + (GCallback)&Application_signal_open_notify_callback }; // The add_main_option_entry*() methods that take a slot parameter are handled // similarly to the corresponding Glib::OptionGroup::add_entry*() methods. @@ -143,7 +144,8 @@ public: short_name_(short_name), slot_string_(new Glib::OptionGroup::SlotOptionArgString(slot)), slot_filename_(nullptr) - { } + { + } explicit OptionArgCallbackData(const Gio::Application* application, gchar short_name, const Glib::OptionGroup::SlotOptionArgFilename& slot) @@ -151,17 +153,19 @@ public: short_name_(short_name), slot_string_(nullptr), slot_filename_(new Glib::OptionGroup::SlotOptionArgFilename(slot)) - { } + { + } - const Gio::Application* get_application() const { return application_; } + const Gio::Application* get_application() const { return application_; } gchar get_short_name() const { return short_name_; } bool is_filename_option() const { return slot_filename_ != nullptr; } - const Glib::OptionGroup::SlotOptionArgString* get_slot_string() const - { return slot_string_; } + const Glib::OptionGroup::SlotOptionArgString* get_slot_string() const { return slot_string_; } const Glib::OptionGroup::SlotOptionArgFilename* get_slot_filename() const - { return slot_filename_; } + { + return slot_filename_; + } ~OptionArgCallbackData() { @@ -189,8 +193,9 @@ OptionArgCallbackDataMap option_arg_callback_data; // Accesses to option_arg_callback_data must be thread-safe. std::mutex option_arg_callback_data_mutex; -gboolean Application_option_arg_callback(const gchar* option_name, const gchar* value, - gpointer /* data */, GError** error) +gboolean +Application_option_arg_callback( + const gchar* option_name, const gchar* value, gpointer /* data */, GError** error) { const Glib::ustring cpp_option_name(option_name); @@ -201,15 +206,15 @@ gboolean Application_option_arg_callback(const gchar* option_name, const gchar* if (option_name[1] == '-') { // Long option name. - const auto long_option_name = Glib::ustring(option_name+2); + const auto long_option_name = Glib::ustring(option_name + 2); iterFind = option_arg_callback_data.find(long_option_name); } else { // Short option name. const auto short_option_name = option_name[1]; - for (iterFind = option_arg_callback_data.begin(); - iterFind != option_arg_callback_data.end(); ++iterFind) + for (iterFind = option_arg_callback_data.begin(); iterFind != option_arg_callback_data.end(); + ++iterFind) { if (iterFind->second->get_short_name() == short_option_name) break; @@ -219,7 +224,9 @@ gboolean Application_option_arg_callback(const gchar* option_name, const gchar* if (iterFind == option_arg_callback_data.end()) { Glib::OptionError(Glib::OptionError::UNKNOWN_OPTION, "Application_option_arg_callback(): " - "Unknown option " + cpp_option_name).propagate(error); + "Unknown option " + + cpp_option_name) + .propagate(error); return false; } @@ -258,24 +265,20 @@ gboolean Application_option_arg_callback(const gchar* option_name, const gchar* namespace Gio { - -const Glib::Class& Application::custom_class_init() +const Glib::Class& +Application::custom_class_init() { Glib::init(); Gio::init(); return application_class_.init(); } - Application::Application(const Glib::ustring& application_id, ApplicationFlags flags) -: - // Mark this class as non-derived to allow C++ vfuncs to be skipped. +: // Mark this class as non-derived to allow C++ vfuncs to be skipped. Glib::ObjectBase(nullptr), Glib::Object(Glib::ConstructParams(custom_class_init(), "application_id", - Glib::c_str_or_nullptr(application_id), - "flags", ((GApplicationFlags)(flags)), nullptr)) + Glib::c_str_or_nullptr(application_id), "flags", ((GApplicationFlags)(flags)), nullptr)) { - } Application::~Application() noexcept @@ -295,17 +298,18 @@ Application::~Application() noexcept } } -//static -void Application::unset_default() +// static +void +Application::unset_default() { g_application_set_default(nullptr); } -void Application_Class::open_callback(GApplication* self, GFile** files, - gint n_files, const gchar *hint) +void +Application_Class::open_callback(GApplication* self, GFile** files, gint n_files, const gchar* hint) { - const auto obj_base = static_cast( - Glib::ObjectBase::_get_current_wrapper((GObject*)self)); + const auto obj_base = + static_cast(Glib::ObjectBase::_get_current_wrapper((GObject*)self)); // Non-gtkmmproc-generated custom classes implicitly call the default // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc- @@ -313,16 +317,17 @@ void Application_Class::open_callback(GApplication* self, GFile** files, // parameter conversions if there is no possibility of the virtual function // being overridden: - if(obj_base && obj_base->is_derived_()) + if (obj_base && obj_base->is_derived_()) { const auto obj = dynamic_cast(obj_base); - if(obj) // This can be nullptr during destruction. + if (obj) // This can be nullptr during destruction. { try // Trap C++ exceptions which would normally be lost because this is a C callback. { // Call the virtual member method, which derived classes might override. Application::type_vec_files vec_files(n_files); - for (int i = 0; i < n_files; i++) { + for (int i = 0; i < n_files; i++) + { vec_files[i] = Glib::wrap(files[i], true); } @@ -331,66 +336,72 @@ void Application_Class::open_callback(GApplication* self, GFile** files, obj->on_open(vec_files, hint_str); return; } - catch(...) + catch (...) { Glib::exception_handlers_invoke(); } } } - const auto base = static_cast( - g_type_class_peek_parent(G_OBJECT_GET_CLASS(self)) // Get the parent class of the object class (The original underlying C class). + const auto base = static_cast(g_type_class_peek_parent(G_OBJECT_GET_CLASS( + self)) // Get the parent class of the object class (The original underlying C class). ); // Call the original underlying C function: - if(base && base->open) + if (base && base->open) (*base->open)(self, files, n_files, hint); } -Glib::SignalProxy< void, const Application::type_vec_files&, const Glib::ustring& > Application::signal_open() +Glib::SignalProxy +Application::signal_open() { - return Glib::SignalProxy< void, const Application::type_vec_files&, const Glib::ustring& >(this, &Application_signal_open_info); + return Glib::SignalProxy( + this, &Application_signal_open_info); } -void Gio::Application::on_open(const Application::type_vec_files& files, const Glib::ustring& hint) +void +Gio::Application::on_open(const Application::type_vec_files& files, const Glib::ustring& hint) { - const auto base = static_cast( - g_type_class_peek_parent(G_OBJECT_GET_CLASS(gobject_)) // Get the parent class of the object class (The original underlying C class). - ); + const auto base = static_cast(g_type_class_peek_parent(G_OBJECT_GET_CLASS( + gobject_)) // Get the parent class of the object class (The original underlying C class). + ); - if(base && base->open) { + if (base && base->open) + { (*base->open)(gobj(), - Glib::ArrayHandler::vector_to_array(files).data(), - files.size(), + Glib::ArrayHandler::vector_to_array(files).data(), files.size(), hint.c_str()); } } -void Application::open(const type_vec_files& files, const Glib::ustring& hint) +void +Application::open(const type_vec_files& files, const Glib::ustring& hint) { g_application_open(gobj(), - Glib::ArrayHandler::vector_to_array(files).data(), - files.size(), + Glib::ArrayHandler::vector_to_array(files).data(), files.size(), hint.c_str()); } -void Application::open(const Glib::RefPtr& file, const Glib::ustring& hint) +void +Application::open(const Glib::RefPtr& file, const Glib::ustring& hint) { type_vec_files files(1); files[0] = file; open(files, hint); } -void Application::add_main_option_entry(OptionType arg_type, const Glib::ustring& long_name, - gchar short_name, const Glib::ustring& description, const Glib::ustring& arg_description, int flags) +void +Application::add_main_option_entry(OptionType arg_type, const Glib::ustring& long_name, + gchar short_name, const Glib::ustring& description, const Glib::ustring& arg_description, + int flags) { - add_main_option_entry_private((GOptionArg)arg_type, long_name, short_name, - description, arg_description, flags); + add_main_option_entry_private( + (GOptionArg)arg_type, long_name, short_name, description, arg_description, flags); } -void Application::add_main_option_entry( - const Glib::OptionGroup::SlotOptionArgString& slot, const Glib::ustring& long_name, - gchar short_name, const Glib::ustring& description, +void +Application::add_main_option_entry(const Glib::OptionGroup::SlotOptionArgString& slot, + const Glib::ustring& long_name, gchar short_name, const Glib::ustring& description, const Glib::ustring& arg_description, int flags) { { @@ -403,13 +414,13 @@ void Application::add_main_option_entry( option_arg_callback_data[long_name] = callback_data; } // option_arg_callback_data_mutex.unlock() - add_main_option_entry_private(G_OPTION_ARG_CALLBACK, long_name, short_name, - description, arg_description, flags & ~Glib::OptionEntry::FLAG_FILENAME); + add_main_option_entry_private(G_OPTION_ARG_CALLBACK, long_name, short_name, description, + arg_description, flags & ~Glib::OptionEntry::FLAG_FILENAME); } -void Application::add_main_option_entry_filename( - const Glib::OptionGroup::SlotOptionArgFilename& slot, const Glib::ustring& long_name, - gchar short_name, const Glib::ustring& description, +void +Application::add_main_option_entry_filename(const Glib::OptionGroup::SlotOptionArgFilename& slot, + const Glib::ustring& long_name, gchar short_name, const Glib::ustring& description, const Glib::ustring& arg_description, int flags) { { @@ -422,14 +433,17 @@ void Application::add_main_option_entry_filename( option_arg_callback_data[long_name] = callback_data; } // option_arg_callback_data_mutex.unlock() - add_main_option_entry_private(G_OPTION_ARG_CALLBACK, long_name, short_name, - description, arg_description, flags | Glib::OptionEntry::FLAG_FILENAME); + add_main_option_entry_private(G_OPTION_ARG_CALLBACK, long_name, short_name, description, + arg_description, flags | Glib::OptionEntry::FLAG_FILENAME); } -void Application::add_main_option_entry_private(GOptionArg arg, const Glib::ustring& long_name, - gchar short_name, const Glib::ustring& description, const Glib::ustring& arg_description, int flags) +void +Application::add_main_option_entry_private(GOptionArg arg, const Glib::ustring& long_name, + gchar short_name, const Glib::ustring& description, const Glib::ustring& arg_description, + int flags) { - // Create a temporary array, just so we can give the correct thing to g_application_add_main_option_entries(): + // Create a temporary array, just so we can give the correct thing to + // g_application_add_main_option_entries(): GOptionEntry array[2]; std::memset(array, 0, 2 * sizeof(GOptionEntry)); // null-termination @@ -485,7 +499,8 @@ void Application::add_main_option_entry_private(GOptionArg arg, const Glib::ustr g_application_add_main_option_entries(gobj(), array); } -void Application::unset_resource_base_path() +void +Application::unset_resource_base_path() { g_application_set_resource_base_path(gobj(), nullptr /* see the C docs. */); } diff --git a/gio/src/applicationcommandline.ccg b/gio/src/applicationcommandline.ccg index 1e16f2de..7fbee67e 100644 --- a/gio/src/applicationcommandline.ccg +++ b/gio/src/applicationcommandline.ccg @@ -21,14 +21,16 @@ namespace Gio { -void ApplicationCommandLine::print(const Glib::ustring& message) +void +ApplicationCommandLine::print(const Glib::ustring& message) { g_application_command_line_print(gobj(), "%s", message.c_str()); } -void ApplicationCommandLine::printerr(const Glib::ustring& message) +void +ApplicationCommandLine::printerr(const Glib::ustring& message) { g_application_command_line_printerr(gobj(), "%s", message.c_str()); } -} //namespace Gio +} // namespace Gio diff --git a/gio/src/asyncinitable.ccg b/gio/src/asyncinitable.ccg index 6710c170..79960709 100644 --- a/gio/src/asyncinitable.ccg +++ b/gio/src/asyncinitable.ccg @@ -24,58 +24,57 @@ namespace Gio { -void AsyncInitable::init_async(const SlotAsyncReady& slot, - const Glib::RefPtr& cancellable, int io_priority) +void +AsyncInitable::init_async( + const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_async_initable_init_async(gobj(), io_priority, Glib::unwrap(cancellable), - &SignalProxy_async_callback, slot_copy); + g_async_initable_init_async( + gobj(), io_priority, Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } -void AsyncInitable::init_async(const SlotAsyncReady& slot, int io_priority) +void +AsyncInitable::init_async(const SlotAsyncReady& slot, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_async_initable_init_async(gobj(), io_priority, nullptr, - &SignalProxy_async_callback, slot_copy); + g_async_initable_init_async(gobj(), io_priority, nullptr, &SignalProxy_async_callback, slot_copy); } -void AsyncInitable_Class::init_async_vfunc_callback(GAsyncInitable* self, - int io_priority, GCancellable* cancellable, GAsyncReadyCallback callback, - gpointer user_data) +void +AsyncInitable_Class::init_async_vfunc_callback(GAsyncInitable* self, int io_priority, + GCancellable* cancellable, GAsyncReadyCallback callback, gpointer user_data) { - const auto obj_base = static_cast( - Glib::ObjectBase::_get_current_wrapper((GObject*)self)); + const auto obj_base = + static_cast(Glib::ObjectBase::_get_current_wrapper((GObject*)self)); // Non-gtkmmproc-generated custom classes implicitly call the default // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc- // generated classes can use this optimisation, which avoids the unnecessary // parameter conversions if there is no possibility of the virtual function // being overridden: - if(obj_base && obj_base->is_derived_()) + if (obj_base && obj_base->is_derived_()) { const auto obj = dynamic_cast(obj_base); - if(obj) // This can be nullptr during destruction. + if (obj) // This can be nullptr during destruction. { try // Trap C++ exceptions which would normally be lost because this is a C callback. { // Get the slot. - Gio::SlotAsyncReady* the_slot = - static_cast(user_data); + Gio::SlotAsyncReady* the_slot = static_cast(user_data); // Call the virtual member method, which derived classes might override. - obj->init_async_vfunc(*the_slot, Glib::wrap(cancellable, true), - io_priority); + obj->init_async_vfunc(*the_slot, Glib::wrap(cancellable, true), io_priority); return; } - catch(...) + catch (...) { Glib::exception_handlers_invoke(); } @@ -83,52 +82,56 @@ void AsyncInitable_Class::init_async_vfunc_callback(GAsyncInitable* self, } const auto base = static_cast( - g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface). -g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface. -) ); + g_type_interface_peek_parent( // Get the parent interface of the interface (The original + // underlying C interface). + g_type_interface_peek( + G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface. + )); // Call the original underlying C function: - if(base && base->init_async) + if (base && base->init_async) (*base->init_async)(self, io_priority, cancellable, callback, user_data); - } -void Gio::AsyncInitable::init_async_vfunc(const SlotAsyncReady& slot, - const Glib::RefPtr& cancellable, int io_priority) +void +Gio::AsyncInitable::init_async_vfunc( + const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, int io_priority) { const auto base = static_cast( - g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface). -g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface. -) ); + g_type_interface_peek_parent( // Get the parent interface of the interface (The original + // underlying C interface). + g_type_interface_peek( + G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface. + )); - if(base && base->init_async) + if (base && base->init_async) { - (*base->init_async)(gobj(), io_priority, - const_cast(Glib::unwrap(cancellable)), + (*base->init_async)(gobj(), io_priority, const_cast(Glib::unwrap(cancellable)), &SignalProxy_async_callback, const_cast(&slot)); } } -gboolean AsyncInitable_Class::init_finish_vfunc_callback(GAsyncInitable* self, - GAsyncResult* res, GError** error) +gboolean +AsyncInitable_Class::init_finish_vfunc_callback( + GAsyncInitable* self, GAsyncResult* res, GError** error) { - const auto obj_base = static_cast( - Glib::ObjectBase::_get_current_wrapper((GObject*)self)); + const auto obj_base = + static_cast(Glib::ObjectBase::_get_current_wrapper((GObject*)self)); // Non-gtkmmproc-generated custom classes implicitly call the default // Glib::ObjectBase constructor, which sets is_derived_. But gtkmmproc- // generated classes can use this optimisation, which avoids the unnecessary // parameter conversions if there is no possibility of the virtual function // being overridden: - if(obj_base && obj_base->is_derived_()) + if (obj_base && obj_base->is_derived_()) { const auto obj = dynamic_cast(obj_base); - if(obj) // This can be nullptr during destruction. + if (obj) // This can be nullptr during destruction. { try // Trap C++ exceptions which would normally be lost because this is a C callback. { // Call the virtual member method, which derived classes might override. return static_cast(obj->init_finish_vfunc(Glib::wrap(res, true))); } - catch(...) + catch (...) { Glib::exception_handlers_invoke(); } @@ -136,33 +139,36 @@ gboolean AsyncInitable_Class::init_finish_vfunc_callback(GAsyncInitable* self, } const auto base = static_cast( - g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface). -g_type_interface_peek(G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface. -) ); + g_type_interface_peek_parent( // Get the parent interface of the interface (The original + // underlying C interface). + g_type_interface_peek( + G_OBJECT_GET_CLASS(self), CppObjectType::get_type()) // Get the interface. + )); // Call the original underlying C function: - if(base && base->init_finish) + if (base && base->init_finish) return (*base->init_finish)(self, res, error); - typedef gboolean RType; return RType(); } -bool Gio::AsyncInitable::init_finish_vfunc(const Glib::RefPtr& res) +bool +Gio::AsyncInitable::init_finish_vfunc(const Glib::RefPtr& res) { const auto base = static_cast( - g_type_interface_peek_parent( // Get the parent interface of the interface (The original underlying C interface). -g_type_interface_peek(G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface. -) ); + g_type_interface_peek_parent( // Get the parent interface of the interface (The original + // underlying C interface). + g_type_interface_peek( + G_OBJECT_GET_CLASS(gobject_), CppObjectType::get_type()) // Get the interface. + )); - if(base && base->init_finish) + if (base && base->init_finish) { GError* gerror = nullptr; - bool const result = (*base->init_finish)(gobj(), Glib::unwrap(res), - &gerror); + bool const result = (*base->init_finish)(gobj(), Glib::unwrap(res), &gerror); - if(gerror) + if (gerror) ::Glib::Error::throw_exception(gerror); return result; diff --git a/gio/src/asyncresult.ccg b/gio/src/asyncresult.ccg index d6a4e463..252fb872 100644 --- a/gio/src/asyncresult.ccg +++ b/gio/src/asyncresult.ccg @@ -24,22 +24,26 @@ namespace Gio { -static GObject* unwrap_objectbase_custom(const Glib::RefPtr& cpp_instance) +static GObject* +unwrap_objectbase_custom(const Glib::RefPtr& cpp_instance) { return (cpp_instance ? cpp_instance->gobj() : nullptr); } -Glib::RefPtr AsyncResult::get_source_object_base() +Glib::RefPtr +AsyncResult::get_source_object_base() { auto cobj = g_async_result_get_source_object(gobj()); - auto cppobj = Glib::wrap_auto(cobj); //ObjectBase::_get_current_wrapper(cobj); - return Glib::RefPtr(cppobj); //g_async_result_get_source_object() gives us a ref, unusually. - //TODO: For some reason this fails: Glib::wrap(cobj); + auto cppobj = Glib::wrap_auto(cobj); // ObjectBase::_get_current_wrapper(cobj); + return Glib::RefPtr( + cppobj); // g_async_result_get_source_object() gives us a ref, unusually. + // TODO: For some reason this fails: Glib::wrap(cobj); } -Glib::RefPtr AsyncResult::get_source_object_base() const +Glib::RefPtr +AsyncResult::get_source_object_base() const { return const_cast(this)->get_source_object_base(); } -} //namespace Gio +} // namespace Gio diff --git a/gio/src/bufferedinputstream.ccg b/gio/src/bufferedinputstream.ccg index 11e7d400..862db1c5 100644 --- a/gio/src/bufferedinputstream.ccg +++ b/gio/src/bufferedinputstream.ccg @@ -23,44 +23,35 @@ namespace Gio { -Glib::RefPtr BufferedInputStream::create_sized(const Glib::RefPtr& base_stream, gsize buffer_size) +Glib::RefPtr +BufferedInputStream::create_sized(const Glib::RefPtr& base_stream, gsize buffer_size) { return Glib::RefPtr(new BufferedInputStream(base_stream, buffer_size)); } -void BufferedInputStream::fill_async(const SlotAsyncReady& slot, - gssize count, - const Glib::RefPtr& cancellable, - int io_priority) +void +BufferedInputStream::fill_async(const SlotAsyncReady& slot, gssize count, + const Glib::RefPtr& cancellable, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. - auto slot_copy = new SlotAsyncReady(slot); + auto slot_copy = new SlotAsyncReady(slot); - g_buffered_input_stream_fill_async(gobj(), - count, - io_priority, - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_buffered_input_stream_fill_async( + gobj(), count, io_priority, Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } -void BufferedInputStream::fill_async(const SlotAsyncReady& slot, - gssize count, - int io_priority) +void +BufferedInputStream::fill_async(const SlotAsyncReady& slot, gssize count, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. - auto slot_copy = new SlotAsyncReady(slot); + auto slot_copy = new SlotAsyncReady(slot); - g_buffered_input_stream_fill_async(gobj(), - count, - io_priority, - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_buffered_input_stream_fill_async( + gobj(), count, io_priority, nullptr, &SignalProxy_async_callback, slot_copy); } -} // namespace Gio +} // namespace Gio diff --git a/gio/src/bufferedoutputstream.ccg b/gio/src/bufferedoutputstream.ccg index c2708997..3985649b 100644 --- a/gio/src/bufferedoutputstream.ccg +++ b/gio/src/bufferedoutputstream.ccg @@ -23,9 +23,10 @@ namespace Gio { -Glib::RefPtr BufferedOutputStream::create_sized(const Glib::RefPtr& base_stream, gsize size) +Glib::RefPtr +BufferedOutputStream::create_sized(const Glib::RefPtr& base_stream, gsize size) { return Glib::RefPtr(new BufferedOutputStream(base_stream, size)); } -} // namespace Gio +} // namespace Gio diff --git a/gio/src/cancellable.ccg b/gio/src/cancellable.ccg index 787990e1..151f478b 100644 --- a/gio/src/cancellable.ccg +++ b/gio/src/cancellable.ccg @@ -20,22 +20,25 @@ #include #include -namespace Gio { +namespace Gio +{ extern "C" { -void delete_slot(gpointer data) +void +delete_slot(gpointer data) { - Cancellable::SlotCancelledCallback* callback = - reinterpret_cast(data); - delete callback; + Cancellable::SlotCancelledCallback* callback = + reinterpret_cast(data); + delete callback; } -void slot_cancelled_proxy(GCancellable * /*cancellable*/, gpointer data) +void +slot_cancelled_proxy(GCancellable* /*cancellable*/, gpointer data) { - Cancellable::SlotCancelledCallback* callback = - reinterpret_cast(data); - (*callback)(); + Cancellable::SlotCancelledCallback* callback = + reinterpret_cast(data); + (*callback)(); } } // extern "C" @@ -43,11 +46,8 @@ void slot_cancelled_proxy(GCancellable * /*cancellable*/, gpointer data) gulong Cancellable::connect(const SlotCancelledCallback& slot) { - auto slot_copy = new SlotCancelledCallback(slot); - return g_cancellable_connect (gobj(), - G_CALLBACK(slot_cancelled_proxy), - slot_copy, - &delete_slot); + auto slot_copy = new SlotCancelledCallback(slot); + return g_cancellable_connect(gobj(), G_CALLBACK(slot_cancelled_proxy), slot_copy, &delete_slot); } } // namespace Gio diff --git a/gio/src/charsetconverter.ccg b/gio/src/charsetconverter.ccg index 967d9c3e..e9d69db8 100644 --- a/gio/src/charsetconverter.ccg +++ b/gio/src/charsetconverter.ccg @@ -20,10 +20,9 @@ namespace Gio { -CharsetConverter::CharsetConverter(const Glib::ustring& to_charset, - const Glib::ustring& from_charset) -: _CONSTRUCT("to-charset", to_charset.c_str(), "from-charset", - from_charset.c_str()) +CharsetConverter::CharsetConverter( + const Glib::ustring& to_charset, const Glib::ustring& from_charset) +: _CONSTRUCT("to-charset", to_charset.c_str(), "from-charset", from_charset.c_str()) { } diff --git a/gio/src/datainputstream.ccg b/gio/src/datainputstream.ccg index 2209e48a..3665ac98 100644 --- a/gio/src/datainputstream.ccg +++ b/gio/src/datainputstream.ccg @@ -24,193 +24,200 @@ namespace Gio { -bool DataInputStream::read_line(std::string& line, const Glib::RefPtr& cancellable) +bool +DataInputStream::read_line(std::string& line, const Glib::RefPtr& cancellable) { GError* gerror = nullptr; char* c_line = g_data_input_stream_read_line(gobj(), - nullptr, // pass nullptr since we can easily determine the length from the returned std::string - Glib::unwrap(cancellable), - &gerror); - if(gerror) + nullptr, // pass nullptr since we can easily determine the length from the returned std::string + Glib::unwrap(cancellable), &gerror); + if (gerror) ::Glib::Error::throw_exception(gerror); - if (c_line) { - line = c_line; - g_free (c_line); - return true; - } - // end of stream reached, return failure status - return false; + if (c_line) + { + line = c_line; + g_free(c_line); + return true; + } + // end of stream reached, return failure status + return false; } -bool DataInputStream::read_line(std::string& line) +bool +DataInputStream::read_line(std::string& line) { GError* gerror = nullptr; char* c_line = g_data_input_stream_read_line(gobj(), - nullptr, // pass nullptr since we can easily determine the length from the returned std::string - nullptr, - &gerror); - if(gerror) + nullptr, // pass nullptr since we can easily determine the length from the returned std::string + nullptr, &gerror); + if (gerror) ::Glib::Error::throw_exception(gerror); - if (c_line) { - line = c_line; - g_free(c_line); - return true; - } - // end of stream reached, return failure status - return false; + if (c_line) + { + line = c_line; + g_free(c_line); + return true; + } + // end of stream reached, return failure status + return false; } -void DataInputStream::read_line_async(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, int io_priority) +void +DataInputStream::read_line_async( + const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_data_input_stream_read_line_async(gobj(), - io_priority, - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_data_input_stream_read_line_async( + gobj(), io_priority, Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } -bool DataInputStream::read_line_finish(const Glib::RefPtr& result, std::string& data) +bool +DataInputStream::read_line_finish(const Glib::RefPtr& result, std::string& data) { GError* gerror = nullptr; gsize size = 0; - gchar* buffer = g_data_input_stream_read_line_finish(gobj(), Glib::unwrap(result), &size, &(gerror)); - if(gerror) + gchar* buffer = + g_data_input_stream_read_line_finish(gobj(), Glib::unwrap(result), &size, &(gerror)); + if (gerror) ::Glib::Error::throw_exception(gerror); bool retval = false; - if(buffer && size) + if (buffer && size) { retval = (buffer != nullptr); data = std::string(buffer, size); - g_free (buffer); + g_free(buffer); } return retval; } -bool DataInputStream::read_until(std::string& data, const std::string& stop_chars, const Glib::RefPtr& cancellable) +bool +DataInputStream::read_until( + std::string& data, const std::string& stop_chars, const Glib::RefPtr& cancellable) { GError* gerror = nullptr; - char* c_str = g_data_input_stream_read_until(gobj(), - stop_chars.c_str(), - nullptr, // pass nullptr since we can easily determine the length from the returned std::string - Glib::unwrap(cancellable), - &gerror); - if(gerror) + char* c_str = g_data_input_stream_read_until(gobj(), stop_chars.c_str(), + nullptr, // pass nullptr since we can easily determine the length from the returned std::string + Glib::unwrap(cancellable), &gerror); + if (gerror) ::Glib::Error::throw_exception(gerror); - if (c_str) { - data = c_str; - g_free (c_str); - return true; - } - // end of stream reached, return failure status - return false; + if (c_str) + { + data = c_str; + g_free(c_str); + return true; + } + // end of stream reached, return failure status + return false; } /** non-cancellable version of read_until() */ -bool DataInputStream::read_until(std::string& data, const std::string& stop_chars) +bool +DataInputStream::read_until(std::string& data, const std::string& stop_chars) { GError* gerror = nullptr; - char* c_str = g_data_input_stream_read_until(gobj(), - stop_chars.c_str(), - nullptr, // pass nullptr since we can easily determine the length from the returned std::string - nullptr, - &gerror); - if(gerror) + char* c_str = g_data_input_stream_read_until(gobj(), stop_chars.c_str(), + nullptr, // pass nullptr since we can easily determine the length from the returned std::string + nullptr, &gerror); + if (gerror) ::Glib::Error::throw_exception(gerror); - if (c_str) { - data = c_str; - g_free (c_str); - return true; - } - // end of stream reached, return failure status - return false; + if (c_str) + { + data = c_str; + g_free(c_str); + return true; + } + // end of stream reached, return failure status + return false; } -void DataInputStream::read_until_async(const std::string& stop_chars, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, int io_priority) +void +DataInputStream::read_until_async(const std::string& stop_chars, const SlotAsyncReady& slot, + const Glib::RefPtr& cancellable, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_data_input_stream_read_until_async(gobj(), stop_chars.c_str(), - io_priority, - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_data_input_stream_read_until_async(gobj(), stop_chars.c_str(), io_priority, + Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } -bool DataInputStream::read_until_finish(const Glib::RefPtr& result, std::string& data) +bool +DataInputStream::read_until_finish(const Glib::RefPtr& result, std::string& data) { GError* gerror = nullptr; gsize size = 0; - gchar* buffer = g_data_input_stream_read_until_finish(gobj(), Glib::unwrap(result), &size, &(gerror)); - if(gerror) + gchar* buffer = + g_data_input_stream_read_until_finish(gobj(), Glib::unwrap(result), &size, &(gerror)); + if (gerror) ::Glib::Error::throw_exception(gerror); bool retval = false; - if(buffer && size) + if (buffer && size) { retval = (buffer != nullptr); data = std::string(buffer, size); - g_free (buffer); + g_free(buffer); } return retval; } - -bool DataInputStream::read_upto(std::string& data, const std::string& stop_chars, const Glib::RefPtr& cancellable) +bool +DataInputStream::read_upto( + std::string& data, const std::string& stop_chars, const Glib::RefPtr& cancellable) { GError* gerror = nullptr; - char* c_str = g_data_input_stream_read_upto(gobj(), - stop_chars.c_str(), -1, /* null-terminated */ - nullptr, // pass nullptr since we can easily determine the length from the returned std::string - Glib::unwrap(cancellable), - &gerror); - if(gerror) + char* c_str = g_data_input_stream_read_upto(gobj(), stop_chars.c_str(), -1, /* null-terminated */ + nullptr, // pass nullptr since we can easily determine the length from the returned std::string + Glib::unwrap(cancellable), &gerror); + if (gerror) ::Glib::Error::throw_exception(gerror); - if (c_str) { - data = c_str; - g_free (c_str); - return true; - } - // end of stream reached, return failure status - return false; + if (c_str) + { + data = c_str; + g_free(c_str); + return true; + } + // end of stream reached, return failure status + return false; } /** non-cancellable version of read_upto() */ -bool DataInputStream::read_upto(std::string& data, const std::string& stop_chars) +bool +DataInputStream::read_upto(std::string& data, const std::string& stop_chars) { GError* gerror = nullptr; - char* c_str = g_data_input_stream_read_upto(gobj(), - stop_chars.c_str(), -1, /* null-terminated */ + char* c_str = g_data_input_stream_read_upto(gobj(), stop_chars.c_str(), -1, /* null-terminated */ nullptr, // pass nullptr since we can easily determine the length from the returned std::string - nullptr, - &gerror); + nullptr, &gerror); - if(gerror) + if (gerror) ::Glib::Error::throw_exception(gerror); - if (c_str) { - data = c_str; - g_free (c_str); - return true; + if (c_str) + { + data = c_str; + g_free(c_str); + return true; } // end of stream reached, return failure status return false; } -void DataInputStream::read_upto_async(const std::string& stop_chars, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, int io_priority) +void +DataInputStream::read_upto_async(const std::string& stop_chars, const SlotAsyncReady& slot, + const Glib::RefPtr& cancellable, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter @@ -218,30 +225,28 @@ void DataInputStream::read_upto_async(const std::string& stop_chars, const SlotA auto slot_copy = new SlotAsyncReady(slot); g_data_input_stream_read_upto_async(gobj(), stop_chars.c_str(), -1, /* null-terminated */ - io_priority, - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + io_priority, Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } -bool DataInputStream::read_upto_finish(const Glib::RefPtr& result, std::string& data) +bool +DataInputStream::read_upto_finish(const Glib::RefPtr& result, std::string& data) { GError* gerror = nullptr; gsize size = 0; - gchar* buffer = g_data_input_stream_read_upto_finish(gobj(), Glib::unwrap(result), &size, &(gerror)); - if(gerror) + gchar* buffer = + g_data_input_stream_read_upto_finish(gobj(), Glib::unwrap(result), &size, &(gerror)); + if (gerror) ::Glib::Error::throw_exception(gerror); bool retval = false; - if(buffer && size) + if (buffer && size) { retval = (buffer != nullptr); data = std::string(buffer, size); - g_free (buffer); + g_free(buffer); } return retval; } - } // namespace Gio diff --git a/gio/src/dbusactiongroup.ccg b/gio/src/dbusactiongroup.ccg index fd077938..b8012ef9 100644 --- a/gio/src/dbusactiongroup.ccg +++ b/gio/src/dbusactiongroup.ccg @@ -21,4 +21,4 @@ namespace Gio { -}// namespace Gio +} // namespace Gio diff --git a/gio/src/dbusaddress.ccg b/gio/src/dbusaddress.ccg index b69fb27c..30f2366c 100644 --- a/gio/src/dbusaddress.ccg +++ b/gio/src/dbusaddress.ccg @@ -30,150 +30,151 @@ namespace DBus namespace Address { -bool is_address(const std::string& string) +bool +is_address(const std::string& string) { return static_cast(g_dbus_is_address(string.c_str())); } -bool is_supported(const std::string& address) +bool +is_supported(const std::string& address) { GError* gerror = nullptr; bool const result = g_dbus_is_supported_address(address.c_str(), &gerror); - if(gerror) + if (gerror) ::Glib::Error::throw_exception(gerror); return result; } -void get_stream(const std::string& address, const SlotAsyncReady slot, +void +get_stream(const std::string& address, const SlotAsyncReady slot, const Glib::RefPtr& cancellable) { auto slot_copy = new SlotAsyncReady(slot); - g_dbus_address_get_stream(address.c_str(), Glib::unwrap(cancellable), - &SignalProxy_async_callback, slot_copy); + g_dbus_address_get_stream( + address.c_str(), Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } -void get_stream(const std::string& address, const SlotAsyncReady slot) +void +get_stream(const std::string& address, const SlotAsyncReady slot) { auto slot_copy = new SlotAsyncReady(slot); - g_dbus_address_get_stream(address.c_str(), nullptr, &SignalProxy_async_callback, - slot_copy); + g_dbus_address_get_stream(address.c_str(), nullptr, &SignalProxy_async_callback, slot_copy); } -Glib::RefPtr get_stream_finish(const Glib::RefPtr& res, - std::string& out_guid) +Glib::RefPtr +get_stream_finish(const Glib::RefPtr& res, std::string& out_guid) { GError* gerror = nullptr; gchar* g_out_guid = nullptr; auto result = - Glib::wrap(g_dbus_address_get_stream_finish(Glib::unwrap(res), - &g_out_guid, &gerror)); + Glib::wrap(g_dbus_address_get_stream_finish(Glib::unwrap(res), &g_out_guid, &gerror)); - if(gerror) + if (gerror) ::Glib::Error::throw_exception(gerror); out_guid = g_out_guid; return result; } -Glib::RefPtr get_stream_finish(const Glib::RefPtr& res) +Glib::RefPtr +get_stream_finish(const Glib::RefPtr& res) { GError* gerror = nullptr; - auto result = - Glib::wrap(g_dbus_address_get_stream_finish(Glib::unwrap(res), nullptr, - &gerror)); + auto result = Glib::wrap(g_dbus_address_get_stream_finish(Glib::unwrap(res), nullptr, &gerror)); - if(gerror) + if (gerror) ::Glib::Error::throw_exception(gerror); return result; } -Glib::RefPtr get_stream_sync(const std::string& address, - const Glib::RefPtr& cancellable, std::string& out_guid) +Glib::RefPtr +get_stream_sync( + const std::string& address, const Glib::RefPtr& cancellable, std::string& out_guid) { GError* gerror = nullptr; gchar* g_out_guid = nullptr; - auto result = - Glib::wrap(g_dbus_address_get_stream_sync(address.c_str(), - &g_out_guid, Glib::unwrap(cancellable), &gerror)); + auto result = Glib::wrap(g_dbus_address_get_stream_sync( + address.c_str(), &g_out_guid, Glib::unwrap(cancellable), &gerror)); - if(gerror) + if (gerror) ::Glib::Error::throw_exception(gerror); out_guid = g_out_guid; return result; } -Glib::RefPtr get_stream_sync(const std::string& address, - std::string& out_guid) +Glib::RefPtr +get_stream_sync(const std::string& address, std::string& out_guid) { GError* gerror = nullptr; gchar* g_out_guid = nullptr; auto result = - Glib::wrap(g_dbus_address_get_stream_sync(address.c_str(), - &g_out_guid, nullptr, &gerror)); + Glib::wrap(g_dbus_address_get_stream_sync(address.c_str(), &g_out_guid, nullptr, &gerror)); - if(gerror) + if (gerror) ::Glib::Error::throw_exception(gerror); out_guid = g_out_guid; return result; } -Glib::RefPtr get_stream_sync(const std::string& address, - const Glib::RefPtr& cancellable) +Glib::RefPtr +get_stream_sync(const std::string& address, const Glib::RefPtr& cancellable) { GError* gerror = nullptr; - auto result = - Glib::wrap(g_dbus_address_get_stream_sync(address.c_str(), nullptr, - Glib::unwrap(cancellable), &gerror)); + auto result = Glib::wrap( + g_dbus_address_get_stream_sync(address.c_str(), nullptr, Glib::unwrap(cancellable), &gerror)); - if(gerror) + if (gerror) ::Glib::Error::throw_exception(gerror); return result; } -Glib::RefPtr get_stream_sync(const std::string& address) +Glib::RefPtr +get_stream_sync(const std::string& address) { GError* gerror = nullptr; auto result = Glib::wrap(g_dbus_address_get_stream_sync(address.c_str(), nullptr, nullptr, &gerror)); - if(gerror) + if (gerror) ::Glib::Error::throw_exception(gerror); return result; } -std::string get_for_bus_sync(BusType bus_type, - const Glib::RefPtr& cancellable) +std::string +get_for_bus_sync(BusType bus_type, const Glib::RefPtr& cancellable) { GError* gerror = nullptr; std::string result(g_dbus_address_get_for_bus_sync( static_cast(bus_type), Glib::unwrap(cancellable), &gerror)); - if(gerror) + if (gerror) ::Glib::Error::throw_exception(gerror); return result; } -std::string get_for_bus_sync(BusType bus_type) +std::string +get_for_bus_sync(BusType bus_type) { GError* gerror = nullptr; - std::string result(g_dbus_address_get_for_bus_sync( - static_cast(bus_type), nullptr, &gerror)); + std::string result( + g_dbus_address_get_for_bus_sync(static_cast(bus_type), nullptr, &gerror)); - if(gerror) + if (gerror) ::Glib::Error::throw_exception(gerror); return result; diff --git a/gio/src/dbusauthobserver.ccg b/gio/src/dbusauthobserver.ccg index 5a181e47..7ca00c72 100644 --- a/gio/src/dbusauthobserver.ccg +++ b/gio/src/dbusauthobserver.ccg @@ -21,7 +21,7 @@ #include #include -//To help the generated code: +// To help the generated code: typedef Gio::Credentials Credentials; typedef Gio::IOStream IOStream; diff --git a/gio/src/dbusconnection.ccg b/gio/src/dbusconnection.ccg index a2f67b36..557d6958 100644 --- a/gio/src/dbusconnection.ccg +++ b/gio/src/dbusconnection.ccg @@ -29,13 +29,12 @@ namespace { -extern "C" -{ +extern "C" { -static void DBusConnection_Signal_giomm_callback(GDBusConnection* connection, - const char* sender_name, const char* object_path, - const char* interface_name, const char* signal_name, GVariant* parameters, - void* user_data) +static void +DBusConnection_Signal_giomm_callback(GDBusConnection* connection, const char* sender_name, + const char* object_path, const char* interface_name, const char* signal_name, + GVariant* parameters, void* user_data) { Gio::DBus::Connection::SlotSignal* the_slot = static_cast(user_data); @@ -46,20 +45,21 @@ static void DBusConnection_Signal_giomm_callback(GDBusConnection* connection, (object_path ? object_path : ""), (interface_name ? interface_name : ""), (signal_name ? signal_name : ""), Glib::VariantContainerBase(parameters, true)); } - catch(...) + catch (...) { Glib::exception_handlers_invoke(); } } -static void DBusConnection_Signal_giomm_callback_destroy(void* data) +static void +DBusConnection_Signal_giomm_callback_destroy(void* data) { delete static_cast(data); } -static GDBusMessage* DBusConnection_Message_Filter_giomm_callback( - GDBusConnection* connection, GDBusMessage* message, gboolean incoming, - void* user_data) +static GDBusMessage* +DBusConnection_Message_Filter_giomm_callback( + GDBusConnection* connection, GDBusMessage* message, gboolean incoming, void* user_data) { Gio::DBus::Connection::SlotMessageFilter* the_slot = static_cast(user_data); @@ -67,11 +67,10 @@ static GDBusMessage* DBusConnection_Message_Filter_giomm_callback( try { auto result = (*the_slot)( - Glib::wrap(connection, true), Glib::wrap(message, true), - static_cast(incoming)); + Glib::wrap(connection, true), Glib::wrap(message, true), static_cast(incoming)); return (result) ? result->gobj_copy() : nullptr; } - catch(...) + catch (...) { Glib::exception_handlers_invoke(); } @@ -79,13 +78,13 @@ static GDBusMessage* DBusConnection_Message_Filter_giomm_callback( return message; } -static void DBusConnection_Message_Filter_giomm_callback_destroy(void* data) +static void +DBusConnection_Message_Filter_giomm_callback_destroy(void* data) { delete static_cast(data); } } // extern "C" - } namespace Gio @@ -94,213 +93,148 @@ namespace Gio namespace DBus { -Connection::Connection(const Glib::RefPtr& stream, - const std::string& guid, - const Glib::RefPtr& observer, - const SlotAsyncReady& slot, - const Glib::RefPtr& cancellable, - ConnectionFlags flags) -: - _CONSTRUCT("stream", Glib::unwrap(stream), - "guid", Glib::c_str_or_nullptr(guid), - "flags", static_cast(flags), - "authentication-observer", Glib::unwrap(observer)) +Connection::Connection(const Glib::RefPtr& stream, const std::string& guid, + const Glib::RefPtr& observer, const SlotAsyncReady& slot, + const Glib::RefPtr& cancellable, ConnectionFlags flags) +: _CONSTRUCT("stream", Glib::unwrap(stream), "guid", Glib::c_str_or_nullptr(guid), "flags", + static_cast(flags), "authentication-observer", Glib::unwrap(observer)) { init_async(slot, cancellable); } -Connection::Connection(const Glib::RefPtr& stream, - const std::string& guid, - const SlotAsyncReady& slot, - const Glib::RefPtr& cancellable, - ConnectionFlags flags) -: - _CONSTRUCT("stream", Glib::unwrap(stream), - "guid", Glib::c_str_or_nullptr(guid), - "flags", static_cast(flags), - "authentication-observer", static_cast(nullptr)) +Connection::Connection(const Glib::RefPtr& stream, const std::string& guid, + const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, ConnectionFlags flags) +: _CONSTRUCT("stream", Glib::unwrap(stream), "guid", Glib::c_str_or_nullptr(guid), "flags", + static_cast(flags), "authentication-observer", + static_cast(nullptr)) { init_async(slot, cancellable); } -Connection::Connection(const Glib::RefPtr& stream, - const std::string& guid, - const Glib::RefPtr& observer, - const SlotAsyncReady& slot, - ConnectionFlags flags) -: - _CONSTRUCT("stream", Glib::unwrap(stream), - "guid", Glib::c_str_or_nullptr(guid), - "flags", static_cast(flags), - "authentication-observer", Glib::unwrap(observer)) +Connection::Connection(const Glib::RefPtr& stream, const std::string& guid, + const Glib::RefPtr& observer, const SlotAsyncReady& slot, ConnectionFlags flags) +: _CONSTRUCT("stream", Glib::unwrap(stream), "guid", Glib::c_str_or_nullptr(guid), "flags", + static_cast(flags), "authentication-observer", Glib::unwrap(observer)) { init_async(slot); } -Connection::Connection(const Glib::RefPtr& stream, - const std::string& guid, - const SlotAsyncReady& slot, - ConnectionFlags flags) -: - _CONSTRUCT("stream", Glib::unwrap(stream), - "guid", Glib::c_str_or_nullptr(guid), - "flags", static_cast(flags), - "authentication-observer", static_cast(nullptr)) +Connection::Connection(const Glib::RefPtr& stream, const std::string& guid, + const SlotAsyncReady& slot, ConnectionFlags flags) +: _CONSTRUCT("stream", Glib::unwrap(stream), "guid", Glib::c_str_or_nullptr(guid), "flags", + static_cast(flags), "authentication-observer", + static_cast(nullptr)) { init_async(slot); } -Connection::Connection(const std::string& address, - const Glib::RefPtr& observer, - const SlotAsyncReady& slot, - const Glib::RefPtr& cancellable, - ConnectionFlags flags) -: - _CONSTRUCT("address", Glib::c_str_or_nullptr(address), - "flags", static_cast(flags), - "authentication-observer", Glib::unwrap(observer)) +Connection::Connection(const std::string& address, const Glib::RefPtr& observer, + const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, ConnectionFlags flags) +: _CONSTRUCT("address", Glib::c_str_or_nullptr(address), "flags", + static_cast(flags), "authentication-observer", Glib::unwrap(observer)) { init_async(slot, cancellable); } -Connection::Connection(const std::string& address, - const SlotAsyncReady& slot, - const Glib::RefPtr& cancellable, - ConnectionFlags flags) -: - _CONSTRUCT("address", Glib::c_str_or_nullptr(address), - "flags", static_cast(flags), - "authentication-observer", static_cast(nullptr)) +Connection::Connection(const std::string& address, const SlotAsyncReady& slot, + const Glib::RefPtr& cancellable, ConnectionFlags flags) +: _CONSTRUCT("address", Glib::c_str_or_nullptr(address), "flags", + static_cast(flags), "authentication-observer", + static_cast(nullptr)) { init_async(slot, cancellable); } -Connection::Connection(const std::string& address, - const Glib::RefPtr& observer, - const SlotAsyncReady& slot, - ConnectionFlags flags) -: - _CONSTRUCT("address", Glib::c_str_or_nullptr(address), - "flags", static_cast(flags), - "authentication-observer", Glib::unwrap(observer)) +Connection::Connection(const std::string& address, const Glib::RefPtr& observer, + const SlotAsyncReady& slot, ConnectionFlags flags) +: _CONSTRUCT("address", Glib::c_str_or_nullptr(address), "flags", + static_cast(flags), "authentication-observer", Glib::unwrap(observer)) { init_async(slot); } -Connection::Connection(const std::string& address, - const SlotAsyncReady& slot, - ConnectionFlags flags) -: - _CONSTRUCT("address", Glib::c_str_or_nullptr(address), - "flags", static_cast(flags), - "authentication-observer", static_cast(nullptr)) +Connection::Connection( + const std::string& address, const SlotAsyncReady& slot, ConnectionFlags flags) +: _CONSTRUCT("address", Glib::c_str_or_nullptr(address), "flags", + static_cast(flags), "authentication-observer", + static_cast(nullptr)) { init_async(slot); } -Connection::Connection(const Glib::RefPtr& stream, - const std::string& guid, - const Glib::RefPtr& observer, - const Glib::RefPtr& cancellable, +Connection::Connection(const Glib::RefPtr& stream, const std::string& guid, + const Glib::RefPtr& observer, const Glib::RefPtr& cancellable, ConnectionFlags flags) -: - _CONSTRUCT("stream", Glib::unwrap(stream), - "guid", Glib::c_str_or_nullptr(guid), - "flags", static_cast(flags), - "authentication-observer", Glib::unwrap(observer)) +: _CONSTRUCT("stream", Glib::unwrap(stream), "guid", Glib::c_str_or_nullptr(guid), "flags", + static_cast(flags), "authentication-observer", Glib::unwrap(observer)) { init(cancellable); } -Connection::Connection(const Glib::RefPtr& stream, - const std::string& guid, - const Glib::RefPtr& cancellable, - ConnectionFlags flags) -: - _CONSTRUCT("stream", Glib::unwrap(stream), - "guid", Glib::c_str_or_nullptr(guid), - "flags", static_cast(flags), - "authentication-observer", static_cast(nullptr)) +Connection::Connection(const Glib::RefPtr& stream, const std::string& guid, + const Glib::RefPtr& cancellable, ConnectionFlags flags) +: _CONSTRUCT("stream", Glib::unwrap(stream), "guid", Glib::c_str_or_nullptr(guid), "flags", + static_cast(flags), "authentication-observer", + static_cast(nullptr)) { init(cancellable); } -Connection::Connection(const Glib::RefPtr& stream, - const std::string& guid, - const Glib::RefPtr& observer, - ConnectionFlags flags) -: - _CONSTRUCT("stream", Glib::unwrap(stream), - "guid", Glib::c_str_or_nullptr(guid), - "flags", static_cast(flags), - "authentication-observer", Glib::unwrap(observer)) +Connection::Connection(const Glib::RefPtr& stream, const std::string& guid, + const Glib::RefPtr& observer, ConnectionFlags flags) +: _CONSTRUCT("stream", Glib::unwrap(stream), "guid", Glib::c_str_or_nullptr(guid), "flags", + static_cast(flags), "authentication-observer", Glib::unwrap(observer)) { init(); } -Connection::Connection(const Glib::RefPtr& stream, - const std::string& guid, - ConnectionFlags flags) -: - _CONSTRUCT("stream", Glib::unwrap(stream), - "guid", Glib::c_str_or_nullptr(guid), - "flags", static_cast(flags), - "authentication-observer", static_cast(nullptr)) +Connection::Connection( + const Glib::RefPtr& stream, const std::string& guid, ConnectionFlags flags) +: _CONSTRUCT("stream", Glib::unwrap(stream), "guid", Glib::c_str_or_nullptr(guid), "flags", + static_cast(flags), "authentication-observer", + static_cast(nullptr)) { init(); } -Connection::Connection(const std::string& address, - const Glib::RefPtr& observer, - const Glib::RefPtr& cancellable, - ConnectionFlags flags) -: - _CONSTRUCT("address", Glib::c_str_or_nullptr(address), - "flags", static_cast(flags), - "authentication-observer", Glib::unwrap(observer)) +Connection::Connection(const std::string& address, const Glib::RefPtr& observer, + const Glib::RefPtr& cancellable, ConnectionFlags flags) +: _CONSTRUCT("address", Glib::c_str_or_nullptr(address), "flags", + static_cast(flags), "authentication-observer", Glib::unwrap(observer)) { init(cancellable); } -Connection::Connection(const std::string& address, - const Glib::RefPtr& cancellable, - ConnectionFlags flags) -: - _CONSTRUCT("address", Glib::c_str_or_nullptr(address), - "flags", static_cast(flags), - "authentication-observer", static_cast(nullptr)) +Connection::Connection( + const std::string& address, const Glib::RefPtr& cancellable, ConnectionFlags flags) +: _CONSTRUCT("address", Glib::c_str_or_nullptr(address), "flags", + static_cast(flags), "authentication-observer", + static_cast(nullptr)) { init(cancellable); } -Connection::Connection(const std::string& address, - const Glib::RefPtr& observer, - ConnectionFlags flags) -: - _CONSTRUCT("address", Glib::c_str_or_nullptr(address), - "flags", static_cast(flags), - "authentication-observer", Glib::unwrap(observer)) +Connection::Connection( + const std::string& address, const Glib::RefPtr& observer, ConnectionFlags flags) +: _CONSTRUCT("address", Glib::c_str_or_nullptr(address), "flags", + static_cast(flags), "authentication-observer", Glib::unwrap(observer)) { init(); } -Connection::Connection(const std::string& address, - ConnectionFlags flags) -: - _CONSTRUCT("address", Glib::c_str_or_nullptr(address), - "flags", static_cast(flags), - "authentication-observer", static_cast(nullptr)) +Connection::Connection(const std::string& address, ConnectionFlags flags) +: _CONSTRUCT("address", Glib::c_str_or_nullptr(address), "flags", + static_cast(flags), "authentication-observer", + static_cast(nullptr)) { init(); } -//static -void Connection::create(const Glib::RefPtr& stream, - const std::string& guid, - const Glib::RefPtr& observer, - const SlotAsyncReady& slot, - const Glib::RefPtr& cancellable, - ConnectionFlags flags) +// static +void +Connection::create(const Glib::RefPtr& stream, const std::string& guid, + const Glib::RefPtr& observer, const SlotAsyncReady& slot, + const Glib::RefPtr& cancellable, ConnectionFlags flags) { // Note that this does not return anything, because it is async - see // create_finish(). @@ -308,12 +242,10 @@ void Connection::create(const Glib::RefPtr& stream, Connection(stream, guid, observer, slot, cancellable, flags); } -//static -void Connection::create(const Glib::RefPtr& stream, - const std::string& guid, - const SlotAsyncReady& slot, - const Glib::RefPtr& cancellable, - ConnectionFlags flags) +// static +void +Connection::create(const Glib::RefPtr& stream, const std::string& guid, + const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, ConnectionFlags flags) { // Note that this does not return anything, because it is async - see // create_finish(). @@ -321,314 +253,275 @@ void Connection::create(const Glib::RefPtr& stream, Connection(stream, guid, slot, cancellable, flags); } -//static -void Connection::create(const Glib::RefPtr& stream, - const std::string& guid, - const Glib::RefPtr& observer, - const SlotAsyncReady& slot, - ConnectionFlags flags) +// static +void +Connection::create(const Glib::RefPtr& stream, const std::string& guid, + const Glib::RefPtr& observer, const SlotAsyncReady& slot, ConnectionFlags flags) { // Note that this does not return anything, because it is async - see // create_finish(). Connection(stream, guid, observer, slot, flags); } -//static -void Connection::create(const Glib::RefPtr& stream, - const std::string& guid, - const SlotAsyncReady& slot, - ConnectionFlags flags) +// static +void +Connection::create(const Glib::RefPtr& stream, const std::string& guid, + const SlotAsyncReady& slot, ConnectionFlags flags) { // Note that this does not return anything, because it is async - see // create_finish(). Connection(stream, guid, slot, flags); } -//static -Glib::RefPtr Connection::create_sync( - const Glib::RefPtr& stream, - const std::string& guid, - const Glib::RefPtr& observer, - const Glib::RefPtr& cancellable, +// static +Glib::RefPtr +Connection::create_sync(const Glib::RefPtr& stream, const std::string& guid, + const Glib::RefPtr& observer, const Glib::RefPtr& cancellable, ConnectionFlags flags) { - return Glib::RefPtr(new Connection(stream, guid, - observer, cancellable, flags)); + return Glib::RefPtr(new Connection(stream, guid, observer, cancellable, flags)); } -//static -Glib::RefPtr Connection::create_sync( - const Glib::RefPtr& stream, - const std::string& guid, - const Glib::RefPtr& cancellable, - ConnectionFlags flags) +// static +Glib::RefPtr +Connection::create_sync(const Glib::RefPtr& stream, const std::string& guid, + const Glib::RefPtr& cancellable, ConnectionFlags flags) { - return Glib::RefPtr(new Connection(stream, guid, - cancellable, flags)); + return Glib::RefPtr(new Connection(stream, guid, cancellable, flags)); } -//static -Glib::RefPtr Connection::create_sync( - const Glib::RefPtr& stream, - const std::string& guid, - const Glib::RefPtr& observer, - ConnectionFlags flags) +// static +Glib::RefPtr +Connection::create_sync(const Glib::RefPtr& stream, const std::string& guid, + const Glib::RefPtr& observer, ConnectionFlags flags) { - return Glib::RefPtr(new Connection(stream, guid, - observer, flags)); + return Glib::RefPtr(new Connection(stream, guid, observer, flags)); } -//static -Glib::RefPtr Connection::create_sync( - const Glib::RefPtr& stream, - const std::string& guid, - ConnectionFlags flags) +// static +Glib::RefPtr +Connection::create_sync( + const Glib::RefPtr& stream, const std::string& guid, ConnectionFlags flags) { - return Glib::RefPtr(new Connection(stream, guid, - flags)); + return Glib::RefPtr(new Connection(stream, guid, flags)); } -//static -void Connection::create_for_address(const std::string& address, - const Glib::RefPtr& observer, - const SlotAsyncReady& slot, - const Glib::RefPtr& cancellable, - ConnectionFlags flags) +// static +void +Connection::create_for_address(const std::string& address, + const Glib::RefPtr& observer, const SlotAsyncReady& slot, + const Glib::RefPtr& cancellable, ConnectionFlags flags) { // Note that this does not return anything, because it is async - see // create_finish(). Connection(address, observer, slot, cancellable, flags); } -//static -void Connection::create_for_address(const std::string& address, - const SlotAsyncReady& slot, - const Glib::RefPtr& cancellable, - ConnectionFlags flags) +// static +void +Connection::create_for_address(const std::string& address, const SlotAsyncReady& slot, + const Glib::RefPtr& cancellable, ConnectionFlags flags) { // Note that this does not return anything, because it is async - see // create_finish(). Connection(address, slot, cancellable, flags); } -//static -void Connection::create_for_address(const std::string& address, - const Glib::RefPtr& observer, - const SlotAsyncReady& slot, - ConnectionFlags flags) +// static +void +Connection::create_for_address(const std::string& address, + const Glib::RefPtr& observer, const SlotAsyncReady& slot, ConnectionFlags flags) { // Note that this does not return anything, because it is async - see // create_finish(). Connection(address, observer, slot, flags); } -//static -void Connection::create_for_address(const std::string& address, - const SlotAsyncReady& slot, - ConnectionFlags flags) +// static +void +Connection::create_for_address( + const std::string& address, const SlotAsyncReady& slot, ConnectionFlags flags) { // Note that this does not return anything, because it is async - see // create_finish(). Connection(address, slot, flags); } -//static -Glib::RefPtr Connection::create_for_address_sync( - const std::string& address, - const Glib::RefPtr& observer, - const Glib::RefPtr& cancellable, +// static +Glib::RefPtr +Connection::create_for_address_sync(const std::string& address, + const Glib::RefPtr& observer, const Glib::RefPtr& cancellable, ConnectionFlags flags) { - return Glib::RefPtr(new Connection(address, observer, - cancellable, flags)); + return Glib::RefPtr(new Connection(address, observer, cancellable, flags)); } -//static -Glib::RefPtr Connection::create_for_address_sync( - const std::string& address, - const Glib::RefPtr& cancellable, - ConnectionFlags flags) +// static +Glib::RefPtr +Connection::create_for_address_sync( + const std::string& address, const Glib::RefPtr& cancellable, ConnectionFlags flags) { - return Glib::RefPtr(new Connection(address, cancellable, - flags)); + return Glib::RefPtr(new Connection(address, cancellable, flags)); } -//static -Glib::RefPtr Connection::create_for_address_sync( - const std::string& address, - const Glib::RefPtr& observer, - ConnectionFlags flags) +// static +Glib::RefPtr +Connection::create_for_address_sync( + const std::string& address, const Glib::RefPtr& observer, ConnectionFlags flags) { - return Glib::RefPtr(new Connection(address, observer, - flags)); + return Glib::RefPtr(new Connection(address, observer, flags)); } -//static -Glib::RefPtr Connection::create_for_address_sync( - const std::string& address, - ConnectionFlags flags) +// static +Glib::RefPtr +Connection::create_for_address_sync(const std::string& address, ConnectionFlags flags) { return Glib::RefPtr(new Connection(address, flags)); } -//static -void Connection::get(BusType bus_type, const SlotAsyncReady& slot, - const Glib::RefPtr& cancellable) +// static +void +Connection::get( + BusType bus_type, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable) { auto slot_copy = new SlotAsyncReady(slot); - g_bus_get(static_cast(bus_type), Glib::unwrap(cancellable), - &SignalProxy_async_callback, slot_copy); + g_bus_get(static_cast(bus_type), Glib::unwrap(cancellable), &SignalProxy_async_callback, + slot_copy); } -//static -void Connection::get(BusType bus_type, const SlotAsyncReady& slot) +// static +void +Connection::get(BusType bus_type, const SlotAsyncReady& slot) { auto slot_copy = new SlotAsyncReady(slot); - g_bus_get(static_cast(bus_type), nullptr, &SignalProxy_async_callback, - slot_copy); + g_bus_get(static_cast(bus_type), nullptr, &SignalProxy_async_callback, slot_copy); } -void Connection::close() +void +Connection::close() { g_dbus_connection_close(gobj(), nullptr, nullptr, nullptr); } -void Connection::close(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable) +void +Connection::close(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable) { auto slot_copy = new SlotAsyncReady(slot); - g_dbus_connection_close(gobj(), - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_dbus_connection_close( + gobj(), Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } -void Connection::close(const SlotAsyncReady& slot) +void +Connection::close(const SlotAsyncReady& slot) { auto slot_copy = new SlotAsyncReady(slot); - g_dbus_connection_close(gobj(), - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_dbus_connection_close(gobj(), nullptr, &SignalProxy_async_callback, slot_copy); } -void Connection::flush() +void +Connection::flush() { g_dbus_connection_flush(gobj(), nullptr, nullptr, nullptr); } -void Connection::flush(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable) +void +Connection::flush(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable) { auto slot_copy = new SlotAsyncReady(slot); - g_dbus_connection_flush(gobj(), - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_dbus_connection_flush( + gobj(), Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } -void Connection::flush(const SlotAsyncReady& slot) +void +Connection::flush(const SlotAsyncReady& slot) { auto slot_copy = new SlotAsyncReady(slot); - g_dbus_connection_flush(gobj(), - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_dbus_connection_flush(gobj(), nullptr, &SignalProxy_async_callback, slot_copy); } -bool Connection::send_message(const Glib::RefPtr& message, - SendMessageFlags flags) +bool +Connection::send_message(const Glib::RefPtr& message, SendMessageFlags flags) { GError* gerror = nullptr; - const bool result = g_dbus_connection_send_message(gobj(), - Glib::unwrap(message), static_cast(flags), nullptr, - &gerror); + const bool result = g_dbus_connection_send_message( + gobj(), Glib::unwrap(message), static_cast(flags), nullptr, &gerror); - if(gerror) + if (gerror) ::Glib::Error::throw_exception(gerror); return result; } -void Connection::send_message_with_reply(const Glib::RefPtr& message, int timeout_msec,const SlotAsyncReady& slot, const Glib::RefPtr& cancellable) +void +Connection::send_message_with_reply(const Glib::RefPtr& message, int timeout_msec, + const SlotAsyncReady& slot, const Glib::RefPtr& cancellable) { auto slot_copy = new SlotAsyncReady(slot); volatile guint32 out_serial = 0; g_dbus_connection_send_message_with_reply(gobj(), Glib::unwrap(message), - static_cast(message->get_flags()), - timeout_msec, &out_serial, - Glib::unwrap(cancellable), &SignalProxy_async_callback, - slot_copy); + static_cast(message->get_flags()), timeout_msec, &out_serial, + Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); message->set_serial(out_serial); } -void Connection::send_message_with_reply(const Glib::RefPtr& message, int timeout_msec,const SlotAsyncReady& slot) +void +Connection::send_message_with_reply( + const Glib::RefPtr& message, int timeout_msec, const SlotAsyncReady& slot) { auto slot_copy = new SlotAsyncReady(slot); volatile guint32 out_serial = 0; g_dbus_connection_send_message_with_reply(gobj(), Glib::unwrap(message), - static_cast(message->get_flags()), - timeout_msec, &out_serial, - nullptr, &SignalProxy_async_callback, - slot_copy); + static_cast(message->get_flags()), timeout_msec, &out_serial, nullptr, + &SignalProxy_async_callback, slot_copy); message->set_serial(out_serial); } -Glib::RefPtr Connection::send_message_with_reply_sync( - const Glib::RefPtr& message, - const Glib::RefPtr& cancellable, - gint timeout_msec) +Glib::RefPtr +Connection::send_message_with_reply_sync(const Glib::RefPtr& message, + const Glib::RefPtr& cancellable, gint timeout_msec) { volatile guint32 out_serial = 0; GError* gerror = nullptr; - GDBusMessage* result = - g_dbus_connection_send_message_with_reply_sync(gobj(), - Glib::unwrap(message), - static_cast(message->get_flags()), - timeout_msec, &out_serial, Glib::unwrap(cancellable), &gerror); + GDBusMessage* result = g_dbus_connection_send_message_with_reply_sync(gobj(), + Glib::unwrap(message), static_cast(message->get_flags()), timeout_msec, + &out_serial, Glib::unwrap(cancellable), &gerror); - if(gerror) + if (gerror) ::Glib::Error::throw_exception(gerror); message->set_serial(out_serial); return Glib::wrap(result); } -Glib::RefPtr Connection::send_message_with_reply_sync( - const Glib::RefPtr& message, - gint timeout_msec) +Glib::RefPtr +Connection::send_message_with_reply_sync(const Glib::RefPtr& message, gint timeout_msec) { volatile guint32 out_serial = 0; GError* gerror = nullptr; - GDBusMessage* result = - g_dbus_connection_send_message_with_reply_sync(gobj(), - Glib::unwrap(message), - static_cast(message->get_flags()), timeout_msec, + GDBusMessage* result = g_dbus_connection_send_message_with_reply_sync(gobj(), + Glib::unwrap(message), static_cast(message->get_flags()), timeout_msec, &out_serial, nullptr, &gerror); - if(gerror) + if (gerror) ::Glib::Error::throw_exception(gerror); message->set_serial(out_serial); return Glib::wrap(result); } -void Connection::call( - const Glib::ustring& object_path, - const Glib::ustring& interface_name, - const Glib::ustring& method_name, - const Glib::VariantContainerBase& parameters, - const SlotAsyncReady& slot, - const Glib::RefPtr& cancellable, - const Glib::ustring& bus_name, - int timeout_msec, - CallFlags flags, - const Glib::VariantType& reply_type) +void +Connection::call(const Glib::ustring& object_path, const Glib::ustring& interface_name, + const Glib::ustring& method_name, const Glib::VariantContainerBase& parameters, + const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, + const Glib::ustring& bus_name, int timeout_msec, CallFlags flags, + const Glib::VariantType& reply_type) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter @@ -636,23 +529,17 @@ void Connection::call( auto slot_copy = new SlotAsyncReady(slot); g_dbus_connection_call(gobj(), Glib::c_str_or_nullptr(bus_name), object_path.c_str(), - interface_name.c_str(), method_name.c_str(), - const_cast(parameters.gobj()), reply_type.gobj(), - static_cast(flags), timeout_msec, - Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); + interface_name.c_str(), method_name.c_str(), const_cast(parameters.gobj()), + reply_type.gobj(), static_cast(flags), timeout_msec, Glib::unwrap(cancellable), + &SignalProxy_async_callback, slot_copy); } // Non-cancellable version. -void Connection::call( - const Glib::ustring& object_path, - const Glib::ustring& interface_name, - const Glib::ustring& method_name, - const Glib::VariantContainerBase& parameters, - const SlotAsyncReady& slot, - const Glib::ustring& bus_name, - int timeout_msec, - CallFlags flags, - const Glib::VariantType& reply_type) +void +Connection::call(const Glib::ustring& object_path, const Glib::ustring& interface_name, + const Glib::ustring& method_name, const Glib::VariantContainerBase& parameters, + const SlotAsyncReady& slot, const Glib::ustring& bus_name, int timeout_msec, CallFlags flags, + const Glib::VariantType& reply_type) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter @@ -660,77 +547,58 @@ void Connection::call( auto slot_copy = new SlotAsyncReady(slot); g_dbus_connection_call(gobj(), Glib::c_str_or_nullptr(bus_name), object_path.c_str(), - interface_name.c_str(), method_name.c_str(), - const_cast(parameters.gobj()), reply_type.gobj(), - static_cast(flags), timeout_msec, nullptr, + interface_name.c_str(), method_name.c_str(), const_cast(parameters.gobj()), + reply_type.gobj(), static_cast(flags), timeout_msec, nullptr, &SignalProxy_async_callback, slot_copy); } -Glib::VariantContainerBase Connection::call_sync( - const Glib::ustring& object_path, - const Glib::ustring& interface_name, - const Glib::ustring& method_name, - const Glib::VariantContainerBase& parameters, - const Glib::RefPtr& cancellable, - const Glib::ustring& bus_name, - int timeout_msec, - CallFlags flags, - const Glib::VariantType& reply_type) +Glib::VariantContainerBase +Connection::call_sync(const Glib::ustring& object_path, const Glib::ustring& interface_name, + const Glib::ustring& method_name, const Glib::VariantContainerBase& parameters, + const Glib::RefPtr& cancellable, const Glib::ustring& bus_name, int timeout_msec, + CallFlags flags, const Glib::VariantType& reply_type) { GError* gerror = nullptr; - GVariant* const gvariant = - g_dbus_connection_call_sync(gobj(), Glib::c_str_or_nullptr(bus_name), object_path.c_str(), - interface_name.c_str(), method_name.c_str(), - const_cast(parameters.gobj()), reply_type.gobj(), - static_cast(flags), timeout_msec, - Glib::unwrap(cancellable), &gerror); + GVariant* const gvariant = g_dbus_connection_call_sync(gobj(), Glib::c_str_or_nullptr(bus_name), + object_path.c_str(), interface_name.c_str(), method_name.c_str(), + const_cast(parameters.gobj()), reply_type.gobj(), static_cast(flags), + timeout_msec, Glib::unwrap(cancellable), &gerror); - if(gerror) + if (gerror) ::Glib::Error::throw_exception(gerror); - return Glib::VariantContainerBase(gvariant, false); //Dont' take an extra reference. + return Glib::VariantContainerBase(gvariant, false); // Dont' take an extra reference. } // Non-cancellable version. -Glib::VariantContainerBase Connection::call_sync( - const Glib::ustring& object_path, - const Glib::ustring& interface_name, - const Glib::ustring& method_name, - const Glib::VariantContainerBase& parameters, - const Glib::ustring& bus_name, - int timeout_msec, - CallFlags flags, - const Glib::VariantType& reply_type) +Glib::VariantContainerBase +Connection::call_sync(const Glib::ustring& object_path, const Glib::ustring& interface_name, + const Glib::ustring& method_name, const Glib::VariantContainerBase& parameters, + const Glib::ustring& bus_name, int timeout_msec, CallFlags flags, + const Glib::VariantType& reply_type) { GError* gerror = nullptr; GVariant* const gvariant = g_dbus_connection_call_sync(gobj(), Glib::c_str_or_nullptr(bus_name), object_path.c_str(), - interface_name.c_str(), method_name.c_str(), - const_cast(parameters.gobj()), reply_type.gobj(), - static_cast(flags), timeout_msec, nullptr, &gerror); + interface_name.c_str(), method_name.c_str(), const_cast(parameters.gobj()), + reply_type.gobj(), static_cast(flags), timeout_msec, nullptr, &gerror); - if(gerror) + if (gerror) ::Glib::Error::throw_exception(gerror); - return Glib::VariantContainerBase(gvariant, false); //Dont' take an extra reference. + return Glib::VariantContainerBase(gvariant, false); // Dont' take an extra reference. } #ifdef G_OS_UNIX // With a UnixFDList. -void Connection::call( - const Glib::ustring& object_path, - const Glib::ustring& interface_name, - const Glib::ustring& method_name, - const Glib::VariantContainerBase& parameters, - const SlotAsyncReady& slot, - const Glib::RefPtr& cancellable, - const Glib::RefPtr& fd_list, - const Glib::ustring& bus_name, - int timeout_msec, - CallFlags flags, - const Glib::VariantType& reply_type) +void +Connection::call(const Glib::ustring& object_path, const Glib::ustring& interface_name, + const Glib::ustring& method_name, const Glib::VariantContainerBase& parameters, + const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, + const Glib::RefPtr& fd_list, const Glib::ustring& bus_name, int timeout_msec, + CallFlags flags, const Glib::VariantType& reply_type) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter @@ -739,23 +607,18 @@ void Connection::call( g_dbus_connection_call_with_unix_fd_list(gobj(), Glib::c_str_or_nullptr(bus_name), object_path.c_str(), interface_name.c_str(), method_name.c_str(), - const_cast(parameters.gobj()), reply_type.gobj(), - static_cast(flags), timeout_msec, Glib::unwrap(fd_list), - Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); + const_cast(parameters.gobj()), reply_type.gobj(), static_cast(flags), + timeout_msec, Glib::unwrap(fd_list), Glib::unwrap(cancellable), &SignalProxy_async_callback, + slot_copy); } // Non-cancellable version (with a UnixFDList). -void Connection::call( - const Glib::ustring& object_path, - const Glib::ustring& interface_name, - const Glib::ustring& method_name, - const Glib::VariantContainerBase& parameters, - const SlotAsyncReady& slot, - const Glib::RefPtr& fd_list, - const Glib::ustring& bus_name, - int timeout_msec, - CallFlags flags, - const Glib::VariantType& reply_type) +void +Connection::call(const Glib::ustring& object_path, const Glib::ustring& interface_name, + const Glib::ustring& method_name, const Glib::VariantContainerBase& parameters, + const SlotAsyncReady& slot, const Glib::RefPtr& fd_list, + const Glib::ustring& bus_name, int timeout_msec, CallFlags flags, + const Glib::VariantType& reply_type) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter @@ -764,111 +627,99 @@ void Connection::call( g_dbus_connection_call_with_unix_fd_list(gobj(), Glib::c_str_or_nullptr(bus_name), object_path.c_str(), interface_name.c_str(), method_name.c_str(), - const_cast(parameters.gobj()), reply_type.gobj(), - static_cast(flags), timeout_msec, Glib::unwrap(fd_list), - nullptr, &SignalProxy_async_callback, slot_copy); + const_cast(parameters.gobj()), reply_type.gobj(), static_cast(flags), + timeout_msec, Glib::unwrap(fd_list), nullptr, &SignalProxy_async_callback, slot_copy); } #endif // G_OS_UNIX -void Connection::emit_signal( - const Glib::ustring& object_path, - const Glib::ustring& interface_name, - const Glib::ustring& signal_name, - const Glib::ustring& destination_bus_name, - const Glib::VariantContainerBase& parameters) +void +Connection::emit_signal(const Glib::ustring& object_path, const Glib::ustring& interface_name, + const Glib::ustring& signal_name, const Glib::ustring& destination_bus_name, + const Glib::VariantContainerBase& parameters) { GError* gerror = nullptr; // destination_bus_name is checked to see if it is empty so that nullptr can be passed // to the C API. This is done because the bus name can be nullptr in the C API, // meaning that the signal should be emitted to all the listeners. - g_dbus_connection_emit_signal(gobj(), - Glib::c_str_or_nullptr(destination_bus_name), + g_dbus_connection_emit_signal(gobj(), Glib::c_str_or_nullptr(destination_bus_name), object_path.c_str(), interface_name.c_str(), signal_name.c_str(), const_cast(parameters.gobj()), &gerror); - if(gerror) + if (gerror) ::Glib::Error::throw_exception(gerror); } -guint Connection::signal_subscribe( - const SlotSignal& slot, - const Glib::ustring& sender, - const Glib::ustring& interface_name, - const Glib::ustring& member, - const Glib::ustring& object_path, - const Glib::ustring& arg0, - SignalFlags flags) +guint +Connection::signal_subscribe(const SlotSignal& slot, const Glib::ustring& sender, + const Glib::ustring& interface_name, const Glib::ustring& member, + const Glib::ustring& object_path, const Glib::ustring& arg0, SignalFlags flags) { auto slot_copy = new SlotSignal(slot); - return g_dbus_connection_signal_subscribe(gobj(), - Glib::c_str_or_nullptr(sender), - Glib::c_str_or_nullptr(interface_name), - Glib::c_str_or_nullptr(member), - Glib::c_str_or_nullptr(object_path), - Glib::c_str_or_nullptr(arg0), - static_cast(flags), - &DBusConnection_Signal_giomm_callback, slot_copy, + return g_dbus_connection_signal_subscribe(gobj(), Glib::c_str_or_nullptr(sender), + Glib::c_str_or_nullptr(interface_name), Glib::c_str_or_nullptr(member), + Glib::c_str_or_nullptr(object_path), Glib::c_str_or_nullptr(arg0), + static_cast(flags), &DBusConnection_Signal_giomm_callback, slot_copy, &DBusConnection_Signal_giomm_callback_destroy); } -guint Connection::add_filter(const SlotMessageFilter& slot) +guint +Connection::add_filter(const SlotMessageFilter& slot) { auto slot_copy = new SlotMessageFilter(slot); - return g_dbus_connection_add_filter(gobj(), - &DBusConnection_Message_Filter_giomm_callback, slot_copy, - DBusConnection_Message_Filter_giomm_callback_destroy); + return g_dbus_connection_add_filter(gobj(), &DBusConnection_Message_Filter_giomm_callback, + slot_copy, DBusConnection_Message_Filter_giomm_callback_destroy); } -guint Connection::register_object(const Glib::ustring& object_path, - const Glib::RefPtr& interface_info, - const InterfaceVTable& vtable) +guint +Connection::register_object(const Glib::ustring& object_path, + const Glib::RefPtr& interface_info, const InterfaceVTable& vtable) { GError* gerror = nullptr; - const guint result = g_dbus_connection_register_object(gobj(), - object_path.c_str(), Glib::unwrap(interface_info), - vtable.gobj(), const_cast(&vtable), nullptr, &gerror); + const guint result = + g_dbus_connection_register_object(gobj(), object_path.c_str(), Glib::unwrap(interface_info), + vtable.gobj(), const_cast(&vtable), nullptr, &gerror); - if(gerror) + if (gerror) ::Glib::Error::throw_exception(gerror); return result; } -guint Connection::register_object(const Glib::ustring& object_path, - const Glib::RefPtr& interface_info) +guint +Connection::register_object( + const Glib::ustring& object_path, const Glib::RefPtr& interface_info) { GError* gerror = nullptr; - const guint result = g_dbus_connection_register_object(gobj(), - object_path.c_str(), Glib::unwrap(interface_info), - nullptr, nullptr, nullptr, &gerror); + const guint result = g_dbus_connection_register_object( + gobj(), object_path.c_str(), Glib::unwrap(interface_info), nullptr, nullptr, nullptr, &gerror); - if(gerror) + if (gerror) ::Glib::Error::throw_exception(gerror); return result; } -guint Connection::register_subtree(const Glib::ustring& object_path, - const SubtreeVTable& vtable, SubtreeFlags flags) +guint +Connection::register_subtree( + const Glib::ustring& object_path, const SubtreeVTable& vtable, SubtreeFlags flags) { GError* gerror = nullptr; - const guint result = g_dbus_connection_register_subtree(gobj(), - object_path.c_str(), - vtable.gobj(), static_cast(flags), - const_cast(&vtable), nullptr, &gerror); + const guint result = + g_dbus_connection_register_subtree(gobj(), object_path.c_str(), vtable.gobj(), + static_cast(flags), const_cast(&vtable), nullptr, &gerror); - if(gerror) + if (gerror) ::Glib::Error::throw_exception(gerror); return result; } -} //namespace DBus +} // namespace DBus } // namespace Gio diff --git a/gio/src/dbuserrorutils.ccg b/gio/src/dbuserrorutils.ccg index a5db2cec..d4e34906 100644 --- a/gio/src/dbuserrorutils.ccg +++ b/gio/src/dbuserrorutils.ccg @@ -30,17 +30,20 @@ namespace DBus namespace ErrorUtils { -bool is_remote_error(const Glib::Error& error) +bool +is_remote_error(const Glib::Error& error) { return static_cast(g_dbus_error_is_remote_error(error.gobj())); } -Glib::ustring get_remote_error(const Glib::Error& error) +Glib::ustring +get_remote_error(const Glib::Error& error) { return Glib::convert_const_gchar_ptr_to_ustring(g_dbus_error_get_remote_error(error.gobj())); } -bool strip_remote_error(Glib::Error& error) +bool +strip_remote_error(Glib::Error& error) { return static_cast(g_dbus_error_strip_remote_error(error.gobj())); } diff --git a/gio/src/dbusinterfacevtable.ccg b/gio/src/dbusinterfacevtable.ccg index 9d6834c6..c6ffd89d 100644 --- a/gio/src/dbusinterfacevtable.ccg +++ b/gio/src/dbusinterfacevtable.ccg @@ -29,59 +29,53 @@ namespace { -extern "C" -{ +extern "C" { -static void DBusInterfaceVTable_MethodCall_giomm_callback( - GDBusConnection* connection, const char* sender, const char* object_path, - const char* interface_name, const char* method_name, GVariant* parameters, - GDBusMethodInvocation* invocation, void* user_data) +static void +DBusInterfaceVTable_MethodCall_giomm_callback(GDBusConnection* connection, const char* sender, + const char* object_path, const char* interface_name, const char* method_name, + GVariant* parameters, GDBusMethodInvocation* invocation, void* user_data) { - Gio::DBus::InterfaceVTable* vtable = - static_cast(user_data); + Gio::DBus::InterfaceVTable* vtable = static_cast(user_data); - Gio::DBus::InterfaceVTable::SlotInterfaceMethodCall* the_slot = - vtable->get_slot_method_call(); + Gio::DBus::InterfaceVTable::SlotInterfaceMethodCall* the_slot = vtable->get_slot_method_call(); try { // Note that we use VariantContainerBase instead of VariantBase for the // GVariant, because it is documented as being a tuple (list of values). - (*the_slot)(Glib::wrap(connection, true), (sender ? sender : ""), - object_path, interface_name, method_name, - Glib::VariantContainerBase(parameters, true), Glib::wrap(invocation, true)); + (*the_slot)(Glib::wrap(connection, true), (sender ? sender : ""), object_path, interface_name, + method_name, Glib::VariantContainerBase(parameters, true), Glib::wrap(invocation, true)); } - catch(...) + catch (...) { Glib::exception_handlers_invoke(); } } -static GVariant* DBusInterfaceVTable_GetProperty_giomm_callback( - GDBusConnection* connection, const char* sender, const char* object_path, - const char* interface_name, const char* property_name, GError** error, +static GVariant* +DBusInterfaceVTable_GetProperty_giomm_callback(GDBusConnection* connection, const char* sender, + const char* object_path, const char* interface_name, const char* property_name, GError** error, void* user_data) { - Gio::DBus::InterfaceVTable* vtable = - static_cast(user_data); + Gio::DBus::InterfaceVTable* vtable = static_cast(user_data); - Gio::DBus::InterfaceVTable::SlotInterfaceGetProperty* the_slot = - vtable->get_slot_get_property(); + Gio::DBus::InterfaceVTable::SlotInterfaceGetProperty* the_slot = vtable->get_slot_get_property(); try { Glib::VariantBase result; - (*the_slot)(result, Glib::wrap(connection, true), sender, object_path, - interface_name, property_name); + (*the_slot)( + result, Glib::wrap(connection, true), sender, object_path, interface_name, property_name); return result.gobj_copy(); } - catch(const Glib::Error& ex) + catch (const Glib::Error& ex) { - if(error) + if (error) *error = g_error_copy(ex.gobj()); } - catch(...) + catch (...) { Glib::exception_handlers_invoke(); } @@ -89,29 +83,26 @@ static GVariant* DBusInterfaceVTable_GetProperty_giomm_callback( return nullptr; } -static gboolean DBusInterfaceVTable_SetProperty_giomm_callback( - GDBusConnection* connection, const char* sender, const char* object_path, - const char* interface_name, const char* property_name, GVariant* value, +static gboolean +DBusInterfaceVTable_SetProperty_giomm_callback(GDBusConnection* connection, const char* sender, + const char* object_path, const char* interface_name, const char* property_name, GVariant* value, GError** error, void* user_data) { - Gio::DBus::InterfaceVTable* vtable = - static_cast(user_data); + Gio::DBus::InterfaceVTable* vtable = static_cast(user_data); - Gio::DBus::InterfaceVTable::SlotInterfaceSetProperty* the_slot = - vtable->get_slot_set_property(); + Gio::DBus::InterfaceVTable::SlotInterfaceSetProperty* the_slot = vtable->get_slot_set_property(); try { - return static_cast((*the_slot)(Glib::wrap(connection, true), - sender, object_path, interface_name, property_name, - Glib::VariantBase(value, true))); + return static_cast((*the_slot)(Glib::wrap(connection, true), sender, object_path, + interface_name, property_name, Glib::VariantBase(value, true))); } - catch(const Glib::Error& ex) + catch (const Glib::Error& ex) { - if(error) + if (error) *error = g_error_copy(ex.gobj()); } - catch(...) + catch (...) { Glib::exception_handlers_invoke(); } @@ -120,7 +111,6 @@ static gboolean DBusInterfaceVTable_SetProperty_giomm_callback( } } // extern "C" - } namespace Gio @@ -129,11 +119,9 @@ namespace Gio namespace DBus { -InterfaceVTable::InterfaceVTable( - const SlotInterfaceMethodCall& slot_method_call, +InterfaceVTable::InterfaceVTable(const SlotInterfaceMethodCall& slot_method_call, const SlotInterfaceGetProperty& slot_get_property, - const SlotInterfaceSetProperty& slot_set_property -) + const SlotInterfaceSetProperty& slot_set_property) : slot_method_call_(new SlotInterfaceMethodCall(slot_method_call)), slot_get_property_(new SlotInterfaceGetProperty(slot_get_property)), slot_set_property_(new SlotInterfaceSetProperty(slot_set_property)) @@ -144,17 +132,18 @@ InterfaceVTable::InterfaceVTable( } InterfaceVTable::InterfaceVTable(InterfaceVTable&& other) noexcept -: gobject_(std::move(other.gobject_)), - slot_method_call_(std::move(other.slot_method_call_)), - slot_get_property_(std::move(other.slot_get_property_)), - slot_set_property_(std::move(other.slot_set_property_)) + : gobject_(std::move(other.gobject_)), + slot_method_call_(std::move(other.slot_method_call_)), + slot_get_property_(std::move(other.slot_get_property_)), + slot_set_property_(std::move(other.slot_set_property_)) { other.slot_method_call_ = nullptr; other.slot_get_property_ = nullptr; other.slot_set_property_ = nullptr; } -InterfaceVTable& InterfaceVTable::operator=(InterfaceVTable&& other) noexcept +InterfaceVTable& +InterfaceVTable::operator=(InterfaceVTable&& other) noexcept { delete slot_method_call_; delete slot_get_property_; @@ -180,23 +169,23 @@ InterfaceVTable::~InterfaceVTable() } InterfaceVTable::SlotInterfaceMethodCall* - InterfaceVTable::get_slot_method_call() const +InterfaceVTable::get_slot_method_call() const { return slot_method_call_; } InterfaceVTable::SlotInterfaceGetProperty* - InterfaceVTable::get_slot_get_property() const +InterfaceVTable::get_slot_get_property() const { return slot_get_property_; } InterfaceVTable::SlotInterfaceSetProperty* - InterfaceVTable::get_slot_set_property() const +InterfaceVTable::get_slot_set_property() const { return slot_set_property_; } -} //namespace DBus +} // namespace DBus } // namespace Gio diff --git a/gio/src/dbusintrospection.ccg b/gio/src/dbusintrospection.ccg index 788ea319..4a37d378 100644 --- a/gio/src/dbusintrospection.ccg +++ b/gio/src/dbusintrospection.ccg @@ -26,29 +26,31 @@ namespace Gio namespace DBus { -//We hand-code this because g_dbus_node_info_lookup_interface() doesn't -//do this when it takes a nullptr. -//See bug https://bugzilla.gnome.org/show_bug.cgi?id=646417 -Glib::RefPtr NodeInfo::lookup_interface() +// We hand-code this because g_dbus_node_info_lookup_interface() doesn't +// do this when it takes a nullptr. +// See bug https://bugzilla.gnome.org/show_bug.cgi?id=646417 +Glib::RefPtr +NodeInfo::lookup_interface() { Glib::RefPtr retvalue; - if(!gobj() || !(gobj()->interfaces)) + if (!gobj() || !(gobj()->interfaces)) return retvalue; retvalue = Glib::wrap(gobj()->interfaces[0]); - if(retvalue) - retvalue->reference(); //The function does not do a ref for us. + if (retvalue) + retvalue->reference(); // The function does not do a ref for us. return retvalue; } -Glib::RefPtr NodeInfo::lookup_interface() const +Glib::RefPtr +NodeInfo::lookup_interface() const { return const_cast(this)->lookup_interface(); } -} //namespace DBus +} // namespace DBus } // namespace Gio diff --git a/gio/src/dbusmessage.ccg b/gio/src/dbusmessage.ccg index 25e72192..fb2cd8aa 100644 --- a/gio/src/dbusmessage.ccg +++ b/gio/src/dbusmessage.ccg @@ -22,7 +22,7 @@ #ifdef G_OS_UNIX #include -#endif //G_OS_UNIX +#endif // G_OS_UNIX namespace Gio { @@ -32,37 +32,37 @@ namespace DBus typedef Message::ByteOrder ByteOrder; -void Message::get_body(Glib::VariantBase& value) const +void +Message::get_body(Glib::VariantBase& value) const { - GVariant* const g_value = - g_dbus_message_get_body(const_cast(gobj())); + GVariant* const g_value = g_dbus_message_get_body(const_cast(gobj())); - if(!g_value) + if (!g_value) return; value.init(g_value, true /* take a reference */); } -void Message::get_header(Glib::VariantBase& value, - MessageHeaderField header_field) const +void +Message::get_header(Glib::VariantBase& value, MessageHeaderField header_field) const { - GVariant* const g_value = - g_dbus_message_get_header(const_cast(gobj()), - ((GDBusMessageHeaderField)(header_field))); + GVariant* const g_value = g_dbus_message_get_header( + const_cast(gobj()), ((GDBusMessageHeaderField)(header_field))); - if(!g_value) + if (!g_value) return; value.init(g_value, true /* take a reference */); } #ifdef G_OS_UNIX -void Message::unset_unix_fd_list() +void +Message::unset_unix_fd_list() { g_dbus_message_set_unix_fd_list(gobj(), nullptr); } -#endif //G_OS_UNIX +#endif // G_OS_UNIX -} //namespace DBus +} // namespace DBus } // namespace Gio diff --git a/gio/src/dbusownname.ccg b/gio/src/dbusownname.ccg index 49de2042..db1a37b3 100644 --- a/gio/src/dbusownname.ccg +++ b/gio/src/dbusownname.ccg @@ -31,11 +31,10 @@ struct OwnSlots Gio::DBus::SlotNameLost* name_lost_slot; }; -extern "C" -{ +extern "C" { -static void Bus_Acquired_giomm_callback(GDBusConnection* connection, - const gchar* name, gpointer data) +static void +Bus_Acquired_giomm_callback(GDBusConnection* connection, const gchar* name, gpointer data) { auto slots = static_cast(data); auto the_slot = slots->bus_acquired_slot; @@ -44,14 +43,14 @@ static void Bus_Acquired_giomm_callback(GDBusConnection* connection, { (*the_slot)(Glib::wrap(connection, true), Glib::convert_const_gchar_ptr_to_ustring(name)); } - catch(...) + catch (...) { Glib::exception_handlers_invoke(); } } -static void Bus_Name_Acquired_giomm_callback(GDBusConnection* connection, - const gchar* name, gpointer data) +static void +Bus_Name_Acquired_giomm_callback(GDBusConnection* connection, const gchar* name, gpointer data) { auto slots = static_cast(data); auto the_slot = slots->name_acquired_slot; @@ -60,14 +59,14 @@ static void Bus_Name_Acquired_giomm_callback(GDBusConnection* connection, { (*the_slot)(Glib::wrap(connection, true), Glib::convert_const_gchar_ptr_to_ustring(name)); } - catch(...) + catch (...) { Glib::exception_handlers_invoke(); } } -static void Bus_Name_Lost_giomm_callback(GDBusConnection* connection, - const gchar* name, gpointer data) +static void +Bus_Name_Lost_giomm_callback(GDBusConnection* connection, const gchar* name, gpointer data) { auto slots = static_cast(data); auto the_slot = slots->name_lost_slot; @@ -76,23 +75,24 @@ static void Bus_Name_Lost_giomm_callback(GDBusConnection* connection, { (*the_slot)(Glib::wrap(connection, true), Glib::convert_const_gchar_ptr_to_ustring(name)); } - catch(...) + catch (...) { Glib::exception_handlers_invoke(); } } -static void Bus_Own_Name_giomm_callback_destroy(void* data) +static void +Bus_Own_Name_giomm_callback_destroy(void* data) { - auto slots = static_cast(data); + auto slots = static_cast(data); - if(slots->bus_acquired_slot) + if (slots->bus_acquired_slot) delete slots->bus_acquired_slot; - if(slots->name_acquired_slot) + if (slots->name_acquired_slot) delete slots->name_acquired_slot; - if(slots->name_lost_slot) + if (slots->name_lost_slot) delete slots->name_lost_slot; delete slots; @@ -102,21 +102,16 @@ static void Bus_Own_Name_giomm_callback_destroy(void* data) } // anonymous namespace - namespace Gio { namespace DBus { -guint own_name( - BusType bus_type, - const Glib::ustring& name, - const SlotBusAcquired& bus_acquired_slot, - const SlotNameAcquired& name_acquired_slot, - const SlotNameLost& name_lost_slot, - BusNameOwnerFlags flags -) +guint +own_name(BusType bus_type, const Glib::ustring& name, const SlotBusAcquired& bus_acquired_slot, + const SlotNameAcquired& name_acquired_slot, const SlotNameLost& name_lost_slot, + BusNameOwnerFlags flags) { auto slots = new OwnSlots; @@ -131,7 +126,8 @@ guint own_name( &Bus_Own_Name_giomm_callback_destroy); } -void unown_name(guint owner_id) +void +unown_name(guint owner_id) { g_bus_unown_name(owner_id); } diff --git a/gio/src/dbusproxy.ccg b/gio/src/dbusproxy.ccg index aac660ec..a8185739 100644 --- a/gio/src/dbusproxy.ccg +++ b/gio/src/dbusproxy.ccg @@ -30,348 +30,245 @@ namespace Gio namespace DBus { -//Help the generate code: +// Help the generate code: typedef Proxy::MapChangedProperties MapChangedProperties; -Proxy::Proxy(const Glib::RefPtr& connection, - const Glib::ustring& name, - const Glib::ustring& object_path, - const Glib::ustring& interface_name, - const SlotAsyncReady& slot, - const Glib::RefPtr& cancellable, - const Glib::RefPtr& info, +Proxy::Proxy(const Glib::RefPtr& connection, const Glib::ustring& name, + const Glib::ustring& object_path, const Glib::ustring& interface_name, const SlotAsyncReady& slot, + const Glib::RefPtr& cancellable, const Glib::RefPtr& info, ProxyFlags flags) -: -_CONSTRUCT("g-connection", Glib::unwrap(connection), - "g-flags", static_cast(flags), - "g-interface-info", Glib::unwrap(info), - "g-name", Glib::c_str_or_nullptr(name), - "g-object-path", Glib::c_str_or_nullptr(object_path), - "g-interface-name", Glib::c_str_or_nullptr(interface_name)) +: _CONSTRUCT("g-connection", Glib::unwrap(connection), "g-flags", + static_cast(flags), "g-interface-info", Glib::unwrap(info), "g-name", + Glib::c_str_or_nullptr(name), "g-object-path", Glib::c_str_or_nullptr(object_path), + "g-interface-name", Glib::c_str_or_nullptr(interface_name)) { init_async(slot, cancellable); } -Proxy::Proxy(const Glib::RefPtr& connection, - const Glib::ustring& name, - const Glib::ustring& object_path, - const Glib::ustring& interface_name, - const SlotAsyncReady& slot, - const Glib::RefPtr& info, - ProxyFlags flags) -: -_CONSTRUCT("g-connection", Glib::unwrap(connection), - "g-flags", static_cast(flags), - "g-interface-info", Glib::unwrap(info), - "g-name", Glib::c_str_or_nullptr(name), - "g-object-path", Glib::c_str_or_nullptr(object_path), - "g-interface-name", Glib::c_str_or_nullptr(interface_name)) +Proxy::Proxy(const Glib::RefPtr& connection, const Glib::ustring& name, + const Glib::ustring& object_path, const Glib::ustring& interface_name, const SlotAsyncReady& slot, + const Glib::RefPtr& info, ProxyFlags flags) +: _CONSTRUCT("g-connection", Glib::unwrap(connection), "g-flags", + static_cast(flags), "g-interface-info", Glib::unwrap(info), "g-name", + Glib::c_str_or_nullptr(name), "g-object-path", Glib::c_str_or_nullptr(object_path), + "g-interface-name", Glib::c_str_or_nullptr(interface_name)) { init_async(slot); } -Proxy::Proxy(const Glib::RefPtr& connection, - const Glib::ustring& name, - const Glib::ustring& object_path, - const Glib::ustring& interface_name, - const Glib::RefPtr& cancellable, - const Glib::RefPtr& info, +Proxy::Proxy(const Glib::RefPtr& connection, const Glib::ustring& name, + const Glib::ustring& object_path, const Glib::ustring& interface_name, + const Glib::RefPtr& cancellable, const Glib::RefPtr& info, ProxyFlags flags) -: -_CONSTRUCT("g-connection", Glib::unwrap(connection), - "g-flags", static_cast(flags), - "g-interface-info", Glib::unwrap(info), - "g-name", Glib::c_str_or_nullptr(name), - "g-object-path", Glib::c_str_or_nullptr(object_path), - "g-interface-name", Glib::c_str_or_nullptr(interface_name)) +: _CONSTRUCT("g-connection", Glib::unwrap(connection), "g-flags", + static_cast(flags), "g-interface-info", Glib::unwrap(info), "g-name", + Glib::c_str_or_nullptr(name), "g-object-path", Glib::c_str_or_nullptr(object_path), + "g-interface-name", Glib::c_str_or_nullptr(interface_name)) { init(cancellable); } -Proxy::Proxy(const Glib::RefPtr& connection, - const Glib::ustring& name, - const Glib::ustring& object_path, - const Glib::ustring& interface_name, - const Glib::RefPtr& info, - ProxyFlags flags) -: -_CONSTRUCT("g-connection", Glib::unwrap(connection), - "g-flags", static_cast(flags), - "g-interface-info", Glib::unwrap(info), - "g-name", Glib::c_str_or_nullptr(name), - "g-object-path", Glib::c_str_or_nullptr(object_path), - "g-interface-name", Glib::c_str_or_nullptr(interface_name)) +Proxy::Proxy(const Glib::RefPtr& connection, const Glib::ustring& name, + const Glib::ustring& object_path, const Glib::ustring& interface_name, + const Glib::RefPtr& info, ProxyFlags flags) +: _CONSTRUCT("g-connection", Glib::unwrap(connection), "g-flags", + static_cast(flags), "g-interface-info", Glib::unwrap(info), "g-name", + Glib::c_str_or_nullptr(name), "g-object-path", Glib::c_str_or_nullptr(object_path), + "g-interface-name", Glib::c_str_or_nullptr(interface_name)) { init(); } -Proxy::Proxy(BusType bus_type, - const Glib::ustring& name, - const Glib::ustring& object_path, - const Glib::ustring& interface_name, - const SlotAsyncReady& slot, - const Glib::RefPtr& cancellable, - const Glib::RefPtr& info, +Proxy::Proxy(BusType bus_type, const Glib::ustring& name, const Glib::ustring& object_path, + const Glib::ustring& interface_name, const SlotAsyncReady& slot, + const Glib::RefPtr& cancellable, const Glib::RefPtr& info, ProxyFlags flags) -: -_CONSTRUCT("g-bus-type", static_cast(bus_type), - "g-flags", static_cast(flags), - "g-interface-info", Glib::unwrap(info), - "g-name", Glib::c_str_or_nullptr(name), - "g-object-path", Glib::c_str_or_nullptr(object_path), - "g-interface-name", Glib::c_str_or_nullptr(interface_name)) +: _CONSTRUCT("g-bus-type", static_cast(bus_type), "g-flags", + static_cast(flags), "g-interface-info", Glib::unwrap(info), "g-name", + Glib::c_str_or_nullptr(name), "g-object-path", Glib::c_str_or_nullptr(object_path), + "g-interface-name", Glib::c_str_or_nullptr(interface_name)) { init_async(slot, cancellable); } -Proxy::Proxy(BusType bus_type, - const Glib::ustring& name, - const Glib::ustring& object_path, - const Glib::ustring& interface_name, - const SlotAsyncReady& slot, - const Glib::RefPtr& info, - ProxyFlags flags) -: -_CONSTRUCT("g-bus-type", static_cast(bus_type), - "g-flags", static_cast(flags), - "g-interface-info", Glib::unwrap(info), - "g-name", Glib::c_str_or_nullptr(name), - "g-object-path", Glib::c_str_or_nullptr(object_path), - "g-interface-name", Glib::c_str_or_nullptr(interface_name)) +Proxy::Proxy(BusType bus_type, const Glib::ustring& name, const Glib::ustring& object_path, + const Glib::ustring& interface_name, const SlotAsyncReady& slot, + const Glib::RefPtr& info, ProxyFlags flags) +: _CONSTRUCT("g-bus-type", static_cast(bus_type), "g-flags", + static_cast(flags), "g-interface-info", Glib::unwrap(info), "g-name", + Glib::c_str_or_nullptr(name), "g-object-path", Glib::c_str_or_nullptr(object_path), + "g-interface-name", Glib::c_str_or_nullptr(interface_name)) { init_async(slot); } -Proxy::Proxy(BusType bus_type, - const Glib::ustring& name, - const Glib::ustring& object_path, - const Glib::ustring& interface_name, - const Glib::RefPtr& cancellable, - const Glib::RefPtr& info, - ProxyFlags flags) -: -_CONSTRUCT("g-bus-type", static_cast(bus_type), - "g-flags", static_cast(flags), - "g-interface-info", Glib::unwrap(info), - "g-name", Glib::c_str_or_nullptr(name), - "g-object-path", Glib::c_str_or_nullptr(object_path), - "g-interface-name", Glib::c_str_or_nullptr(interface_name)) +Proxy::Proxy(BusType bus_type, const Glib::ustring& name, const Glib::ustring& object_path, + const Glib::ustring& interface_name, const Glib::RefPtr& cancellable, + const Glib::RefPtr& info, ProxyFlags flags) +: _CONSTRUCT("g-bus-type", static_cast(bus_type), "g-flags", + static_cast(flags), "g-interface-info", Glib::unwrap(info), "g-name", + Glib::c_str_or_nullptr(name), "g-object-path", Glib::c_str_or_nullptr(object_path), + "g-interface-name", Glib::c_str_or_nullptr(interface_name)) { init(cancellable); } -Proxy::Proxy(BusType bus_type, - const Glib::ustring& name, - const Glib::ustring& object_path, - const Glib::ustring& interface_name, - const Glib::RefPtr& info, - ProxyFlags flags) -: -_CONSTRUCT("g-bus-type", static_cast(bus_type), - "g-flags", static_cast(flags), - "g-interface-info", Glib::unwrap(info), - "g-name", Glib::c_str_or_nullptr(name), - "g-object-path", Glib::c_str_or_nullptr(object_path), - "g-interface-name", Glib::c_str_or_nullptr(interface_name)) +Proxy::Proxy(BusType bus_type, const Glib::ustring& name, const Glib::ustring& object_path, + const Glib::ustring& interface_name, const Glib::RefPtr& info, ProxyFlags flags) +: _CONSTRUCT("g-bus-type", static_cast(bus_type), "g-flags", + static_cast(flags), "g-interface-info", Glib::unwrap(info), "g-name", + Glib::c_str_or_nullptr(name), "g-object-path", Glib::c_str_or_nullptr(object_path), + "g-interface-name", Glib::c_str_or_nullptr(interface_name)) { init(); } -void Proxy::create(const Glib::RefPtr& connection, - const Glib::ustring& name, - const Glib::ustring& object_path, - const Glib::ustring& interface_name, - const SlotAsyncReady& slot, - const Glib::RefPtr& cancellable, - const Glib::RefPtr& info, +void +Proxy::create(const Glib::RefPtr& connection, const Glib::ustring& name, + const Glib::ustring& object_path, const Glib::ustring& interface_name, const SlotAsyncReady& slot, + const Glib::RefPtr& cancellable, const Glib::RefPtr& info, ProxyFlags flags) { - Proxy(connection, name, object_path, interface_name, slot, - cancellable, info, flags); + Proxy(connection, name, object_path, interface_name, slot, cancellable, info, flags); } -void Proxy::create(const Glib::RefPtr& connection, - const Glib::ustring& name, - const Glib::ustring& object_path, - const Glib::ustring& interface_name, - const SlotAsyncReady& slot, - const Glib::RefPtr& info, - ProxyFlags flags) +void +Proxy::create(const Glib::RefPtr& connection, const Glib::ustring& name, + const Glib::ustring& object_path, const Glib::ustring& interface_name, const SlotAsyncReady& slot, + const Glib::RefPtr& info, ProxyFlags flags) { Proxy(connection, name, object_path, interface_name, slot, info, flags); } Glib::RefPtr -Proxy::create_sync(const Glib::RefPtr& connection, - const Glib::ustring& name, - const Glib::ustring& object_path, - const Glib::ustring& interface_name, - const Glib::RefPtr& cancellable, - const Glib::RefPtr& info, +Proxy::create_sync(const Glib::RefPtr& connection, const Glib::ustring& name, + const Glib::ustring& object_path, const Glib::ustring& interface_name, + const Glib::RefPtr& cancellable, const Glib::RefPtr& info, ProxyFlags flags) { - return Glib::RefPtr(new Proxy(connection, name, - object_path, interface_name, cancellable, info, flags)); + return Glib::RefPtr( + new Proxy(connection, name, object_path, interface_name, cancellable, info, flags)); } Glib::RefPtr -Proxy::create_sync(const Glib::RefPtr& connection, - const Glib::ustring& name, - const Glib::ustring& object_path, - const Glib::ustring& interface_name, - const Glib::RefPtr& info, - ProxyFlags flags) +Proxy::create_sync(const Glib::RefPtr& connection, const Glib::ustring& name, + const Glib::ustring& object_path, const Glib::ustring& interface_name, + const Glib::RefPtr& info, ProxyFlags flags) { - return Glib::RefPtr(new Proxy(connection, name, - object_path, interface_name, info, flags)); + return Glib::RefPtr(new Proxy(connection, name, object_path, interface_name, info, flags)); } -void Proxy::create_for_bus(BusType bus_type, - const Glib::ustring& name, - const Glib::ustring& object_path, - const Glib::ustring& interface_name, - const SlotAsyncReady& slot, - const Glib::RefPtr& cancellable, - const Glib::RefPtr& info, +void +Proxy::create_for_bus(BusType bus_type, const Glib::ustring& name, const Glib::ustring& object_path, + const Glib::ustring& interface_name, const SlotAsyncReady& slot, + const Glib::RefPtr& cancellable, const Glib::RefPtr& info, ProxyFlags flags) { - Proxy(bus_type, name, object_path, interface_name, slot, cancellable, - info, flags); + Proxy(bus_type, name, object_path, interface_name, slot, cancellable, info, flags); } -void Proxy::create_for_bus(BusType bus_type, - const Glib::ustring& name, - const Glib::ustring& object_path, - const Glib::ustring& interface_name, - const SlotAsyncReady& slot, - const Glib::RefPtr& info, - ProxyFlags flags) +void +Proxy::create_for_bus(BusType bus_type, const Glib::ustring& name, const Glib::ustring& object_path, + const Glib::ustring& interface_name, const SlotAsyncReady& slot, + const Glib::RefPtr& info, ProxyFlags flags) { Proxy(bus_type, name, object_path, interface_name, slot, info, flags); } -Glib::RefPtr Proxy::create_for_bus_sync(BusType bus_type, - const Glib::ustring& name, - const Glib::ustring& object_path, - const Glib::ustring& interface_name, - const Glib::RefPtr& cancellable, - const Glib::RefPtr& info, +Glib::RefPtr +Proxy::create_for_bus_sync(BusType bus_type, const Glib::ustring& name, + const Glib::ustring& object_path, const Glib::ustring& interface_name, + const Glib::RefPtr& cancellable, const Glib::RefPtr& info, ProxyFlags flags) { - return Glib::RefPtr(new Proxy(bus_type, name, - object_path, interface_name, cancellable, info, flags)); + return Glib::RefPtr( + new Proxy(bus_type, name, object_path, interface_name, cancellable, info, flags)); } -Glib::RefPtr Proxy::create_for_bus_sync(BusType bus_type, - const Glib::ustring& name, - const Glib::ustring& object_path, - const Glib::ustring& interface_name, - const Glib::RefPtr& info, - ProxyFlags flags) +Glib::RefPtr +Proxy::create_for_bus_sync(BusType bus_type, const Glib::ustring& name, + const Glib::ustring& object_path, const Glib::ustring& interface_name, + const Glib::RefPtr& info, ProxyFlags flags) { - return Glib::RefPtr(new Proxy(bus_type, name, - object_path, interface_name, info, flags)); + return Glib::RefPtr(new Proxy(bus_type, name, object_path, interface_name, info, flags)); } -void Proxy::get_cached_property(Glib::VariantBase& property, - const Glib::ustring& property_name) const +void +Proxy::get_cached_property(Glib::VariantBase& property, const Glib::ustring& property_name) const { GVariant* const g_variant = - g_dbus_proxy_get_cached_property(const_cast(gobj()), - property_name.c_str()); + g_dbus_proxy_get_cached_property(const_cast(gobj()), property_name.c_str()); property.init(g_variant, false /* no extra reference needed */); } -void Proxy::call(const Glib::ustring& method_name, - const SlotAsyncReady& slot, - const Glib::RefPtr& cancellable, - const Glib::VariantContainerBase& parameters, - int timeout_msec, - CallFlags flags -) +void +Proxy::call(const Glib::ustring& method_name, const SlotAsyncReady& slot, + const Glib::RefPtr& cancellable, const Glib::VariantContainerBase& parameters, + int timeout_msec, CallFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_dbus_proxy_call(gobj(), method_name.c_str(), - const_cast(parameters.gobj()), - static_cast(flags), timeout_msec, - Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); + g_dbus_proxy_call(gobj(), method_name.c_str(), const_cast(parameters.gobj()), + static_cast(flags), timeout_msec, Glib::unwrap(cancellable), + &SignalProxy_async_callback, slot_copy); } -void Proxy::call(const Glib::ustring& method_name, - const SlotAsyncReady& slot, - const Glib::VariantContainerBase& parameters, - int timeout_msec, - CallFlags flags -) +void +Proxy::call(const Glib::ustring& method_name, const SlotAsyncReady& slot, + const Glib::VariantContainerBase& parameters, int timeout_msec, CallFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_dbus_proxy_call(gobj(), method_name.c_str(), - const_cast(parameters.gobj()), - static_cast(flags), timeout_msec, - nullptr, &SignalProxy_async_callback, slot_copy); + g_dbus_proxy_call(gobj(), method_name.c_str(), const_cast(parameters.gobj()), + static_cast(flags), timeout_msec, nullptr, &SignalProxy_async_callback, + slot_copy); } -Glib::VariantContainerBase Proxy::call_sync( - const Glib::ustring& method_name, - const Glib::RefPtr& cancellable, - const Glib::VariantContainerBase& parameters, - int timeout_msec, - CallFlags flags -) +Glib::VariantContainerBase +Proxy::call_sync(const Glib::ustring& method_name, const Glib::RefPtr& cancellable, + const Glib::VariantContainerBase& parameters, int timeout_msec, CallFlags flags) { GError* g_error = nullptr; GVariant* const gvariant = - g_dbus_proxy_call_sync(gobj(), method_name.c_str(), - const_cast(parameters.gobj()), - static_cast(flags), timeout_msec, - Glib::unwrap(cancellable), &g_error); + g_dbus_proxy_call_sync(gobj(), method_name.c_str(), const_cast(parameters.gobj()), + static_cast(flags), timeout_msec, Glib::unwrap(cancellable), &g_error); - if(g_error) + if (g_error) ::Glib::Error::throw_exception(g_error); - return Glib::VariantContainerBase(gvariant, false); //Dont' take an extra reference. + return Glib::VariantContainerBase(gvariant, false); // Dont' take an extra reference. } -Glib::VariantContainerBase Proxy::call_sync( - const Glib::ustring& method_name, - const Glib::VariantContainerBase& parameters, - int timeout_msec, - CallFlags flags -) +Glib::VariantContainerBase +Proxy::call_sync(const Glib::ustring& method_name, const Glib::VariantContainerBase& parameters, + int timeout_msec, CallFlags flags) { GError* g_error = nullptr; GVariant* const gvariant = - g_dbus_proxy_call_sync(gobj(), method_name.c_str(), - const_cast(parameters.gobj()), - static_cast(flags), timeout_msec, nullptr, &g_error); + g_dbus_proxy_call_sync(gobj(), method_name.c_str(), const_cast(parameters.gobj()), + static_cast(flags), timeout_msec, nullptr, &g_error); - if(g_error) + if (g_error) ::Glib::Error::throw_exception(g_error); - return Glib::VariantContainerBase(gvariant, false); //Dont' take an extra reference. + return Glib::VariantContainerBase(gvariant, false); // Dont' take an extra reference. } #ifdef G_OS_UNIX // With a UnixFDList. -void Proxy::call( - const Glib::ustring& method_name, - const Glib::VariantContainerBase& parameters, - const SlotAsyncReady& slot, - const Glib::RefPtr& cancellable, - const Glib::RefPtr& fd_list, - int timeout_msec, - CallFlags flags) +void +Proxy::call(const Glib::ustring& method_name, const Glib::VariantContainerBase& parameters, + const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, + const Glib::RefPtr& fd_list, int timeout_msec, CallFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter @@ -379,19 +276,15 @@ void Proxy::call( auto slot_copy = new SlotAsyncReady(slot); g_dbus_proxy_call_with_unix_fd_list(gobj(), method_name.c_str(), - const_cast(parameters.gobj()), - static_cast(flags), timeout_msec, Glib::unwrap(fd_list), - Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); + const_cast(parameters.gobj()), static_cast(flags), timeout_msec, + Glib::unwrap(fd_list), Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } // Non-cancellable version (with a UnixFDList). -void Proxy::call( - const Glib::ustring& method_name, - const Glib::VariantContainerBase& parameters, - const SlotAsyncReady& slot, - const Glib::RefPtr& fd_list, - int timeout_msec, - CallFlags flags) +void +Proxy::call(const Glib::ustring& method_name, const Glib::VariantContainerBase& parameters, + const SlotAsyncReady& slot, const Glib::RefPtr& fd_list, int timeout_msec, + CallFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter @@ -399,12 +292,11 @@ void Proxy::call( auto slot_copy = new SlotAsyncReady(slot); g_dbus_proxy_call_with_unix_fd_list(gobj(), method_name.c_str(), - const_cast(parameters.gobj()), - static_cast(flags), timeout_msec, Glib::unwrap(fd_list), - nullptr, &SignalProxy_async_callback, slot_copy); + const_cast(parameters.gobj()), static_cast(flags), timeout_msec, + Glib::unwrap(fd_list), nullptr, &SignalProxy_async_callback, slot_copy); } #endif // G_OS_UNIX -} //namespace DBus +} // namespace DBus } // namespace Gio diff --git a/gio/src/dbusserver.ccg b/gio/src/dbusserver.ccg index 36c8af08..2d6aea8d 100644 --- a/gio/src/dbusserver.ccg +++ b/gio/src/dbusserver.ccg @@ -27,85 +27,66 @@ namespace Gio namespace DBus { -Server::Server(const std::string& address, - const std::string& guid, - const Glib::RefPtr& observer, - const Glib::RefPtr& cancellable, +Server::Server(const std::string& address, const std::string& guid, + const Glib::RefPtr& observer, const Glib::RefPtr& cancellable, ServerFlags flags) - : _CONSTRUCT("address", Glib::c_str_or_nullptr(address), - "flags", static_cast(flags), - "guid", Glib::c_str_or_nullptr(guid), +: _CONSTRUCT("address", Glib::c_str_or_nullptr(address), "flags", + static_cast(flags), "guid", Glib::c_str_or_nullptr(guid), "authentication-observer", Glib::unwrap(observer)) { init(cancellable); } -Server::Server(const std::string& address, - const std::string& guid, - const Glib::RefPtr& cancellable, - ServerFlags flags) - : _CONSTRUCT("address", Glib::c_str_or_nullptr(address), - "flags", static_cast(flags), - "guid", Glib::c_str_or_nullptr(guid), +Server::Server(const std::string& address, const std::string& guid, + const Glib::RefPtr& cancellable, ServerFlags flags) +: _CONSTRUCT("address", Glib::c_str_or_nullptr(address), "flags", + static_cast(flags), "guid", Glib::c_str_or_nullptr(guid), "authentication-observer", static_cast(nullptr)) { init(cancellable); } -Server::Server(const std::string& address, - const std::string& guid, - const Glib::RefPtr& observer, - ServerFlags flags) - : _CONSTRUCT("address", Glib::c_str_or_nullptr(address), - "flags", static_cast(flags), - "guid", Glib::c_str_or_nullptr(guid), +Server::Server(const std::string& address, const std::string& guid, + const Glib::RefPtr& observer, ServerFlags flags) +: _CONSTRUCT("address", Glib::c_str_or_nullptr(address), "flags", + static_cast(flags), "guid", Glib::c_str_or_nullptr(guid), "authentication-observer", Glib::unwrap(observer)) { init(); } -Server::Server(const std::string& address, - const std::string& guid, - ServerFlags flags) - : _CONSTRUCT("address", Glib::c_str_or_nullptr(address), - "flags", static_cast(flags), - "guid", Glib::c_str_or_nullptr(guid), +Server::Server(const std::string& address, const std::string& guid, ServerFlags flags) +: _CONSTRUCT("address", Glib::c_str_or_nullptr(address), "flags", + static_cast(flags), "guid", Glib::c_str_or_nullptr(guid), "authentication-observer", static_cast(nullptr)) { init(); } -Glib::RefPtr Server::create_sync(const std::string& address, - const std::string& guid, - const Glib::RefPtr& observer, - const Glib::RefPtr& cancellable, +Glib::RefPtr +Server::create_sync(const std::string& address, const std::string& guid, + const Glib::RefPtr& observer, const Glib::RefPtr& cancellable, ServerFlags flags) { - return Glib::RefPtr(new Server(address, guid, observer, - cancellable, flags)); + return Glib::RefPtr(new Server(address, guid, observer, cancellable, flags)); } -Glib::RefPtr Server::create_sync(const std::string& address, - const std::string& guid, - const Glib::RefPtr& cancellable, - ServerFlags flags) +Glib::RefPtr +Server::create_sync(const std::string& address, const std::string& guid, + const Glib::RefPtr& cancellable, ServerFlags flags) { - return Glib::RefPtr(new Server(address, guid, - cancellable, flags)); + return Glib::RefPtr(new Server(address, guid, cancellable, flags)); } -Glib::RefPtr Server::create_sync(const std::string& address, - const std::string& guid, - const Glib::RefPtr& observer, - ServerFlags flags) +Glib::RefPtr +Server::create_sync(const std::string& address, const std::string& guid, + const Glib::RefPtr& observer, ServerFlags flags) { - return Glib::RefPtr(new Server(address, guid, observer, - flags)); + return Glib::RefPtr(new Server(address, guid, observer, flags)); } -Glib::RefPtr Server::create_sync(const std::string& address, - const std::string& guid, - ServerFlags flags) +Glib::RefPtr +Server::create_sync(const std::string& address, const std::string& guid, ServerFlags flags) { return Glib::RefPtr(new Server(address, guid, flags)); } diff --git a/gio/src/dbussubtreevtable.ccg b/gio/src/dbussubtreevtable.ccg index 1b0e2956..0445386e 100644 --- a/gio/src/dbussubtreevtable.ccg +++ b/gio/src/dbussubtreevtable.ccg @@ -29,35 +29,31 @@ namespace { -extern "C" -{ +extern "C" { -static char** DBusSubtreeVTable_Enumerate_giomm_callback( - GDBusConnection* connection, const char* sender, const char* object_path, - void* user_data) +static char** +DBusSubtreeVTable_Enumerate_giomm_callback( + GDBusConnection* connection, const char* sender, const char* object_path, void* user_data) { - Gio::DBus::SubtreeVTable* vtable = - static_cast(user_data); + Gio::DBus::SubtreeVTable* vtable = static_cast(user_data); - Gio::DBus::SubtreeVTable::SlotSubtreeEnumerate* the_slot = - vtable->get_slot_enumerate(); + Gio::DBus::SubtreeVTable::SlotSubtreeEnumerate* the_slot = vtable->get_slot_enumerate(); try { - auto result = - (*the_slot)(Glib::wrap(connection, true), sender, object_path); + auto result = (*the_slot)(Glib::wrap(connection, true), sender, object_path); // This will be freed by the caller. char** ret = g_new(char*, result.size()); - for(std::vector::size_type i = 0; i < result.size(); i++) + for (std::vector::size_type i = 0; i < result.size(); i++) { ret[i] = g_strdup(result[i].c_str()); } return ret; } - catch(...) + catch (...) { Glib::exception_handlers_invoke(); } @@ -65,34 +61,30 @@ static char** DBusSubtreeVTable_Enumerate_giomm_callback( return nullptr; } -static GDBusInterfaceInfo** DBusSubtreeVTable_Introspect_giomm_callback( - GDBusConnection* connection, const char* sender, const char* object_path, - const char* node, void* user_data) +static GDBusInterfaceInfo** +DBusSubtreeVTable_Introspect_giomm_callback(GDBusConnection* connection, const char* sender, + const char* object_path, const char* node, void* user_data) { - Gio::DBus::SubtreeVTable* vtable = - static_cast(user_data); + Gio::DBus::SubtreeVTable* vtable = static_cast(user_data); - Gio::DBus::SubtreeVTable::SlotSubtreeIntrospect* the_slot = - vtable->get_slot_introspect(); + Gio::DBus::SubtreeVTable::SlotSubtreeIntrospect* the_slot = vtable->get_slot_introspect(); try { - auto result = - (*the_slot)(Glib::wrap(connection, true), sender, object_path, node); + auto result = (*the_slot)(Glib::wrap(connection, true), sender, object_path, node); // This will be freed by the caller, along with unreferencing its members. GDBusInterfaceInfo** info = g_new(GDBusInterfaceInfo*, result.size()); - for(std::vector< Glib::RefPtr >::size_type i = 0; - i < result.size(); i++) + for (std::vector>::size_type i = 0; i < result.size(); + i++) { - info[i] = static_cast( - g_object_ref(result[i]->gobj())); + info[i] = static_cast(g_object_ref(result[i]->gobj())); } return info; } - catch(...) + catch (...) { Glib::exception_handlers_invoke(); } @@ -100,28 +92,25 @@ static GDBusInterfaceInfo** DBusSubtreeVTable_Introspect_giomm_callback( return nullptr; } -static const GDBusInterfaceVTable* DBusSubtreeVTable_Dispatch_giomm_callback( - GDBusConnection* connection, const char* sender, const char* object_path, - const char* interface_name, const char* node, void** out_user_data, +static const GDBusInterfaceVTable* +DBusSubtreeVTable_Dispatch_giomm_callback(GDBusConnection* connection, const char* sender, + const char* object_path, const char* interface_name, const char* node, void** out_user_data, void* user_data) { - Gio::DBus::SubtreeVTable* vtable_subtree = - static_cast(user_data); + Gio::DBus::SubtreeVTable* vtable_subtree = static_cast(user_data); - Gio::DBus::SubtreeVTable::SlotSubtreeDispatch* the_slot = - vtable_subtree->get_slot_dispatch(); + Gio::DBus::SubtreeVTable::SlotSubtreeDispatch* the_slot = vtable_subtree->get_slot_dispatch(); try { - const Gio::DBus::InterfaceVTable* vtable_iface = - (*the_slot)(Glib::wrap(connection, true), sender, object_path, - interface_name, (node ? node : "")); + const Gio::DBus::InterfaceVTable* vtable_iface = (*the_slot)( + Glib::wrap(connection, true), sender, object_path, interface_name, (node ? node : "")); *out_user_data = const_cast(vtable_iface); return vtable_iface->gobj(); } - catch(...) + catch (...) { Glib::exception_handlers_invoke(); } @@ -130,7 +119,6 @@ static const GDBusInterfaceVTable* DBusSubtreeVTable_Dispatch_giomm_callback( } } // extern "C" - } namespace Gio @@ -139,12 +127,8 @@ namespace Gio namespace DBus { - -SubtreeVTable::SubtreeVTable( - const SlotSubtreeEnumerate& slot_enumerate, - const SlotSubtreeIntrospect& slot_introspect, - const SlotSubtreeDispatch& slot_dispatch -) +SubtreeVTable::SubtreeVTable(const SlotSubtreeEnumerate& slot_enumerate, + const SlotSubtreeIntrospect& slot_introspect, const SlotSubtreeDispatch& slot_dispatch) : slot_enumerate_(new SlotSubtreeEnumerate(slot_enumerate)), slot_introspect_(new SlotSubtreeIntrospect(slot_introspect)), slot_dispatch_(new SlotSubtreeDispatch(slot_dispatch)) @@ -155,17 +139,18 @@ SubtreeVTable::SubtreeVTable( } SubtreeVTable::SubtreeVTable(SubtreeVTable&& other) noexcept -: gobject_(std::move(other.gobject_)), - slot_enumerate_(std::move(other.slot_enumerate_)), - slot_introspect_(std::move(other.slot_introspect_)), - slot_dispatch_(std::move(other.slot_dispatch_)) + : gobject_(std::move(other.gobject_)), + slot_enumerate_(std::move(other.slot_enumerate_)), + slot_introspect_(std::move(other.slot_introspect_)), + slot_dispatch_(std::move(other.slot_dispatch_)) { other.slot_enumerate_ = nullptr; other.slot_introspect_ = nullptr; other.slot_dispatch_ = nullptr; } -SubtreeVTable& SubtreeVTable::operator=(SubtreeVTable&& other) noexcept +SubtreeVTable& +SubtreeVTable::operator=(SubtreeVTable&& other) noexcept { delete slot_enumerate_; delete slot_introspect_; @@ -191,23 +176,23 @@ SubtreeVTable::~SubtreeVTable() } SubtreeVTable::SlotSubtreeEnumerate* - SubtreeVTable::get_slot_enumerate() const +SubtreeVTable::get_slot_enumerate() const { return slot_enumerate_; } SubtreeVTable::SlotSubtreeIntrospect* - SubtreeVTable::get_slot_introspect() const +SubtreeVTable::get_slot_introspect() const { return slot_introspect_; } SubtreeVTable::SlotSubtreeDispatch* - SubtreeVTable::get_slot_dispatch() const +SubtreeVTable::get_slot_dispatch() const { return slot_dispatch_; } -} //namespace DBus +} // namespace DBus } // namespace Gio diff --git a/gio/src/dbusutils.ccg b/gio/src/dbusutils.ccg index 195b73c5..a614bceb 100644 --- a/gio/src/dbusutils.ccg +++ b/gio/src/dbusutils.ccg @@ -26,32 +26,38 @@ namespace Gio namespace DBus { -std::string generate_guid() +std::string +generate_guid() { return Glib::convert_const_gchar_ptr_to_stdstring(g_dbus_generate_guid()); } -bool is_guid(const std::string& string) +bool +is_guid(const std::string& string) { return static_cast(g_dbus_is_guid(string.c_str())); } -bool is_name(const Glib::ustring& string) +bool +is_name(const Glib::ustring& string) { return static_cast(g_dbus_is_name(string.c_str())); } -bool is_unique_name(const Glib::ustring& string) +bool +is_unique_name(const Glib::ustring& string) { return static_cast(g_dbus_is_unique_name(string.c_str())); } -bool is_member_name(const Glib::ustring& string) +bool +is_member_name(const Glib::ustring& string) { return static_cast(g_dbus_is_member_name(string.c_str())); } -bool is_interface_name(const Glib::ustring& string) +bool +is_interface_name(const Glib::ustring& string) { return static_cast(g_dbus_is_interface_name(string.c_str())); } diff --git a/gio/src/dbuswatchname.ccg b/gio/src/dbuswatchname.ccg index 0900b6a0..fa7a1ee3 100644 --- a/gio/src/dbuswatchname.ccg +++ b/gio/src/dbuswatchname.ccg @@ -30,11 +30,11 @@ struct WatchSlots Gio::DBus::SlotNameVanished* name_vanished_slot; }; -extern "C" -{ +extern "C" { -static void Bus_Name_Appeared_giomm_callback(GDBusConnection* connection, - const gchar* name, const char* name_owner, gpointer data) +static void +Bus_Name_Appeared_giomm_callback( + GDBusConnection* connection, const gchar* name, const char* name_owner, gpointer data) { auto slots = static_cast(data); auto the_slot = slots->name_appeared_slot; @@ -44,14 +44,14 @@ static void Bus_Name_Appeared_giomm_callback(GDBusConnection* connection, (*the_slot)(Glib::wrap(connection, true), Glib::convert_const_gchar_ptr_to_ustring(name), Glib::convert_const_gchar_ptr_to_ustring(name_owner)); } - catch(...) + catch (...) { Glib::exception_handlers_invoke(); } } -static void Bus_Name_Vanished_giomm_callback(GDBusConnection* connection, - const gchar* name, gpointer data) +static void +Bus_Name_Vanished_giomm_callback(GDBusConnection* connection, const gchar* name, gpointer data) { auto slots = static_cast(data); auto the_slot = slots->name_vanished_slot; @@ -60,20 +60,21 @@ static void Bus_Name_Vanished_giomm_callback(GDBusConnection* connection, { (*the_slot)(Glib::wrap(connection, true), Glib::convert_const_gchar_ptr_to_ustring(name)); } - catch(...) + catch (...) { Glib::exception_handlers_invoke(); } } -static void Bus_Watch_Name_giomm_callback_destroy(void* data) +static void +Bus_Watch_Name_giomm_callback_destroy(void* data) { - auto slots = static_cast(data); + auto slots = static_cast(data); - if(slots->name_appeared_slot) + if (slots->name_appeared_slot) delete slots->name_appeared_slot; - if(slots->name_vanished_slot) + if (slots->name_vanished_slot) delete slots->name_vanished_slot; delete slots; @@ -83,20 +84,15 @@ static void Bus_Watch_Name_giomm_callback_destroy(void* data) } // anonymous namespace - namespace Gio { namespace DBus { -guint watch_name( - BusType bus_type, - const Glib::ustring& name, - const SlotNameAppeared& name_appeared_slot, - const SlotNameVanished& name_vanished_slot, - BusNameWatcherFlags flags -) +guint +watch_name(BusType bus_type, const Glib::ustring& name, const SlotNameAppeared& name_appeared_slot, + const SlotNameVanished& name_vanished_slot, BusNameWatcherFlags flags) { auto slots = new WatchSlots; @@ -105,18 +101,14 @@ guint watch_name( slots->name_vanished_slot = new SlotNameVanished(name_vanished_slot); return g_bus_watch_name(static_cast(bus_type), name.c_str(), - static_cast(flags), - &Bus_Name_Appeared_giomm_callback, &Bus_Name_Vanished_giomm_callback, - slots, &Bus_Watch_Name_giomm_callback_destroy); + static_cast(flags), &Bus_Name_Appeared_giomm_callback, + &Bus_Name_Vanished_giomm_callback, slots, &Bus_Watch_Name_giomm_callback_destroy); } -guint watch_name( - const Glib::RefPtr& connection, - const Glib::ustring& name, - const SlotNameAppeared& name_appeared_slot, - const SlotNameVanished& name_vanished_slot, - BusNameWatcherFlags flags -) +guint +watch_name(const Glib::RefPtr& connection, const Glib::ustring& name, + const SlotNameAppeared& name_appeared_slot, const SlotNameVanished& name_vanished_slot, + BusNameWatcherFlags flags) { auto slots = new WatchSlots; @@ -124,13 +116,13 @@ guint watch_name( slots->name_appeared_slot = new SlotNameAppeared(name_appeared_slot); slots->name_vanished_slot = new SlotNameVanished(name_vanished_slot); - return g_bus_watch_name_on_connection(Glib::unwrap(connection), - name.c_str(), static_cast(flags), - &Bus_Name_Appeared_giomm_callback, &Bus_Name_Vanished_giomm_callback, - slots, &Bus_Watch_Name_giomm_callback_destroy); + return g_bus_watch_name_on_connection(Glib::unwrap(connection), name.c_str(), + static_cast(flags), &Bus_Name_Appeared_giomm_callback, + &Bus_Name_Vanished_giomm_callback, slots, &Bus_Watch_Name_giomm_callback_destroy); } -void unwatch_name(guint watcher_id) +void +unwatch_name(guint watcher_id) { g_bus_unwatch_name(watcher_id); } diff --git a/gio/src/drive.ccg b/gio/src/drive.ccg index 0adb0dcc..c75dd14d 100644 --- a/gio/src/drive.ccg +++ b/gio/src/drive.ccg @@ -26,100 +26,96 @@ namespace Gio { -void Drive::eject(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, MountUnmountFlags flags) +void +Drive::eject( + const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, MountUnmountFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_drive_eject_with_operation(gobj(), - static_cast(flags), - nullptr, // mount_operation - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_drive_eject_with_operation(gobj(), static_cast(flags), + nullptr, // mount_operation + Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } -void Drive::eject(const SlotAsyncReady& slot, MountUnmountFlags flags) +void +Drive::eject(const SlotAsyncReady& slot, MountUnmountFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_drive_eject_with_operation(gobj(), - static_cast(flags), - nullptr, // mount_operation - nullptr, // cancellable - &SignalProxy_async_callback, - slot_copy); + g_drive_eject_with_operation(gobj(), static_cast(flags), + nullptr, // mount_operation + nullptr, // cancellable + &SignalProxy_async_callback, slot_copy); } -void Drive::eject(const Glib::RefPtr& mount_operation, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, MountUnmountFlags flags) +void +Drive::eject(const Glib::RefPtr& mount_operation, const SlotAsyncReady& slot, + const Glib::RefPtr& cancellable, MountUnmountFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_drive_eject_with_operation(gobj(), - static_cast(flags), - Glib::unwrap(mount_operation), - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_drive_eject_with_operation(gobj(), static_cast(flags), + Glib::unwrap(mount_operation), Glib::unwrap(cancellable), &SignalProxy_async_callback, + slot_copy); } -void Drive::eject(const Glib::RefPtr& mount_operation, const SlotAsyncReady& slot, MountUnmountFlags flags) +void +Drive::eject(const Glib::RefPtr& mount_operation, const SlotAsyncReady& slot, + MountUnmountFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_drive_eject_with_operation(gobj(), - static_cast(flags), - Glib::unwrap(mount_operation), - nullptr, // cancellable - &SignalProxy_async_callback, - slot_copy); + g_drive_eject_with_operation(gobj(), static_cast(flags), + Glib::unwrap(mount_operation), + nullptr, // cancellable + &SignalProxy_async_callback, slot_copy); } -void Drive::eject(const Glib::RefPtr& mount_operation, MountUnmountFlags flags) +void +Drive::eject(const Glib::RefPtr& mount_operation, MountUnmountFlags flags) { - g_drive_eject_with_operation(gobj(), - static_cast(flags), - Glib::unwrap(mount_operation), - nullptr, // cancellable - nullptr, // callback - nullptr); // user_data + g_drive_eject_with_operation(gobj(), static_cast(flags), + Glib::unwrap(mount_operation), + nullptr, // cancellable + nullptr, // callback + nullptr); // user_data } -void Drive::eject(MountUnmountFlags flags) +void +Drive::eject(MountUnmountFlags flags) { - g_drive_eject_with_operation(gobj(), - static_cast(flags), - nullptr, // mount_operation - nullptr, // cancellable - nullptr, // callback - nullptr); // user_data + g_drive_eject_with_operation(gobj(), static_cast(flags), + nullptr, // mount_operation + nullptr, // cancellable + nullptr, // callback + nullptr); // user_data } -void Drive::poll_for_media(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable) +void +Drive::poll_for_media(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_drive_poll_for_media(gobj(), - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_drive_poll_for_media(gobj(), Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } -void Drive::poll_for_media(const SlotAsyncReady& slot) +void +Drive::poll_for_media(const SlotAsyncReady& slot) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter @@ -127,93 +123,68 @@ void Drive::poll_for_media(const SlotAsyncReady& slot) auto slot_copy = new SlotAsyncReady(slot); g_drive_poll_for_media(gobj(), - nullptr, // cancellable - &SignalProxy_async_callback, - slot_copy); + nullptr, // cancellable + &SignalProxy_async_callback, slot_copy); } -void Drive::poll_for_media() +void +Drive::poll_for_media() { g_drive_poll_for_media(gobj(), - nullptr, // cancellable - nullptr, - nullptr); + nullptr, // cancellable + nullptr, nullptr); } void Drive::stop(const Glib::RefPtr& mount_operation, - const Glib::RefPtr& cancellable, - const SlotAsyncReady& slot, - MountUnmountFlags flags) + const Glib::RefPtr& cancellable, const SlotAsyncReady& slot, MountUnmountFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_drive_stop(gobj(), - static_cast(flags), - Glib::unwrap(mount_operation), - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_drive_stop(gobj(), static_cast(flags), Glib::unwrap(mount_operation), + Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } void -Drive::stop(const Glib::RefPtr& mount_operation, - const SlotAsyncReady& slot, - MountUnmountFlags flags) +Drive::stop(const Glib::RefPtr& mount_operation, const SlotAsyncReady& slot, + MountUnmountFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_drive_stop(gobj(), - static_cast(flags), - Glib::unwrap(mount_operation), - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_drive_stop(gobj(), static_cast(flags), Glib::unwrap(mount_operation), + nullptr, &SignalProxy_async_callback, slot_copy); } - void Drive::start(const Glib::RefPtr& mount_operation, - const Glib::RefPtr& cancellable, - const SlotAsyncReady& slot, - DriveStartFlags flags) + const Glib::RefPtr& cancellable, const SlotAsyncReady& slot, DriveStartFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_drive_start(gobj(), - static_cast(flags), - Glib::unwrap(mount_operation), - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_drive_start(gobj(), static_cast(flags), Glib::unwrap(mount_operation), + Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } void -Drive::start(const Glib::RefPtr& mount_operation, - const SlotAsyncReady& slot, - DriveStartFlags flags) +Drive::start(const Glib::RefPtr& mount_operation, const SlotAsyncReady& slot, + DriveStartFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_drive_start(gobj(), - static_cast(flags), - Glib::unwrap(mount_operation), - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_drive_start(gobj(), static_cast(flags), Glib::unwrap(mount_operation), + nullptr, &SignalProxy_async_callback, slot_copy); } } // namespace Gio - diff --git a/gio/src/emblem.ccg b/gio/src/emblem.ccg index c146baae..5317f389 100644 --- a/gio/src/emblem.ccg +++ b/gio/src/emblem.ccg @@ -22,4 +22,4 @@ namespace Gio { -} //namespace Gio +} // namespace Gio diff --git a/gio/src/emblemedicon.ccg b/gio/src/emblemedicon.ccg index 695e1d50..faa8e37d 100644 --- a/gio/src/emblemedicon.ccg +++ b/gio/src/emblemedicon.ccg @@ -22,10 +22,8 @@ namespace Gio { -EmblemedIcon::EmblemedIcon(const Glib::RefPtr& icon) -: - _CONSTRUCT("icon", Glib::unwrap(icon)) +EmblemedIcon::EmblemedIcon(const Glib::RefPtr& icon) : _CONSTRUCT("icon", Glib::unwrap(icon)) { } -} //namespace Gio +} // namespace Gio diff --git a/gio/src/enums.ccg b/gio/src/enums.ccg index ce51b4b6..24ee9e89 100644 --- a/gio/src/enums.ccg +++ b/gio/src/enums.ccg @@ -16,4 +16,3 @@ * License along with this library; if not, write to the Free * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - diff --git a/gio/src/file.ccg b/gio/src/file.ccg index 0aeb8ba4..b9b8771c 100644 --- a/gio/src/file.ccg +++ b/gio/src/file.ccg @@ -30,9 +30,8 @@ typedef std::pair Mea typedef std::pair LoadPartialSlots; static void -SignalProxy_file_progress_callback(goffset current_num_bytes, - goffset total_num_bytes, - gpointer data) +SignalProxy_file_progress_callback( + goffset current_num_bytes, goffset total_num_bytes, gpointer data) { auto the_slot = static_cast(data); @@ -40,9 +39,8 @@ SignalProxy_file_progress_callback(goffset current_num_bytes, { (*the_slot)(current_num_bytes, total_num_bytes); - } - catch(...) + catch (...) { Glib::exception_handlers_invoke(); } @@ -59,13 +57,13 @@ SignalProxy_file_copy_async_callback(GObject*, GAsyncResult* res, void* data) try { - if(*the_slot) + if (*the_slot) { auto result = Glib::wrap(res, true /* take copy */); (*the_slot)(result); } } - catch(...) + catch (...) { Glib::exception_handlers_invoke(); } @@ -75,7 +73,6 @@ SignalProxy_file_copy_async_callback(GObject*, GAsyncResult* res, void* data) delete slot_pair; } - // Same as SignalProxy_async_callback, except that this one knows that // the slot is packed in a pair. The operation is assumed to be finished // after the callback is triggered, so we delete that pair here. @@ -87,13 +84,13 @@ SignalProxy_file_measure_async_callback(GObject*, GAsyncResult* res, void* data) try { - if(*the_slot) + if (*the_slot) { auto result = Glib::wrap(res, true /* take copy */); (*the_slot)(result); } } - catch(...) + catch (...) { Glib::exception_handlers_invoke(); } @@ -104,7 +101,8 @@ SignalProxy_file_measure_async_callback(GObject*, GAsyncResult* res, void* data) } static gboolean -SignalProxy_load_partial_contents_read_more_callback(const char* file_contents, goffset file_size, gpointer data) +SignalProxy_load_partial_contents_read_more_callback( + const char* file_contents, goffset file_size, gpointer data) { auto slot_pair = static_cast(data); auto the_slot = slot_pair->first; @@ -115,9 +113,8 @@ SignalProxy_load_partial_contents_read_more_callback(const char* file_contents, { result = (*the_slot)(file_contents, file_size); - } - catch(...) + catch (...) { Glib::exception_handlers_invoke(); } @@ -139,7 +136,7 @@ SignalProxy_load_partial_contents_ready_callback(GObject*, GAsyncResult* res, vo auto result = Glib::wrap(res, true /* take copy */); (*the_slot)(result); } - catch(...) + catch (...) { Glib::exception_handlers_invoke(); } @@ -150,21 +147,18 @@ SignalProxy_load_partial_contents_ready_callback(GObject*, GAsyncResult* res, vo } static void -SignalProxy_file_measure_progress_callback(gboolean reporting, - guint64 current_size, - guint64 num_dirs, - guint64 num_files, - gpointer data) +SignalProxy_file_measure_progress_callback( + gboolean reporting, guint64 current_size, guint64 num_dirs, guint64 num_files, gpointer data) { - Gio::File::SlotFileMeasureProgress* the_slot = static_cast(data); + Gio::File::SlotFileMeasureProgress* the_slot = + static_cast(data); try { (*the_slot)(reporting, current_size, num_dirs, num_files); - } - catch(...) + catch (...) { Glib::exception_handlers_invoke(); } @@ -172,7 +166,8 @@ SignalProxy_file_measure_progress_callback(gboolean reporting, } // anonymous namespace -namespace Gio { +namespace Gio +{ Glib::RefPtr File::create_for_path(const std::string& path) @@ -210,42 +205,33 @@ File::read_async(const SlotAsyncReady& slot, int io_priority) // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_read_async(gobj(), - io_priority, - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_file_read_async(gobj(), io_priority, nullptr, &SignalProxy_async_callback, slot_copy); } void -File::read_async(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, int io_priority) +File::read_async( + const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_read_async(gobj(), - io_priority, - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_file_read_async( + gobj(), io_priority, Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } void -File::append_to_async(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, FileCreateFlags flags, int io_priority) +File::append_to_async(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, + FileCreateFlags flags, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_append_to_async(gobj(), - static_cast(flags), - io_priority, - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_file_append_to_async(gobj(), static_cast(flags), io_priority, + Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } void @@ -256,28 +242,22 @@ File::append_to_async(const SlotAsyncReady& slot, FileCreateFlags flags, int io_ // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_append_to_async(gobj(), - static_cast(flags), - io_priority, - nullptr, // cancellable - &SignalProxy_async_callback, - slot_copy); + g_file_append_to_async(gobj(), static_cast(flags), io_priority, + nullptr, // cancellable + &SignalProxy_async_callback, slot_copy); } void -File::create_file_async(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, FileCreateFlags flags, int io_priority) +File::create_file_async(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, + FileCreateFlags flags, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_create_async(gobj(), - static_cast(flags), - io_priority, - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_file_create_async(gobj(), static_cast(flags), io_priority, + Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } void @@ -288,81 +268,65 @@ File::create_file_async(const SlotAsyncReady& slot, FileCreateFlags flags, int i // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_create_async(gobj(), - static_cast(flags), - io_priority, - nullptr, // cancellable - &SignalProxy_async_callback, - slot_copy); + g_file_create_async(gobj(), static_cast(flags), io_priority, + nullptr, // cancellable + &SignalProxy_async_callback, slot_copy); } void -File::create_file_readwrite_async(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, FileCreateFlags flags, int io_priority) +File::create_file_readwrite_async(const SlotAsyncReady& slot, + const Glib::RefPtr& cancellable, FileCreateFlags flags, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_create_async(gobj(), - static_cast(flags), - io_priority, - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_file_create_async(gobj(), static_cast(flags), io_priority, + Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } void -File::create_file_readwrite_async(const SlotAsyncReady& slot, FileCreateFlags flags, int io_priority) +File::create_file_readwrite_async( + const SlotAsyncReady& slot, FileCreateFlags flags, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_create_readwrite_async(gobj(), - static_cast(flags), - io_priority, - nullptr, // cancellable - &SignalProxy_async_callback, - slot_copy); + g_file_create_readwrite_async(gobj(), static_cast(flags), io_priority, + nullptr, // cancellable + &SignalProxy_async_callback, slot_copy); } - void -File::replace_async(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, const std::string& etag, bool make_backup, FileCreateFlags flags, int io_priority) +File::replace_async(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, + const std::string& etag, bool make_backup, FileCreateFlags flags, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_replace_async(gobj(), - Glib::c_str_or_nullptr(etag), - make_backup, - static_cast(flags), - io_priority, - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_file_replace_async(gobj(), Glib::c_str_or_nullptr(etag), make_backup, + static_cast(flags), io_priority, Glib::unwrap(cancellable), + &SignalProxy_async_callback, slot_copy); } void -File::replace_async(const SlotAsyncReady& slot, const std::string& etag, bool make_backup, FileCreateFlags flags, int io_priority) +File::replace_async(const SlotAsyncReady& slot, const std::string& etag, bool make_backup, + FileCreateFlags flags, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_replace_async(gobj(), - Glib::c_str_or_nullptr(etag), - make_backup, - static_cast(flags), - io_priority, - nullptr, // cancellable - &SignalProxy_async_callback, - slot_copy); + g_file_replace_async(gobj(), Glib::c_str_or_nullptr(etag), make_backup, + static_cast(flags), io_priority, + nullptr, // cancellable + &SignalProxy_async_callback, slot_copy); } void @@ -373,264 +337,251 @@ File::open_readwrite_async(const SlotAsyncReady& slot, int io_priority) // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_open_readwrite_async(gobj(), - io_priority, - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_file_open_readwrite_async(gobj(), io_priority, nullptr, &SignalProxy_async_callback, slot_copy); } void -File::open_readwrite_async(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, int io_priority) +File::open_readwrite_async( + const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_open_readwrite_async(gobj(), - io_priority, - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_file_open_readwrite_async( + gobj(), io_priority, Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } void -File::replace_readwrite_async(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, const std::string& etag, bool make_backup, FileCreateFlags flags, int io_priority) +File::replace_readwrite_async(const SlotAsyncReady& slot, + const Glib::RefPtr& cancellable, const std::string& etag, bool make_backup, + FileCreateFlags flags, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_replace_readwrite_async(gobj(), - Glib::c_str_or_nullptr(etag), - make_backup, - static_cast(flags), - io_priority, - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_file_replace_readwrite_async(gobj(), Glib::c_str_or_nullptr(etag), make_backup, + static_cast(flags), io_priority, Glib::unwrap(cancellable), + &SignalProxy_async_callback, slot_copy); } void -File::replace_readwrite_async(const SlotAsyncReady& slot, const std::string& etag, bool make_backup, FileCreateFlags flags, int io_priority) +File::replace_readwrite_async(const SlotAsyncReady& slot, const std::string& etag, bool make_backup, + FileCreateFlags flags, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_replace_readwrite_async(gobj(), - Glib::c_str_or_nullptr(etag), - make_backup, - static_cast(flags), - io_priority, - nullptr, // cancellable - &SignalProxy_async_callback, - slot_copy); + g_file_replace_readwrite_async(gobj(), Glib::c_str_or_nullptr(etag), make_backup, + static_cast(flags), io_priority, + nullptr, // cancellable + &SignalProxy_async_callback, slot_copy); } -FileType File::query_file_type(FileQueryInfoFlags flags) const +FileType +File::query_file_type(FileQueryInfoFlags flags) const { - return (FileType)g_file_query_file_type(const_cast(gobj()), (GFileQueryInfoFlags)flags, nullptr); + return (FileType)g_file_query_file_type( + const_cast(gobj()), (GFileQueryInfoFlags)flags, nullptr); } -Glib::RefPtr File::query_info(const Glib::RefPtr& cancellable, const std::string& attributes, FileQueryInfoFlags flags) const +Glib::RefPtr +File::query_info(const Glib::RefPtr& cancellable, const std::string& attributes, + FileQueryInfoFlags flags) const { GError* gerror = nullptr; - auto retvalue = Glib::wrap(g_file_query_info(const_cast(gobj()), attributes.c_str(), ((GFileQueryInfoFlags)(flags)), const_cast(Glib::unwrap(cancellable)), &(gerror))); - if(gerror) + auto retvalue = Glib::wrap(g_file_query_info(const_cast(gobj()), attributes.c_str(), + ((GFileQueryInfoFlags)(flags)), const_cast(Glib::unwrap(cancellable)), + &(gerror))); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } -Glib::RefPtr File::query_info(const std::string& attributes, FileQueryInfoFlags flags) const +Glib::RefPtr +File::query_info(const std::string& attributes, FileQueryInfoFlags flags) const { GError* gerror = nullptr; - auto retvalue = Glib::wrap(g_file_query_info(const_cast(gobj()), attributes.c_str(), ((GFileQueryInfoFlags)(flags)), nullptr, &(gerror))); - if(gerror) + auto retvalue = Glib::wrap(g_file_query_info(const_cast(gobj()), attributes.c_str(), + ((GFileQueryInfoFlags)(flags)), nullptr, &(gerror))); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } void -File::query_info_async(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, const std::string& attributes, FileQueryInfoFlags flags, int io_priority) const +File::query_info_async(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, + const std::string& attributes, FileQueryInfoFlags flags, int io_priority) const { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_query_info_async(const_cast(gobj()), - attributes.c_str(), - static_cast(flags), - io_priority, - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_file_query_info_async(const_cast(gobj()), attributes.c_str(), + static_cast(flags), io_priority, Glib::unwrap(cancellable), + &SignalProxy_async_callback, slot_copy); } void -File::query_info_async(const SlotAsyncReady& slot, const std::string& attributes, FileQueryInfoFlags flags, int io_priority) const +File::query_info_async(const SlotAsyncReady& slot, const std::string& attributes, + FileQueryInfoFlags flags, int io_priority) const { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_query_info_async(const_cast(gobj()), - attributes.c_str(), - static_cast(flags), - io_priority, - nullptr, // cancellable - &SignalProxy_async_callback, - slot_copy); + g_file_query_info_async(const_cast(gobj()), attributes.c_str(), + static_cast(flags), io_priority, + nullptr, // cancellable + &SignalProxy_async_callback, slot_copy); } - -Glib::RefPtr File::query_filesystem_info(const Glib::RefPtr& cancellable, const std::string& attributes) +Glib::RefPtr +File::query_filesystem_info( + const Glib::RefPtr& cancellable, const std::string& attributes) { GError* gerror = nullptr; - auto retvalue = Glib::wrap(g_file_query_filesystem_info(gobj(), attributes.c_str(), const_cast(Glib::unwrap(cancellable)), &(gerror))); - if(gerror) + auto retvalue = Glib::wrap(g_file_query_filesystem_info( + gobj(), attributes.c_str(), const_cast(Glib::unwrap(cancellable)), &(gerror))); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } -Glib::RefPtr File::query_filesystem_info(const std::string& attributes) +Glib::RefPtr +File::query_filesystem_info(const std::string& attributes) { GError* gerror = nullptr; - auto retvalue = Glib::wrap(g_file_query_filesystem_info(gobj(), attributes.c_str(), nullptr, &(gerror))); - if(gerror) + auto retvalue = + Glib::wrap(g_file_query_filesystem_info(gobj(), attributes.c_str(), nullptr, &(gerror))); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } void -File::query_filesystem_info_async(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, const std::string& attributes, int io_priority) const +File::query_filesystem_info_async(const SlotAsyncReady& slot, + const Glib::RefPtr& cancellable, const std::string& attributes, + int io_priority) const { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_query_filesystem_info_async(const_cast(gobj()), - attributes.c_str(), - io_priority, - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_file_query_filesystem_info_async(const_cast(gobj()), attributes.c_str(), io_priority, + Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } void -File::query_filesystem_info_async(const SlotAsyncReady& slot, const std::string& attributes, int io_priority) const +File::query_filesystem_info_async( + const SlotAsyncReady& slot, const std::string& attributes, int io_priority) const { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_query_filesystem_info_async(const_cast(gobj()), - attributes.c_str(), - io_priority, - nullptr, // cancellable - &SignalProxy_async_callback, - slot_copy); + g_file_query_filesystem_info_async(const_cast(gobj()), attributes.c_str(), io_priority, + nullptr, // cancellable + &SignalProxy_async_callback, slot_copy); } -Glib::RefPtr File::enumerate_children(const Glib::RefPtr& cancellable, const std::string& attributes, FileQueryInfoFlags flags) +Glib::RefPtr +File::enumerate_children(const Glib::RefPtr& cancellable, + const std::string& attributes, FileQueryInfoFlags flags) { GError* gerror = nullptr; - auto retvalue = Glib::wrap(g_file_enumerate_children(gobj(), attributes.c_str(), ((GFileQueryInfoFlags)(flags)), const_cast(Glib::unwrap(cancellable)), &(gerror))); - if(gerror) + auto retvalue = + Glib::wrap(g_file_enumerate_children(gobj(), attributes.c_str(), ((GFileQueryInfoFlags)(flags)), + const_cast(Glib::unwrap(cancellable)), &(gerror))); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } -Glib::RefPtr File::enumerate_children(const std::string& attributes, FileQueryInfoFlags flags) +Glib::RefPtr +File::enumerate_children(const std::string& attributes, FileQueryInfoFlags flags) { GError* gerror = nullptr; - auto retvalue = Glib::wrap(g_file_enumerate_children(gobj(), attributes.c_str(), ((GFileQueryInfoFlags)(flags)), nullptr, &(gerror))); - if(gerror) + auto retvalue = Glib::wrap(g_file_enumerate_children( + gobj(), attributes.c_str(), ((GFileQueryInfoFlags)(flags)), nullptr, &(gerror))); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } void -File::enumerate_children_async(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, const std::string& attributes, FileQueryInfoFlags flags, int io_priority) +File::enumerate_children_async(const SlotAsyncReady& slot, + const Glib::RefPtr& cancellable, const std::string& attributes, + FileQueryInfoFlags flags, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_enumerate_children_async(gobj(), - attributes.c_str(), - static_cast(flags), - io_priority, - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_file_enumerate_children_async(gobj(), attributes.c_str(), + static_cast(flags), io_priority, Glib::unwrap(cancellable), + &SignalProxy_async_callback, slot_copy); } void -File::enumerate_children_async(const SlotAsyncReady& slot, const std::string& attributes, FileQueryInfoFlags flags, int io_priority) +File::enumerate_children_async(const SlotAsyncReady& slot, const std::string& attributes, + FileQueryInfoFlags flags, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_enumerate_children_async(gobj(), - attributes.c_str(), - static_cast(flags), - io_priority, - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_file_enumerate_children_async(gobj(), attributes.c_str(), + static_cast(flags), io_priority, nullptr, &SignalProxy_async_callback, + slot_copy); } void -File::set_display_name_async(const Glib::ustring& display_name, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, int io_priority) +File::set_display_name_async(const Glib::ustring& display_name, const SlotAsyncReady& slot, + const Glib::RefPtr& cancellable, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_set_display_name_async(gobj(), - display_name.c_str(), - io_priority, - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_file_set_display_name_async(gobj(), display_name.c_str(), io_priority, + Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } void -File::set_display_name_async(const Glib::ustring& display_name, const SlotAsyncReady& slot, int io_priority) +File::set_display_name_async( + const Glib::ustring& display_name, const SlotAsyncReady& slot, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_set_display_name_async(gobj(), - display_name.c_str(), - io_priority, - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_file_set_display_name_async( + gobj(), display_name.c_str(), io_priority, nullptr, &SignalProxy_async_callback, slot_copy); } bool -File::copy(const Glib::RefPtr& destination, const SlotFileProgress& slot, const Glib::RefPtr& cancellable, FileCopyFlags flags) +File::copy(const Glib::RefPtr& destination, const SlotFileProgress& slot, + const Glib::RefPtr& cancellable, FileCopyFlags flags) { GError* gerror = nullptr; bool res; @@ -640,13 +591,8 @@ File::copy(const Glib::RefPtr& destination, const SlotFileProgress& slot, // and deleted in the callback. SlotFileProgress* slot_copy = new SlotFileProgress(slot); - res = g_file_copy(gobj(), - Glib::unwrap(destination), - static_cast(flags), - Glib::unwrap(cancellable), - &SignalProxy_file_progress_callback, - slot_copy, - &gerror); + res = g_file_copy(gobj(), Glib::unwrap(destination), static_cast(flags), + Glib::unwrap(cancellable), &SignalProxy_file_progress_callback, slot_copy, &gerror); delete slot_copy; @@ -667,13 +613,8 @@ File::copy(const Glib::RefPtr& destination, const SlotFileProgress& slot, // and deleted in the callback. SlotFileProgress* slot_copy = new SlotFileProgress(slot); - res = g_file_copy(gobj(), - Glib::unwrap(destination), - static_cast(flags), - nullptr, - &SignalProxy_file_progress_callback, - slot_copy, - &gerror); + res = g_file_copy(gobj(), Glib::unwrap(destination), static_cast(flags), nullptr, + &SignalProxy_file_progress_callback, slot_copy, &gerror); delete slot_copy; @@ -687,13 +628,8 @@ bool File::copy(const Glib::RefPtr& destination, FileCopyFlags flags) { GError* gerror = nullptr; - bool res = g_file_copy(gobj(), - Glib::unwrap(destination), - static_cast(flags), - nullptr, - nullptr, - nullptr, - &gerror); + bool res = g_file_copy(gobj(), Glib::unwrap(destination), static_cast(flags), + nullptr, nullptr, nullptr, &gerror); if (gerror) ::Glib::Error::throw_exception(gerror); @@ -702,12 +638,9 @@ File::copy(const Glib::RefPtr& destination, FileCopyFlags flags) } void -File::copy_async(const Glib::RefPtr& destination, - const SlotFileProgress& slot_progress, - const SlotAsyncReady& slot_ready, - const Glib::RefPtr& cancellable, - FileCopyFlags flags, - int io_priority) +File::copy_async(const Glib::RefPtr& destination, const SlotFileProgress& slot_progress, + const SlotAsyncReady& slot_ready, const Glib::RefPtr& cancellable, + FileCopyFlags flags, int io_priority) { // Create a new pair which will hold copies of passed slots. // This will be deleted in the SignalProxy_file_copy_async_callback() callback @@ -718,46 +651,28 @@ File::copy_async(const Glib::RefPtr& destination, slots->first = slot_progress_copy; slots->second = slot_ready_copy; - g_file_copy_async(gobj(), - Glib::unwrap(destination), - static_cast(flags), - io_priority, - Glib::unwrap(cancellable), - &SignalProxy_file_progress_callback, - slot_progress_copy, - &SignalProxy_file_copy_async_callback, - slots); + g_file_copy_async(gobj(), Glib::unwrap(destination), static_cast(flags), + io_priority, Glib::unwrap(cancellable), &SignalProxy_file_progress_callback, slot_progress_copy, + &SignalProxy_file_copy_async_callback, slots); } void -File::copy_async(const Glib::RefPtr& destination, - const SlotAsyncReady& slot_ready, - const Glib::RefPtr& cancellable, - FileCopyFlags flags, - int io_priority) +File::copy_async(const Glib::RefPtr& destination, const SlotAsyncReady& slot_ready, + const Glib::RefPtr& cancellable, FileCopyFlags flags, int io_priority) { // Create copies of slots. // Pointers to them will be passed through the callbacks' data parameter // and deleted in the corresponding callback. SlotAsyncReady* slot_ready_copy = new SlotAsyncReady(slot_ready); - g_file_copy_async(gobj(), - Glib::unwrap(destination), - static_cast(flags), - io_priority, - Glib::unwrap(cancellable), - nullptr, - nullptr, - &SignalProxy_async_callback, - slot_ready_copy); + g_file_copy_async(gobj(), Glib::unwrap(destination), static_cast(flags), + io_priority, Glib::unwrap(cancellable), nullptr, nullptr, &SignalProxy_async_callback, + slot_ready_copy); } void -File::copy_async(const Glib::RefPtr& destination, - const SlotFileProgress& slot_progress, - const SlotAsyncReady& slot_ready, - FileCopyFlags flags, - int io_priority) +File::copy_async(const Glib::RefPtr& destination, const SlotFileProgress& slot_progress, + const SlotAsyncReady& slot_ready, FileCopyFlags flags, int io_priority) { // Create a new pair which will hold copies of passed slots. // This will be deleted in the SignalProxy_file_copy_async_callback() callback @@ -768,41 +683,27 @@ File::copy_async(const Glib::RefPtr& destination, slots->first = slot_progress_copy; slots->second = slot_ready_copy; - g_file_copy_async(gobj(), - Glib::unwrap(destination), - static_cast(flags), - io_priority, - nullptr, - &SignalProxy_file_progress_callback, - slot_progress_copy, - &SignalProxy_file_copy_async_callback, - slots); + g_file_copy_async(gobj(), Glib::unwrap(destination), static_cast(flags), + io_priority, nullptr, &SignalProxy_file_progress_callback, slot_progress_copy, + &SignalProxy_file_copy_async_callback, slots); } void -File::copy_async(const Glib::RefPtr& destination, - const SlotAsyncReady& slot_ready, - FileCopyFlags flags, - int io_priority) +File::copy_async(const Glib::RefPtr& destination, const SlotAsyncReady& slot_ready, + FileCopyFlags flags, int io_priority) { // Create copies of slots. // Pointers to them will be passed through the callbacks' data parameter // and deleted in the corresponding callback. SlotAsyncReady* slot_ready_copy = new SlotAsyncReady(slot_ready); - g_file_copy_async(gobj(), - Glib::unwrap(destination), - static_cast(flags), - io_priority, - nullptr, - nullptr, - nullptr, - &SignalProxy_async_callback, - slot_ready_copy); + g_file_copy_async(gobj(), Glib::unwrap(destination), static_cast(flags), + io_priority, nullptr, nullptr, nullptr, &SignalProxy_async_callback, slot_ready_copy); } bool -File::move(const Glib::RefPtr& destination, const SlotFileProgress& slot, const Glib::RefPtr& cancellable, FileCopyFlags flags) +File::move(const Glib::RefPtr& destination, const SlotFileProgress& slot, + const Glib::RefPtr& cancellable, FileCopyFlags flags) { GError* gerror = nullptr; bool res; @@ -812,13 +713,8 @@ File::move(const Glib::RefPtr& destination, const SlotFileProgress& slot, // and deleted in the callback. SlotFileProgress* slot_copy = new SlotFileProgress(slot); - res = g_file_move(gobj(), - Glib::unwrap(destination), - static_cast(flags), - Glib::unwrap(cancellable), - &SignalProxy_file_progress_callback, - slot_copy, - &gerror); + res = g_file_move(gobj(), Glib::unwrap(destination), static_cast(flags), + Glib::unwrap(cancellable), &SignalProxy_file_progress_callback, slot_copy, &gerror); delete slot_copy; @@ -839,13 +735,8 @@ File::move(const Glib::RefPtr& destination, const SlotFileProgress& slot, // and deleted in the callback. SlotFileProgress* slot_copy = new SlotFileProgress(slot); - res = g_file_move(gobj(), - Glib::unwrap(destination), - static_cast(flags), - nullptr, - &SignalProxy_file_progress_callback, - slot_copy, - &gerror); + res = g_file_move(gobj(), Glib::unwrap(destination), static_cast(flags), nullptr, + &SignalProxy_file_progress_callback, slot_copy, &gerror); delete slot_copy; @@ -861,13 +752,8 @@ File::move(const Glib::RefPtr& destination, FileCopyFlags flags) GError* gerror = nullptr; bool res; - res = g_file_move(gobj(), - Glib::unwrap(destination), - static_cast(flags), - nullptr, - nullptr, - nullptr, - &gerror); + res = g_file_move(gobj(), Glib::unwrap(destination), static_cast(flags), nullptr, + nullptr, nullptr, &gerror); if (gerror) ::Glib::Error::throw_exception(gerror); @@ -876,51 +762,40 @@ File::move(const Glib::RefPtr& destination, FileCopyFlags flags) } void -File::set_attributes_async(const Glib::RefPtr& info, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, FileQueryInfoFlags flags, int io_priority) +File::set_attributes_async(const Glib::RefPtr& info, const SlotAsyncReady& slot, + const Glib::RefPtr& cancellable, FileQueryInfoFlags flags, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_set_attributes_async(gobj(), - Glib::unwrap(info), - static_cast(flags), - io_priority, - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_file_set_attributes_async(gobj(), Glib::unwrap(info), static_cast(flags), + io_priority, Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } void -File::set_attributes_async(const Glib::RefPtr& info, const SlotAsyncReady& slot, FileQueryInfoFlags flags, int io_priority) +File::set_attributes_async(const Glib::RefPtr& info, const SlotAsyncReady& slot, + FileQueryInfoFlags flags, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_set_attributes_async(gobj(), - Glib::unwrap(info), - static_cast(flags), - io_priority, - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_file_set_attributes_async(gobj(), Glib::unwrap(info), static_cast(flags), + io_priority, nullptr, &SignalProxy_async_callback, slot_copy); } bool -File::set_attributes_finish(const Glib::RefPtr& result, - const Glib::RefPtr& info) +File::set_attributes_finish( + const Glib::RefPtr& result, const Glib::RefPtr& info) { GError* gerror = nullptr; GFileInfo* cinfo = Glib::unwrap(info); bool res; - res = g_file_set_attributes_finish(gobj(), - Glib::unwrap(result), - &cinfo, - &gerror); + res = g_file_set_attributes_finish(gobj(), Glib::unwrap(result), &cinfo, &gerror); if (gerror) ::Glib::Error::throw_exception(gerror); @@ -928,75 +803,63 @@ File::set_attributes_finish(const Glib::RefPtr& result, return res; } - -void File::mount_mountable(const Glib::RefPtr& mount_operation, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, MountMountFlags flags) +void +File::mount_mountable(const Glib::RefPtr& mount_operation, + const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, MountMountFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_mount_mountable(gobj(), - static_cast(flags), - Glib::unwrap(mount_operation), - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_file_mount_mountable(gobj(), static_cast(flags), + Glib::unwrap(mount_operation), Glib::unwrap(cancellable), &SignalProxy_async_callback, + slot_copy); } -void File::mount_mountable(const Glib::RefPtr& mount_operation, const SlotAsyncReady& slot, MountMountFlags flags) +void +File::mount_mountable(const Glib::RefPtr& mount_operation, + const SlotAsyncReady& slot, MountMountFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_mount_mountable(gobj(), - static_cast(flags), - Glib::unwrap(mount_operation), - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_file_mount_mountable(gobj(), static_cast(flags), + Glib::unwrap(mount_operation), nullptr, &SignalProxy_async_callback, slot_copy); } -void File::mount_mountable(const SlotAsyncReady& slot, MountMountFlags flags) +void +File::mount_mountable(const SlotAsyncReady& slot, MountMountFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_mount_mountable(gobj(), - static_cast(flags), - nullptr, - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_file_mount_mountable(gobj(), static_cast(flags), nullptr, nullptr, + &SignalProxy_async_callback, slot_copy); } -void File::mount_mountable(MountMountFlags flags) +void +File::mount_mountable(MountMountFlags flags) { - g_file_mount_mountable(gobj(), - static_cast(flags), - nullptr, - nullptr, - nullptr, - nullptr); + g_file_mount_mountable( + gobj(), static_cast(flags), nullptr, nullptr, nullptr, nullptr); } -void File::unmount_mountable(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, MountUnmountFlags flags) +void +File::unmount_mountable( + const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, MountUnmountFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_unmount_mountable_with_operation(gobj(), - static_cast(flags), - nullptr, - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_file_unmount_mountable_with_operation(gobj(), static_cast(flags), nullptr, + Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } void @@ -1007,181 +870,143 @@ File::unmount_mountable(const SlotAsyncReady& slot, MountUnmountFlags flags) // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_unmount_mountable_with_operation(gobj(), - static_cast(flags), - nullptr, - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_file_unmount_mountable_with_operation(gobj(), static_cast(flags), nullptr, + nullptr, &SignalProxy_async_callback, slot_copy); } void File::unmount_mountable(MountUnmountFlags flags) { - g_file_unmount_mountable_with_operation(gobj(), - static_cast(flags), - nullptr, - nullptr, - nullptr, - nullptr); + g_file_unmount_mountable_with_operation( + gobj(), static_cast(flags), nullptr, nullptr, nullptr, nullptr); } -void File::unmount_mountable(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, const Glib::RefPtr& mount_operation, MountUnmountFlags flags) +void +File::unmount_mountable(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, + const Glib::RefPtr& mount_operation, MountUnmountFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_unmount_mountable_with_operation(gobj(), - static_cast(flags), - Glib::unwrap(mount_operation), - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_file_unmount_mountable_with_operation(gobj(), static_cast(flags), + Glib::unwrap(mount_operation), Glib::unwrap(cancellable), &SignalProxy_async_callback, + slot_copy); } void -File::unmount_mountable(const SlotAsyncReady& slot, const Glib::RefPtr& mount_operation, MountUnmountFlags flags) +File::unmount_mountable(const SlotAsyncReady& slot, + const Glib::RefPtr& mount_operation, MountUnmountFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_unmount_mountable_with_operation(gobj(), - static_cast(flags), - Glib::unwrap(mount_operation), - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_file_unmount_mountable_with_operation(gobj(), static_cast(flags), + Glib::unwrap(mount_operation), nullptr, &SignalProxy_async_callback, slot_copy); } void -File::unmount_mountable(const Glib::RefPtr& mount_operation, MountUnmountFlags flags) +File::unmount_mountable( + const Glib::RefPtr& mount_operation, MountUnmountFlags flags) { - g_file_unmount_mountable_with_operation(gobj(), - static_cast(flags), - Glib::unwrap(mount_operation), - nullptr, - nullptr, - nullptr); + g_file_unmount_mountable_with_operation(gobj(), static_cast(flags), + Glib::unwrap(mount_operation), nullptr, nullptr, nullptr); } - - -void File::mount_enclosing_volume(const Glib::RefPtr& mount_operation, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, MountMountFlags flags) +void +File::mount_enclosing_volume(const Glib::RefPtr& mount_operation, + const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, MountMountFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_mount_enclosing_volume(gobj(), - static_cast(flags), - Glib::unwrap(mount_operation), - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_file_mount_enclosing_volume(gobj(), static_cast(flags), + Glib::unwrap(mount_operation), Glib::unwrap(cancellable), &SignalProxy_async_callback, + slot_copy); } -void File::mount_enclosing_volume(const Glib::RefPtr& mount_operation, const SlotAsyncReady& slot, MountMountFlags flags) +void +File::mount_enclosing_volume(const Glib::RefPtr& mount_operation, + const SlotAsyncReady& slot, MountMountFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_mount_enclosing_volume(gobj(), - static_cast(flags), - Glib::unwrap(mount_operation), - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_file_mount_enclosing_volume(gobj(), static_cast(flags), + Glib::unwrap(mount_operation), nullptr, &SignalProxy_async_callback, slot_copy); } -void File::mount_enclosing_volume(const SlotAsyncReady& slot, MountMountFlags flags) +void +File::mount_enclosing_volume(const SlotAsyncReady& slot, MountMountFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_mount_enclosing_volume(gobj(), - static_cast(flags), - nullptr, - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_file_mount_enclosing_volume(gobj(), static_cast(flags), nullptr, nullptr, + &SignalProxy_async_callback, slot_copy); } -void File::mount_enclosing_volume(MountMountFlags flags) +void +File::mount_enclosing_volume(MountMountFlags flags) { - g_file_mount_enclosing_volume(gobj(), - static_cast(flags), - nullptr, - nullptr, - nullptr, - nullptr); + g_file_mount_enclosing_volume( + gobj(), static_cast(flags), nullptr, nullptr, nullptr, nullptr); } void -File::eject_mountable(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, const Glib::RefPtr& mount_operation, MountUnmountFlags flags) +File::eject_mountable(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, + const Glib::RefPtr& mount_operation, MountUnmountFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_eject_mountable_with_operation(gobj(), - static_cast(flags), - Glib::unwrap(mount_operation), - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_file_eject_mountable_with_operation(gobj(), static_cast(flags), + Glib::unwrap(mount_operation), Glib::unwrap(cancellable), &SignalProxy_async_callback, + slot_copy); } void -File::eject_mountable(const SlotAsyncReady& slot, const Glib::RefPtr& mount_operation, MountUnmountFlags flags) +File::eject_mountable(const SlotAsyncReady& slot, + const Glib::RefPtr& mount_operation, MountUnmountFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_eject_mountable_with_operation(gobj(), - static_cast(flags), - Glib::unwrap(mount_operation), - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_file_eject_mountable_with_operation(gobj(), static_cast(flags), + Glib::unwrap(mount_operation), nullptr, &SignalProxy_async_callback, slot_copy); } void File::eject_mountable(const Glib::RefPtr& mount_operation, MountUnmountFlags flags) { - g_file_eject_mountable_with_operation(gobj(), - static_cast(flags), - Glib::unwrap(mount_operation), - nullptr, - nullptr, - nullptr); + g_file_eject_mountable_with_operation(gobj(), static_cast(flags), + Glib::unwrap(mount_operation), nullptr, nullptr, nullptr); } void -File::eject_mountable(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, MountUnmountFlags flags) +File::eject_mountable( + const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, MountUnmountFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_eject_mountable_with_operation(gobj(), - static_cast(flags), - nullptr, - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_file_eject_mountable_with_operation(gobj(), static_cast(flags), nullptr, + Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } void @@ -1192,23 +1017,15 @@ File::eject_mountable(const SlotAsyncReady& slot, MountUnmountFlags flags) // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_eject_mountable_with_operation(gobj(), - static_cast(flags), - nullptr, - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_file_eject_mountable_with_operation(gobj(), static_cast(flags), nullptr, + nullptr, &SignalProxy_async_callback, slot_copy); } void File::eject_mountable(MountUnmountFlags flags) { - g_file_eject_mountable_with_operation(gobj(), - static_cast(flags), - nullptr, - nullptr, - nullptr, - nullptr); + g_file_eject_mountable_with_operation( + gobj(), static_cast(flags), nullptr, nullptr, nullptr, nullptr); } void @@ -1219,10 +1036,8 @@ File::load_contents_async(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable) +File::load_partial_contents_async(const SlotReadMore& slot_read_more, + const SlotAsyncReady& slot_async_ready, const Glib::RefPtr& cancellable) { // Create a new pair which will hold copies of passed slots. // This will be deleted in the SignalProxy_load_partial_contents_ready_callback() callback @@ -1251,16 +1064,14 @@ File::load_partial_contents_async(const SlotReadMore& slot_read_more, const Slot slots->first = slot_read_more_copy; slots->second = slot_async_copy; - g_file_load_partial_contents_async(gobj(), - Glib::unwrap(cancellable), - &SignalProxy_load_partial_contents_read_more_callback, - &SignalProxy_load_partial_contents_ready_callback, - slots); + g_file_load_partial_contents_async(gobj(), Glib::unwrap(cancellable), + &SignalProxy_load_partial_contents_read_more_callback, + &SignalProxy_load_partial_contents_ready_callback, slots); } void -File::load_partial_contents_async(const SlotReadMore& slot_read_more, - const SlotAsyncReady& slot_async_ready) +File::load_partial_contents_async( + const SlotReadMore& slot_read_more, const SlotAsyncReady& slot_async_ready) { // Create a new pair which will hold copies of passed slots. // This will be deleted in the SignalProxy_load_partial_contents_ready_callback() callback @@ -1271,64 +1082,77 @@ File::load_partial_contents_async(const SlotReadMore& slot_read_more, slots->first = slot_read_more_copy; slots->second = slot_async_copy; - g_file_load_partial_contents_async(gobj(), - nullptr, - &SignalProxy_load_partial_contents_read_more_callback, - &SignalProxy_load_partial_contents_ready_callback, - slots); + g_file_load_partial_contents_async(gobj(), nullptr, + &SignalProxy_load_partial_contents_read_more_callback, + &SignalProxy_load_partial_contents_ready_callback, slots); } -void File::replace_contents(const char* contents, gsize length, const std::string& etag, std::string& new_etag, const Glib::RefPtr& cancellable, bool make_backup, FileCreateFlags flags) +void +File::replace_contents(const char* contents, gsize length, const std::string& etag, + std::string& new_etag, const Glib::RefPtr& cancellable, bool make_backup, + FileCreateFlags flags) { GError* gerror = nullptr; gchar* c_etag_new = nullptr; - g_file_replace_contents(gobj(), contents, length, Glib::c_str_or_nullptr(etag), static_cast(make_backup), ((GFileCreateFlags)(flags)), &c_etag_new, const_cast(Glib::unwrap(cancellable)), &(gerror)); - if(gerror) + g_file_replace_contents(gobj(), contents, length, Glib::c_str_or_nullptr(etag), + static_cast(make_backup), ((GFileCreateFlags)(flags)), &c_etag_new, + const_cast(Glib::unwrap(cancellable)), &(gerror)); + if (gerror) ::Glib::Error::throw_exception(gerror); - if(c_etag_new) + if (c_etag_new) new_etag = c_etag_new; else new_etag = std::string(); } -void File::replace_contents(const char* contents, gsize length, const std::string& etag, std::string& new_etag, bool make_backup, FileCreateFlags flags) +void +File::replace_contents(const char* contents, gsize length, const std::string& etag, + std::string& new_etag, bool make_backup, FileCreateFlags flags) { GError* gerror = nullptr; gchar* c_etag_new = nullptr; - g_file_replace_contents(gobj(), contents, length, Glib::c_str_or_nullptr(etag), static_cast(make_backup), ((GFileCreateFlags)(flags)), &c_etag_new, nullptr, &(gerror)); - if(gerror) + g_file_replace_contents(gobj(), contents, length, Glib::c_str_or_nullptr(etag), + static_cast(make_backup), ((GFileCreateFlags)(flags)), &c_etag_new, nullptr, &(gerror)); + if (gerror) ::Glib::Error::throw_exception(gerror); - if(c_etag_new) + if (c_etag_new) new_etag = c_etag_new; else new_etag = std::string(); } -void File::replace_contents(const std::string& contents, const std::string& etag, std::string& new_etag, const Glib::RefPtr& cancellable, bool make_backup, FileCreateFlags flags) +void +File::replace_contents(const std::string& contents, const std::string& etag, std::string& new_etag, + const Glib::RefPtr& cancellable, bool make_backup, FileCreateFlags flags) { GError* gerror = nullptr; gchar* c_etag_new = nullptr; - g_file_replace_contents(gobj(), contents.c_str(), contents.size(), Glib::c_str_or_nullptr(etag), static_cast(make_backup), ((GFileCreateFlags)(flags)), &c_etag_new, const_cast(Glib::unwrap(cancellable)), &(gerror)); - if(gerror) + g_file_replace_contents(gobj(), contents.c_str(), contents.size(), Glib::c_str_or_nullptr(etag), + static_cast(make_backup), ((GFileCreateFlags)(flags)), &c_etag_new, + const_cast(Glib::unwrap(cancellable)), &(gerror)); + if (gerror) ::Glib::Error::throw_exception(gerror); - if(c_etag_new) + if (c_etag_new) new_etag = c_etag_new; else new_etag = std::string(); } -void File::replace_contents(const std::string& contents, const std::string& etag, std::string& new_etag, bool make_backup, FileCreateFlags flags) +void +File::replace_contents(const std::string& contents, const std::string& etag, std::string& new_etag, + bool make_backup, FileCreateFlags flags) { GError* gerror = nullptr; gchar* c_etag_new = nullptr; - g_file_replace_contents(gobj(), contents.c_str(), contents.size(), Glib::c_str_or_nullptr(etag), static_cast(make_backup), ((GFileCreateFlags)(flags)), &c_etag_new, nullptr, &(gerror)); - if(gerror) + g_file_replace_contents(gobj(), contents.c_str(), contents.size(), Glib::c_str_or_nullptr(etag), + static_cast(make_backup), ((GFileCreateFlags)(flags)), &c_etag_new, nullptr, &(gerror)); + if (gerror) ::Glib::Error::throw_exception(gerror); - if(c_etag_new) + if (c_etag_new) new_etag = c_etag_new; else new_etag = std::string(); @@ -1336,287 +1160,258 @@ void File::replace_contents(const std::string& contents, const std::string& etag void File::replace_contents_async(const SlotAsyncReady& slot, - const Glib::RefPtr& cancellable, - const char* contents, - gsize length, - const std::string& etag, - bool make_backup, - FileCreateFlags flags) + const Glib::RefPtr& cancellable, const char* contents, gsize length, + const std::string& etag, bool make_backup, FileCreateFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_replace_contents_async(gobj(), - contents, - length, - Glib::c_str_or_nullptr(etag), - make_backup, - static_cast(flags), - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_file_replace_contents_async(gobj(), contents, length, Glib::c_str_or_nullptr(etag), make_backup, + static_cast(flags), Glib::unwrap(cancellable), &SignalProxy_async_callback, + slot_copy); } void -File::replace_contents_async(const SlotAsyncReady& slot, - const char* contents, - gsize length, - const std::string& etag, - bool make_backup, - FileCreateFlags flags) +File::replace_contents_async(const SlotAsyncReady& slot, const char* contents, gsize length, + const std::string& etag, bool make_backup, FileCreateFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_replace_contents_async(gobj(), - contents, - length, - Glib::c_str_or_nullptr(etag), - make_backup, - static_cast(flags), - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_file_replace_contents_async(gobj(), contents, length, Glib::c_str_or_nullptr(etag), make_backup, + static_cast(flags), nullptr, &SignalProxy_async_callback, slot_copy); } void File::replace_contents_async(const SlotAsyncReady& slot, - const Glib::RefPtr& cancellable, - const std::string& contents, - const std::string& etag, - bool make_backup, - FileCreateFlags flags) + const Glib::RefPtr& cancellable, const std::string& contents, + const std::string& etag, bool make_backup, FileCreateFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_replace_contents_async(gobj(), - contents.c_str(), - contents.size(), - Glib::c_str_or_nullptr(etag), - make_backup, - static_cast(flags), - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_file_replace_contents_async(gobj(), contents.c_str(), contents.size(), + Glib::c_str_or_nullptr(etag), make_backup, static_cast(flags), + Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } void -File::replace_contents_async(const SlotAsyncReady& slot, - const std::string& contents, - const std::string& etag, - bool make_backup, - FileCreateFlags flags) +File::replace_contents_async(const SlotAsyncReady& slot, const std::string& contents, + const std::string& etag, bool make_backup, FileCreateFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_replace_contents_async(gobj(), - contents.c_str(), - contents.size(), - Glib::c_str_or_nullptr(etag), - make_backup, - static_cast(flags), - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_file_replace_contents_async(gobj(), contents.c_str(), contents.size(), + Glib::c_str_or_nullptr(etag), make_backup, static_cast(flags), nullptr, + &SignalProxy_async_callback, slot_copy); } -void File::replace_contents_finish(const Glib::RefPtr& result, std::string& new_etag) +void +File::replace_contents_finish(const Glib::RefPtr& result, std::string& new_etag) { GError* gerror = nullptr; gchar* c_new_etag = nullptr; g_file_replace_contents_finish(gobj(), Glib::unwrap(result), &c_new_etag, &(gerror)); - if(gerror) + if (gerror) ::Glib::Error::throw_exception(gerror); - if(c_new_etag) + if (c_new_etag) new_etag = c_new_etag; else - new_etag = std::string(); + new_etag = std::string(); } - -void File::replace_contents_finish(const Glib::RefPtr& result) +void +File::replace_contents_finish(const Glib::RefPtr& result) { GError* gerror = nullptr; g_file_replace_contents_finish(gobj(), Glib::unwrap(result), nullptr, &(gerror)); - if(gerror) + if (gerror) ::Glib::Error::throw_exception(gerror); } - void File::replace_contents_bytes_async(const SlotAsyncReady& slot, - const Glib::RefPtr& cancellable, - const Glib::RefPtr& contents, - const std::string& etag, - bool make_backup, - FileCreateFlags flags) + const Glib::RefPtr& cancellable, const Glib::RefPtr& contents, + const std::string& etag, bool make_backup, FileCreateFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_replace_contents_bytes_async(gobj(), - const_cast(Glib::unwrap(contents)), - Glib::c_str_or_nullptr(etag), - make_backup, - static_cast(flags), - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_file_replace_contents_bytes_async(gobj(), const_cast(Glib::unwrap(contents)), + Glib::c_str_or_nullptr(etag), make_backup, static_cast(flags), + Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } void File::replace_contents_bytes_async(const SlotAsyncReady& slot, - const Glib::RefPtr& contents, - const std::string& etag, - bool make_backup, - FileCreateFlags flags) + const Glib::RefPtr& contents, const std::string& etag, bool make_backup, + FileCreateFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_replace_contents_bytes_async(gobj(), - const_cast(Glib::unwrap(contents)), - Glib::c_str_or_nullptr(etag), - make_backup, - static_cast(flags), - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_file_replace_contents_bytes_async(gobj(), const_cast(Glib::unwrap(contents)), + Glib::c_str_or_nullptr(etag), make_backup, static_cast(flags), nullptr, + &SignalProxy_async_callback, slot_copy); } - -Glib::RefPtr File::replace(const Glib::RefPtr& cancellable, const std::string& etag, bool make_backup, FileCreateFlags flags) +Glib::RefPtr +File::replace(const Glib::RefPtr& cancellable, const std::string& etag, + bool make_backup, FileCreateFlags flags) { GError* gerror = nullptr; - auto retvalue = Glib::wrap(g_file_replace(gobj(), Glib::c_str_or_nullptr(etag), static_cast(make_backup), ((GFileCreateFlags)(flags)), const_cast(Glib::unwrap(cancellable)), &(gerror))); - if(gerror) + auto retvalue = Glib::wrap(g_file_replace(gobj(), Glib::c_str_or_nullptr(etag), + static_cast(make_backup), ((GFileCreateFlags)(flags)), + const_cast(Glib::unwrap(cancellable)), &(gerror))); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } -Glib::RefPtr File::replace(const std::string& etag, bool make_backup, FileCreateFlags flags) +Glib::RefPtr +File::replace(const std::string& etag, bool make_backup, FileCreateFlags flags) { GError* gerror = nullptr; - auto retvalue = Glib::wrap(g_file_replace(gobj(), Glib::c_str_or_nullptr(etag), static_cast(make_backup), ((GFileCreateFlags)(flags)), nullptr, &(gerror))); - if(gerror) + auto retvalue = Glib::wrap(g_file_replace(gobj(), Glib::c_str_or_nullptr(etag), + static_cast(make_backup), ((GFileCreateFlags)(flags)), nullptr, &(gerror))); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } - -Glib::RefPtr File::replace_readwrite(const Glib::RefPtr& cancellable, const std::string& etag, bool make_backup, FileCreateFlags flags) +Glib::RefPtr +File::replace_readwrite(const Glib::RefPtr& cancellable, const std::string& etag, + bool make_backup, FileCreateFlags flags) { GError* gerror = nullptr; - auto retvalue = Glib::wrap(g_file_replace_readwrite(gobj(), Glib::c_str_or_nullptr(etag), static_cast(make_backup), ((GFileCreateFlags)(flags)), const_cast(Glib::unwrap(cancellable)), &(gerror))); - if(gerror) + auto retvalue = Glib::wrap(g_file_replace_readwrite(gobj(), Glib::c_str_or_nullptr(etag), + static_cast(make_backup), ((GFileCreateFlags)(flags)), + const_cast(Glib::unwrap(cancellable)), &(gerror))); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } -Glib::RefPtr File::replace_readwrite(const std::string& etag, bool make_backup, FileCreateFlags flags) +Glib::RefPtr +File::replace_readwrite(const std::string& etag, bool make_backup, FileCreateFlags flags) { GError* gerror = nullptr; - auto retvalue = Glib::wrap(g_file_replace_readwrite(gobj(), Glib::c_str_or_nullptr(etag), static_cast(make_backup), ((GFileCreateFlags)(flags)), nullptr, &(gerror))); - if(gerror) + auto retvalue = Glib::wrap(g_file_replace_readwrite(gobj(), Glib::c_str_or_nullptr(etag), + static_cast(make_backup), ((GFileCreateFlags)(flags)), nullptr, &(gerror))); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } - - -Glib::RefPtr File::monitor_directory(const Glib::RefPtr& cancellable, FileMonitorFlags flags) +Glib::RefPtr +File::monitor_directory(const Glib::RefPtr& cancellable, FileMonitorFlags flags) { GError* gerror = nullptr; - auto retvalue = Glib::wrap(g_file_monitor_directory(gobj(), ((GFileMonitorFlags)(flags)), const_cast(Glib::unwrap(cancellable)), &(gerror))); - if(gerror) + auto retvalue = Glib::wrap(g_file_monitor_directory(gobj(), ((GFileMonitorFlags)(flags)), + const_cast(Glib::unwrap(cancellable)), &(gerror))); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } -Glib::RefPtr File::monitor_directory(FileMonitorFlags flags) +Glib::RefPtr +File::monitor_directory(FileMonitorFlags flags) { GError* gerror = nullptr; - auto retvalue = Glib::wrap(g_file_monitor_directory(gobj(), ((GFileMonitorFlags)(flags)), nullptr, &(gerror))); - if(gerror) + auto retvalue = + Glib::wrap(g_file_monitor_directory(gobj(), ((GFileMonitorFlags)(flags)), nullptr, &(gerror))); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } -Glib::RefPtr File::monitor_file(const Glib::RefPtr& cancellable, FileMonitorFlags flags) +Glib::RefPtr +File::monitor_file(const Glib::RefPtr& cancellable, FileMonitorFlags flags) { GError* gerror = nullptr; - auto retvalue = Glib::wrap(g_file_monitor_file(gobj(), ((GFileMonitorFlags)(flags)), const_cast(Glib::unwrap(cancellable)), &(gerror))); - if(gerror) + auto retvalue = Glib::wrap(g_file_monitor_file(gobj(), ((GFileMonitorFlags)(flags)), + const_cast(Glib::unwrap(cancellable)), &(gerror))); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } -Glib::RefPtr File::monitor_file(FileMonitorFlags flags) +Glib::RefPtr +File::monitor_file(FileMonitorFlags flags) { GError* gerror = nullptr; - auto retvalue = Glib::wrap(g_file_monitor_file(gobj(), ((GFileMonitorFlags)(flags)), nullptr, &(gerror))); - if(gerror) + auto retvalue = + Glib::wrap(g_file_monitor_file(gobj(), ((GFileMonitorFlags)(flags)), nullptr, &(gerror))); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } - -Glib::RefPtr File::monitor(const Glib::RefPtr& cancellable, FileMonitorFlags flags) +Glib::RefPtr +File::monitor(const Glib::RefPtr& cancellable, FileMonitorFlags flags) { GError* gerror = nullptr; - auto retvalue = Glib::wrap(g_file_monitor(gobj(), ((GFileMonitorFlags)(flags)), const_cast(Glib::unwrap(cancellable)), &(gerror))); - if(gerror) + auto retvalue = Glib::wrap(g_file_monitor(gobj(), ((GFileMonitorFlags)(flags)), + const_cast(Glib::unwrap(cancellable)), &(gerror))); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } -Glib::RefPtr File::monitor(FileMonitorFlags flags) +Glib::RefPtr +File::monitor(FileMonitorFlags flags) { GError* gerror = nullptr; - auto retvalue = Glib::wrap(g_file_monitor(gobj(), ((GFileMonitorFlags)(flags)), nullptr, &(gerror))); - if(gerror) + auto retvalue = + Glib::wrap(g_file_monitor(gobj(), ((GFileMonitorFlags)(flags)), nullptr, &(gerror))); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } - -void File::measure_disk_usage(const Glib::RefPtr& cancellable, const SlotFileMeasureProgress& slot_progress, guint64& disk_usage, guint64& num_dirs, guint64& num_files, FileMeasureFlags flags) +void +File::measure_disk_usage(const Glib::RefPtr& cancellable, + const SlotFileMeasureProgress& slot_progress, guint64& disk_usage, guint64& num_dirs, + guint64& num_files, FileMeasureFlags flags) { GError* gerror = nullptr; g_file_measure_disk_usage(gobj(), ((GFileMeasureFlags)(flags)), const_cast(Glib::unwrap(cancellable)), - &SignalProxy_file_measure_progress_callback, const_cast(&slot_progress), - &disk_usage, &num_dirs, &num_files, &(gerror)); - if(gerror) + &SignalProxy_file_measure_progress_callback, + const_cast(&slot_progress), &disk_usage, &num_dirs, &num_files, + &(gerror)); + if (gerror) ::Glib::Error::throw_exception(gerror); } -void File::measure_disk_usage_async(const SlotAsyncReady& slot_ready, const Glib::RefPtr& cancellable, const SlotFileMeasureProgress& slot_progress, FileMeasureFlags flags, int io_priority) +void +File::measure_disk_usage_async(const SlotAsyncReady& slot_ready, + const Glib::RefPtr& cancellable, const SlotFileMeasureProgress& slot_progress, + FileMeasureFlags flags, int io_priority) { // Create a new pair which will hold copies of passed slots. // This will be deleted in the SignalProxy_file_measure_async_callback() callback @@ -1627,160 +1422,147 @@ void File::measure_disk_usage_async(const SlotAsyncReady& slot_ready, const Glib slots->first = slot_progress_copy; slots->second = slot_ready_copy; - g_file_measure_disk_usage_async(gobj(), - ((GFileMeasureFlags)(flags)), - io_priority, + g_file_measure_disk_usage_async(gobj(), ((GFileMeasureFlags)(flags)), io_priority, const_cast(Glib::unwrap(cancellable)), - &SignalProxy_file_measure_progress_callback, const_cast(&slot_progress), - &SignalProxy_file_measure_async_callback, slots); + &SignalProxy_file_measure_progress_callback, + const_cast(&slot_progress), &SignalProxy_file_measure_async_callback, + slots); } -void File::start_mountable(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, const Glib::RefPtr& start_operation, DriveStartFlags flags) +void +File::start_mountable(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, + const Glib::RefPtr& start_operation, DriveStartFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_start_mountable(gobj(), - ((GDriveStartFlags)(flags)), - Glib::unwrap(start_operation), - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_file_start_mountable(gobj(), ((GDriveStartFlags)(flags)), Glib::unwrap(start_operation), + Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } -void File::start_mountable(const SlotAsyncReady& slot, const Glib::RefPtr& start_operation, DriveStartFlags flags) +void +File::start_mountable(const SlotAsyncReady& slot, + const Glib::RefPtr& start_operation, DriveStartFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_start_mountable(gobj(), - ((GDriveStartFlags)(flags)), - Glib::unwrap(start_operation), - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_file_start_mountable(gobj(), ((GDriveStartFlags)(flags)), Glib::unwrap(start_operation), + nullptr, &SignalProxy_async_callback, slot_copy); } -void File::stop_mountable(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, const Glib::RefPtr& start_operation, MountUnmountFlags flags) +void +File::stop_mountable(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, + const Glib::RefPtr& start_operation, MountUnmountFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_stop_mountable(gobj(), - ((GMountUnmountFlags)(flags)), - Glib::unwrap(start_operation), - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_file_stop_mountable(gobj(), ((GMountUnmountFlags)(flags)), Glib::unwrap(start_operation), + Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } -void File::stop_mountable(const SlotAsyncReady& slot, const Glib::RefPtr& start_operation, MountUnmountFlags flags) +void +File::stop_mountable(const SlotAsyncReady& slot, + const Glib::RefPtr& start_operation, MountUnmountFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_stop_mountable(gobj(), - ((GMountUnmountFlags)(flags)), - Glib::unwrap(start_operation), - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_file_stop_mountable(gobj(), ((GMountUnmountFlags)(flags)), Glib::unwrap(start_operation), + nullptr, &SignalProxy_async_callback, slot_copy); } - -void File::poll_mountable(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable) +void +File::poll_mountable(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_poll_mountable(gobj(), - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_file_poll_mountable(gobj(), Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } -void File::poll_mountable(const SlotAsyncReady& slot) +void +File::poll_mountable(const SlotAsyncReady& slot) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_poll_mountable(gobj(), - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_file_poll_mountable(gobj(), nullptr, &SignalProxy_async_callback, slot_copy); } -void File::find_enclosing_mount_async(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, int io_priority) +void +File::find_enclosing_mount_async( + const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_find_enclosing_mount_async(gobj(), - io_priority, - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_file_find_enclosing_mount_async( + gobj(), io_priority, Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } -void File::find_enclosing_mount_async(const SlotAsyncReady& slot, int io_priority) +void +File::find_enclosing_mount_async(const SlotAsyncReady& slot, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_file_find_enclosing_mount_async(gobj(), - io_priority, - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_file_find_enclosing_mount_async( + gobj(), io_priority, nullptr, &SignalProxy_async_callback, slot_copy); } -bool File::set_attributes_from_info(const Glib::RefPtr& info, const Glib::RefPtr& cancellable, FileQueryInfoFlags flags) +bool +File::set_attributes_from_info(const Glib::RefPtr& info, + const Glib::RefPtr& cancellable, FileQueryInfoFlags flags) { GError* gerror = nullptr; - bool retvalue = g_file_set_attributes_from_info(gobj(), Glib::unwrap(info), ((GFileQueryInfoFlags)(flags)), const_cast(Glib::unwrap(cancellable)), &(gerror)); - if(gerror) + bool retvalue = + g_file_set_attributes_from_info(gobj(), Glib::unwrap(info), ((GFileQueryInfoFlags)(flags)), + const_cast(Glib::unwrap(cancellable)), &(gerror)); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } -bool File::set_attributes_from_info(const Glib::RefPtr& info, FileQueryInfoFlags flags) +bool +File::set_attributes_from_info(const Glib::RefPtr& info, FileQueryInfoFlags flags) { GError* gerror = nullptr; - bool retvalue = g_file_set_attributes_from_info(gobj(), Glib::unwrap(info), ((GFileQueryInfoFlags)(flags)), nullptr, &(gerror)); - if(gerror) + bool retvalue = g_file_set_attributes_from_info( + gobj(), Glib::unwrap(info), ((GFileQueryInfoFlags)(flags)), nullptr, &(gerror)); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } bool -File::copy_attributes(const Glib::RefPtr& destination, const Glib::RefPtr& cancellable, FileCopyFlags flags) +File::copy_attributes(const Glib::RefPtr& destination, + const Glib::RefPtr& cancellable, FileCopyFlags flags) { GError* gerror = nullptr; bool res; - res = g_file_copy_attributes(gobj(), - Glib::unwrap(destination), - static_cast(flags), - Glib::unwrap(cancellable), - &gerror); + res = g_file_copy_attributes(gobj(), Glib::unwrap(destination), + static_cast(flags), Glib::unwrap(cancellable), &gerror); if (gerror) ::Glib::Error::throw_exception(gerror); @@ -1794,11 +1576,8 @@ File::copy_attributes(const Glib::RefPtr& destination, FileCopyFlags flags GError* gerror = nullptr; bool res; - res = g_file_copy_attributes(gobj(), - Glib::unwrap(destination), - static_cast(flags), - nullptr, - &gerror); + res = g_file_copy_attributes( + gobj(), Glib::unwrap(destination), static_cast(flags), nullptr, &gerror); if (gerror) ::Glib::Error::throw_exception(gerror); @@ -1806,72 +1585,87 @@ File::copy_attributes(const Glib::RefPtr& destination, FileCopyFlags flags return res; } -Glib::RefPtr File::create_file(const Glib::RefPtr& cancellable, FileCreateFlags flags) +Glib::RefPtr +File::create_file(const Glib::RefPtr& cancellable, FileCreateFlags flags) { GError* gerror = nullptr; - auto retvalue = Glib::wrap(g_file_create(gobj(), ((GFileCreateFlags)(flags)), const_cast(Glib::unwrap(cancellable)), &(gerror))); - if(gerror) + auto retvalue = Glib::wrap(g_file_create(gobj(), ((GFileCreateFlags)(flags)), + const_cast(Glib::unwrap(cancellable)), &(gerror))); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } -Glib::RefPtr File::create_file(FileCreateFlags flags) +Glib::RefPtr +File::create_file(FileCreateFlags flags) { GError* gerror = nullptr; - auto retvalue = Glib::wrap(g_file_create(gobj(), ((GFileCreateFlags)(flags)), nullptr, &(gerror))); - if(gerror) + auto retvalue = + Glib::wrap(g_file_create(gobj(), ((GFileCreateFlags)(flags)), nullptr, &(gerror))); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } -Glib::RefPtr File::create_file_readwrite(const Glib::RefPtr& cancellable, FileCreateFlags flags) +Glib::RefPtr +File::create_file_readwrite(const Glib::RefPtr& cancellable, FileCreateFlags flags) { GError* gerror = nullptr; - auto retvalue = Glib::wrap(g_file_create_readwrite(gobj(), ((GFileCreateFlags)(flags)), const_cast(Glib::unwrap(cancellable)), &(gerror))); - if(gerror) + auto retvalue = Glib::wrap(g_file_create_readwrite(gobj(), ((GFileCreateFlags)(flags)), + const_cast(Glib::unwrap(cancellable)), &(gerror))); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } -Glib::RefPtr File::create_file_readwrite(FileCreateFlags flags) +Glib::RefPtr +File::create_file_readwrite(FileCreateFlags flags) { GError* gerror = nullptr; - auto retvalue = Glib::wrap(g_file_create_readwrite(gobj(), ((GFileCreateFlags)(flags)), nullptr, &(gerror))); - if(gerror) + auto retvalue = + Glib::wrap(g_file_create_readwrite(gobj(), ((GFileCreateFlags)(flags)), nullptr, &(gerror))); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } -Glib::RefPtr File::append_to(const Glib::RefPtr& cancellable, FileCreateFlags flags) +Glib::RefPtr +File::append_to(const Glib::RefPtr& cancellable, FileCreateFlags flags) { GError* gerror = nullptr; - auto retvalue = Glib::wrap(g_file_append_to(gobj(), ((GFileCreateFlags)(flags)), const_cast(Glib::unwrap(cancellable)), &(gerror))); - if(gerror) + auto retvalue = Glib::wrap(g_file_append_to(gobj(), ((GFileCreateFlags)(flags)), + const_cast(Glib::unwrap(cancellable)), &(gerror))); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } -Glib::RefPtr File::append_to(FileCreateFlags flags) +Glib::RefPtr +File::append_to(FileCreateFlags flags) { GError* gerror = nullptr; - auto retvalue = Glib::wrap(g_file_append_to(gobj(), ((GFileCreateFlags)(flags)), nullptr, &(gerror))); - if(gerror) + auto retvalue = + Glib::wrap(g_file_append_to(gobj(), ((GFileCreateFlags)(flags)), nullptr, &(gerror))); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } -bool File::load_contents(const Glib::RefPtr& cancellable, char*& contents, gsize& length, std::string& etag_out) +bool +File::load_contents(const Glib::RefPtr& cancellable, char*& contents, gsize& length, + std::string& etag_out) { GError* gerror = nullptr; gchar* cetag_out = nullptr; - bool retvalue = g_file_load_contents(gobj(), Glib::unwrap(cancellable), &contents, &(length), &cetag_out, &(gerror)); - if(gerror) + bool retvalue = g_file_load_contents( + gobj(), Glib::unwrap(cancellable), &contents, &(length), &cetag_out, &(gerror)); + if (gerror) ::Glib::Error::throw_exception(gerror); etag_out = Glib::convert_return_gchar_ptr_to_stdstring(cetag_out); @@ -1879,22 +1673,26 @@ bool File::load_contents(const Glib::RefPtr& cancellable, char*& co return retvalue; } -bool File::load_contents(const Glib::RefPtr& cancellable, char*& contents, gsize& length) +bool +File::load_contents(const Glib::RefPtr& cancellable, char*& contents, gsize& length) { GError* gerror = nullptr; - bool retvalue = g_file_load_contents(gobj(), Glib::unwrap(cancellable), &contents, &(length), nullptr, &(gerror)); - if(gerror) + bool retvalue = g_file_load_contents( + gobj(), Glib::unwrap(cancellable), &contents, &(length), nullptr, &(gerror)); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } -bool File::load_contents(char*& contents, gsize& length, std::string& etag_out) +bool +File::load_contents(char*& contents, gsize& length, std::string& etag_out) { GError* gerror = nullptr; gchar* cetag_out = nullptr; - bool retvalue = g_file_load_contents(gobj(), nullptr, &contents, &(length), &cetag_out, &(gerror)); - if(gerror) + bool retvalue = + g_file_load_contents(gobj(), nullptr, &contents, &(length), &cetag_out, &(gerror)); + if (gerror) ::Glib::Error::throw_exception(gerror); etag_out = Glib::convert_return_gchar_ptr_to_stdstring(cetag_out); @@ -1902,22 +1700,26 @@ bool File::load_contents(char*& contents, gsize& length, std::string& etag_out) return retvalue; } -bool File::load_contents(char*& contents, gsize& length) +bool +File::load_contents(char*& contents, gsize& length) { GError* gerror = nullptr; bool retvalue = g_file_load_contents(gobj(), nullptr, &contents, &(length), nullptr, &(gerror)); - if(gerror) + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } -bool File::load_contents_finish(const Glib::RefPtr& result, char*& contents, gsize& length, std::string& etag_out) +bool +File::load_contents_finish( + const Glib::RefPtr& result, char*& contents, gsize& length, std::string& etag_out) { GError* gerror = nullptr; gchar* cetag_out = nullptr; - bool retvalue = g_file_load_contents_finish(gobj(), Glib::unwrap(result), &contents, &(length), &cetag_out, &(gerror)); - if(gerror) + bool retvalue = g_file_load_contents_finish( + gobj(), Glib::unwrap(result), &contents, &(length), &cetag_out, &(gerror)); + if (gerror) ::Glib::Error::throw_exception(gerror); etag_out = Glib::convert_return_gchar_ptr_to_stdstring(cetag_out); @@ -1925,22 +1727,27 @@ bool File::load_contents_finish(const Glib::RefPtr& result, char*& return retvalue; } -bool File::load_contents_finish(const Glib::RefPtr& result, char*& contents, gsize& length) +bool +File::load_contents_finish(const Glib::RefPtr& result, char*& contents, gsize& length) { GError* gerror = nullptr; - bool retvalue = g_file_load_contents_finish(gobj(), Glib::unwrap(result), &contents, &(length), nullptr, &(gerror)); - if(gerror) + bool retvalue = g_file_load_contents_finish( + gobj(), Glib::unwrap(result), &contents, &(length), nullptr, &(gerror)); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } -bool File::load_partial_contents_finish(const Glib::RefPtr& result, char*& contents, gsize& length, std::string& etag_out) +bool +File::load_partial_contents_finish( + const Glib::RefPtr& result, char*& contents, gsize& length, std::string& etag_out) { GError* gerror = nullptr; gchar* cetag_out = nullptr; - bool retvalue = g_file_load_partial_contents_finish(gobj(), Glib::unwrap(result), &contents, &(length), &cetag_out, &(gerror)); - if(gerror) + bool retvalue = g_file_load_partial_contents_finish( + gobj(), Glib::unwrap(result), &contents, &(length), &cetag_out, &(gerror)); + if (gerror) ::Glib::Error::throw_exception(gerror); etag_out = Glib::convert_return_gchar_ptr_to_stdstring(cetag_out); @@ -1948,121 +1755,96 @@ bool File::load_partial_contents_finish(const Glib::RefPtr& result, return retvalue; } -bool File::load_partial_contents_finish(const Glib::RefPtr& result, char*& contents, gsize& length) +bool +File::load_partial_contents_finish( + const Glib::RefPtr& result, char*& contents, gsize& length) { GError* gerror = nullptr; - bool retvalue = g_file_load_partial_contents_finish(gobj(), Glib::unwrap(result), &contents, &(length), nullptr, &(gerror)); - if(gerror) + bool retvalue = g_file_load_partial_contents_finish( + gobj(), Glib::unwrap(result), &contents, &(length), nullptr, &(gerror)); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } -bool File::has_parent() const +bool +File::has_parent() const { return g_file_has_parent(const_cast(gobj()), nullptr); } - void -File::remove_async(const SlotAsyncReady& slot_ready, - const Glib::RefPtr& cancellable, - int io_priority) +File::remove_async( + const SlotAsyncReady& slot_ready, const Glib::RefPtr& cancellable, int io_priority) { // Create copies of slots. // Pointers to them will be passed through the callbacks' data parameter // and deleted in the corresponding callback. SlotAsyncReady* slot_ready_copy = new SlotAsyncReady(slot_ready); - g_file_delete_async(gobj(), - io_priority, - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_ready_copy); + g_file_delete_async( + gobj(), io_priority, Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_ready_copy); } void -File::remove_async(const SlotAsyncReady& slot_ready, - int io_priority) +File::remove_async(const SlotAsyncReady& slot_ready, int io_priority) { // Create copies of slots. // Pointers to them will be passed through the callbacks' data parameter // and deleted in the corresponding callback. SlotAsyncReady* slot_ready_copy = new SlotAsyncReady(slot_ready); - g_file_delete_async(gobj(), - io_priority, - nullptr, - &SignalProxy_async_callback, - slot_ready_copy); + g_file_delete_async(gobj(), io_priority, nullptr, &SignalProxy_async_callback, slot_ready_copy); } - void -File::trash_async(const SlotAsyncReady& slot_ready, - const Glib::RefPtr& cancellable, - int io_priority) +File::trash_async( + const SlotAsyncReady& slot_ready, const Glib::RefPtr& cancellable, int io_priority) { // Create copies of slots. // Pointers to them will be passed through the callbacks' data parameter // and deleted in the corresponding callback. SlotAsyncReady* slot_ready_copy = new SlotAsyncReady(slot_ready); - g_file_trash_async(gobj(), - io_priority, - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_ready_copy); + g_file_trash_async( + gobj(), io_priority, Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_ready_copy); } void -File::trash_async(const SlotAsyncReady& slot_ready, - int io_priority) +File::trash_async(const SlotAsyncReady& slot_ready, int io_priority) { // Create copies of slots. // Pointers to them will be passed through the callbacks' data parameter // and deleted in the corresponding callback. SlotAsyncReady* slot_ready_copy = new SlotAsyncReady(slot_ready); - g_file_trash_async(gobj(), - io_priority, - nullptr, - &SignalProxy_async_callback, - slot_ready_copy); + g_file_trash_async(gobj(), io_priority, nullptr, &SignalProxy_async_callback, slot_ready_copy); } void -File::make_directory_async(const SlotAsyncReady& slot_ready, - const Glib::RefPtr& cancellable, - int io_priority) +File::make_directory_async( + const SlotAsyncReady& slot_ready, const Glib::RefPtr& cancellable, int io_priority) { // Create copies of slots. // Pointers to them will be passed through the callbacks' data parameter // and deleted in the corresponding callback. SlotAsyncReady* slot_ready_copy = new SlotAsyncReady(slot_ready); - g_file_make_directory_async(gobj(), - io_priority, - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_ready_copy); + g_file_make_directory_async( + gobj(), io_priority, Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_ready_copy); } void -File::make_directory_async(const SlotAsyncReady& slot_ready, - int io_priority) +File::make_directory_async(const SlotAsyncReady& slot_ready, int io_priority) { // Create copies of slots. // Pointers to them will be passed through the callbacks' data parameter // and deleted in the corresponding callback. SlotAsyncReady* slot_ready_copy = new SlotAsyncReady(slot_ready); - g_file_make_directory_async(gobj(), - io_priority, - nullptr, - &SignalProxy_async_callback, - slot_ready_copy); + g_file_make_directory_async( + gobj(), io_priority, nullptr, &SignalProxy_async_callback, slot_ready_copy); } - } // namespace Gio diff --git a/gio/src/fileattributeinfo.ccg b/gio/src/fileattributeinfo.ccg index d3e95977..9cf96757 100644 --- a/gio/src/fileattributeinfo.ccg +++ b/gio/src/fileattributeinfo.ccg @@ -23,8 +23,7 @@ namespace Gio { FileAttributeInfo::FileAttributeInfo(const GFileAttributeInfo* ginfo) - : - m_name(ginfo->name ? ginfo->name : ""), +: m_name(ginfo->name ? ginfo->name : ""), m_type(static_cast(ginfo->type)), m_flags(static_cast(ginfo->flags)) { @@ -45,13 +44,14 @@ FileAttributeInfo::operator=(const FileAttributeInfo& other) } FileAttributeInfo::FileAttributeInfo(FileAttributeInfo&& other) noexcept -: m_name(std::move(other.m_name)), - m_type(std::move(other.m_type)), - m_flags(std::move(other.m_flags)) + : m_name(std::move(other.m_name)), + m_type(std::move(other.m_type)), + m_flags(std::move(other.m_flags)) { } -FileAttributeInfo& FileAttributeInfo::operator=(FileAttributeInfo&& other) noexcept +FileAttributeInfo& +FileAttributeInfo::operator=(FileAttributeInfo&& other) noexcept { m_name = std::move(other.m_name); m_type = std::move(other.m_type); @@ -83,4 +83,3 @@ FileAttributeInfo::get_flags() const } } // namespace Gio - diff --git a/gio/src/fileattributeinfolist.ccg b/gio/src/fileattributeinfolist.ccg index 717b731e..98d0efa8 100644 --- a/gio/src/fileattributeinfolist.ccg +++ b/gio/src/fileattributeinfolist.ccg @@ -27,7 +27,8 @@ FileAttributeInfoList::operator bool() const return !empty(); } -bool FileAttributeInfoList::empty() const +bool +FileAttributeInfoList::empty() const { return gobj() == nullptr; } @@ -36,8 +37,7 @@ FileAttributeInfo FileAttributeInfoList::lookup(const std::string& name) const { auto cobject = const_cast(gobj()); - const GFileAttributeInfo* cinfo = - g_file_attribute_info_list_lookup (cobject, name.c_str()); + const GFileAttributeInfo* cinfo = g_file_attribute_info_list_lookup(cobject, name.c_str()); FileAttributeInfo info(cinfo); return info; diff --git a/gio/src/fileenumerator.ccg b/gio/src/fileenumerator.ccg index aff8c88a..b59cca0c 100644 --- a/gio/src/fileenumerator.ccg +++ b/gio/src/fileenumerator.ccg @@ -27,19 +27,16 @@ namespace Gio { void -FileEnumerator::next_files_async(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, int num_files, int io_priority) +FileEnumerator::next_files_async(const SlotAsyncReady& slot, + const Glib::RefPtr& cancellable, int num_files, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_file_enumerator_next_files_async(gobj(), - num_files, - io_priority, - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_file_enumerator_next_files_async(gobj(), num_files, io_priority, Glib::unwrap(cancellable), + &SignalProxy_async_callback, slot_copy); } void @@ -50,45 +47,35 @@ FileEnumerator::next_files_async(const SlotAsyncReady& slot, int num_files, int // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_file_enumerator_next_files_async(gobj(), - num_files, - io_priority, - nullptr, // cancellable - &SignalProxy_async_callback, - slot_copy); + g_file_enumerator_next_files_async(gobj(), num_files, io_priority, + nullptr, // cancellable + &SignalProxy_async_callback, slot_copy); } void -FileEnumerator::close_async(int io_priority, - const Glib::RefPtr& cancellable, - const SlotAsyncReady& slot) +FileEnumerator::close_async( + int io_priority, const Glib::RefPtr& cancellable, const SlotAsyncReady& slot) { -// Create a copy of the slot. + // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_file_enumerator_close_async(gobj(), - io_priority, - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_file_enumerator_close_async( + gobj(), io_priority, Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } void -FileEnumerator::close_async(int io_priority, - const SlotAsyncReady& slot) +FileEnumerator::close_async(int io_priority, const SlotAsyncReady& slot) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_file_enumerator_close_async(gobj(), - io_priority, - nullptr, // cancellable - &SignalProxy_async_callback, - slot_copy); + g_file_enumerator_close_async(gobj(), io_priority, + nullptr, // cancellable + &SignalProxy_async_callback, slot_copy); } } // namespace Gio diff --git a/gio/src/fileinfo.ccg b/gio/src/fileinfo.ccg index 8d7bd9ae..fa359957 100644 --- a/gio/src/fileinfo.ccg +++ b/gio/src/fileinfo.ccg @@ -19,7 +19,8 @@ #include -namespace Gio { +namespace Gio +{ // FileAttributeMatcher @@ -29,7 +30,8 @@ FileAttributeMatcher::create(const std::string& attributes) return Glib::wrap(g_file_attribute_matcher_new(attributes.c_str())); } -Glib::TimeVal FileInfo::modification_time() const +Glib::TimeVal +FileInfo::modification_time() const { Glib::TimeVal result; g_file_info_get_modification_time(const_cast(gobj()), (GTimeVal*)(&result)); diff --git a/gio/src/fileinputstream.ccg b/gio/src/fileinputstream.ccg index 769cbae2..ef1b73e4 100644 --- a/gio/src/fileinputstream.ccg +++ b/gio/src/fileinputstream.ccg @@ -24,56 +24,55 @@ namespace Gio { -Glib::RefPtr FileInputStream::query_info(const Glib::RefPtr& cancellable, const std::string& attributes) +Glib::RefPtr +FileInputStream::query_info( + const Glib::RefPtr& cancellable, const std::string& attributes) { GError* gerror = nullptr; - auto retvalue = Glib::wrap(g_file_input_stream_query_info(gobj(), g_strdup((attributes).c_str()), const_cast(Glib::unwrap(cancellable)), &(gerror))); - if(gerror) + auto retvalue = Glib::wrap(g_file_input_stream_query_info(gobj(), g_strdup((attributes).c_str()), + const_cast(Glib::unwrap(cancellable)), &(gerror))); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } -Glib::RefPtr FileInputStream::query_info(const std::string& attributes) +Glib::RefPtr +FileInputStream::query_info(const std::string& attributes) { GError* gerror = nullptr; - auto retvalue = Glib::wrap(g_file_input_stream_query_info(gobj(), g_strdup((attributes).c_str()), nullptr, &(gerror))); - if(gerror) + auto retvalue = Glib::wrap( + g_file_input_stream_query_info(gobj(), g_strdup((attributes).c_str()), nullptr, &(gerror))); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } void -FileInputStream::query_info_async(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, const std::string& attributes, int io_priority) +FileInputStream::query_info_async(const SlotAsyncReady& slot, + const Glib::RefPtr& cancellable, const std::string& attributes, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_file_input_stream_query_info_async(gobj(), - const_cast(attributes.c_str()), - io_priority, - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_file_input_stream_query_info_async(gobj(), const_cast(attributes.c_str()), io_priority, + Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } void -FileInputStream::query_info_async(const SlotAsyncReady& slot, const std::string& attributes, int io_priority) +FileInputStream::query_info_async( + const SlotAsyncReady& slot, const std::string& attributes, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_file_input_stream_query_info_async(gobj(), - const_cast(attributes.c_str()), - io_priority, - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_file_input_stream_query_info_async(gobj(), const_cast(attributes.c_str()), io_priority, + nullptr, &SignalProxy_async_callback, slot_copy); } } // namespace Gio diff --git a/gio/src/fileiostream.ccg b/gio/src/fileiostream.ccg index 1ef1bb60..21002d36 100644 --- a/gio/src/fileiostream.ccg +++ b/gio/src/fileiostream.ccg @@ -24,56 +24,55 @@ namespace Gio { -Glib::RefPtr FileIOStream::query_info(const Glib::RefPtr& cancellable, const std::string& attributes) +Glib::RefPtr +FileIOStream::query_info( + const Glib::RefPtr& cancellable, const std::string& attributes) { GError* gerror = nullptr; - auto retvalue = Glib::wrap(g_file_io_stream_query_info(gobj(), g_strdup((attributes).c_str()), const_cast(Glib::unwrap(cancellable)), &(gerror))); - if(gerror) + auto retvalue = Glib::wrap(g_file_io_stream_query_info(gobj(), g_strdup((attributes).c_str()), + const_cast(Glib::unwrap(cancellable)), &(gerror))); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } -Glib::RefPtr FileIOStream::query_info(const std::string& attributes) +Glib::RefPtr +FileIOStream::query_info(const std::string& attributes) { GError* gerror = nullptr; - auto retvalue = Glib::wrap(g_file_io_stream_query_info(gobj(), g_strdup((attributes).c_str()), nullptr, &(gerror))); - if(gerror) + auto retvalue = Glib::wrap( + g_file_io_stream_query_info(gobj(), g_strdup((attributes).c_str()), nullptr, &(gerror))); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } void -FileIOStream::query_info_async(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, const std::string& attributes, int io_priority) +FileIOStream::query_info_async(const SlotAsyncReady& slot, + const Glib::RefPtr& cancellable, const std::string& attributes, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_file_io_stream_query_info_async(gobj(), - const_cast(attributes.c_str()), - io_priority, - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_file_io_stream_query_info_async(gobj(), const_cast(attributes.c_str()), io_priority, + Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } void -FileIOStream::query_info_async(const SlotAsyncReady& slot, const std::string& attributes, int io_priority) +FileIOStream::query_info_async( + const SlotAsyncReady& slot, const std::string& attributes, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_file_io_stream_query_info_async(gobj(), - const_cast(attributes.c_str()), - io_priority, - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_file_io_stream_query_info_async(gobj(), const_cast(attributes.c_str()), io_priority, + nullptr, &SignalProxy_async_callback, slot_copy); } } // namespace Gio diff --git a/gio/src/filemonitor.ccg b/gio/src/filemonitor.ccg index 45b0d1ae..3161de1d 100644 --- a/gio/src/filemonitor.ccg +++ b/gio/src/filemonitor.ccg @@ -21,7 +21,7 @@ #include #include -namespace Gio { - +namespace Gio +{ } // namespace Gio diff --git a/gio/src/filenamecompleter.ccg b/gio/src/filenamecompleter.ccg index 45b0d1ae..3161de1d 100644 --- a/gio/src/filenamecompleter.ccg +++ b/gio/src/filenamecompleter.ccg @@ -21,7 +21,7 @@ #include #include -namespace Gio { - +namespace Gio +{ } // namespace Gio diff --git a/gio/src/fileoutputstream.ccg b/gio/src/fileoutputstream.ccg index 429d5cb0..2e8040c0 100644 --- a/gio/src/fileoutputstream.ccg +++ b/gio/src/fileoutputstream.ccg @@ -26,60 +26,59 @@ namespace Gio { -Glib::RefPtr FileOutputStream::query_info(const Glib::RefPtr& cancellable, const std::string& attributes) +Glib::RefPtr +FileOutputStream::query_info( + const Glib::RefPtr& cancellable, const std::string& attributes) { GError* gerror = nullptr; - auto retvalue = Glib::wrap(g_file_output_stream_query_info(gobj(), g_strdup((attributes).c_str()), const_cast(Glib::unwrap(cancellable)), &(gerror))); - if(gerror) + auto retvalue = Glib::wrap(g_file_output_stream_query_info(gobj(), g_strdup((attributes).c_str()), + const_cast(Glib::unwrap(cancellable)), &(gerror))); + if (gerror) ::Glib::Error::throw_exception(gerror); - if(retvalue) - retvalue->reference(); //The function does not do a ref for us. + if (retvalue) + retvalue->reference(); // The function does not do a ref for us. return retvalue; } -Glib::RefPtr FileOutputStream::query_info(const std::string& attributes) +Glib::RefPtr +FileOutputStream::query_info(const std::string& attributes) { GError* gerror = nullptr; - auto retvalue = Glib::wrap(g_file_output_stream_query_info(gobj(), g_strdup((attributes).c_str()), nullptr, &(gerror))); - if(gerror) + auto retvalue = Glib::wrap( + g_file_output_stream_query_info(gobj(), g_strdup((attributes).c_str()), nullptr, &(gerror))); + if (gerror) ::Glib::Error::throw_exception(gerror); - if(retvalue) - retvalue->reference(); //The function does not do a ref for us. + if (retvalue) + retvalue->reference(); // The function does not do a ref for us. return retvalue; } void -FileOutputStream::query_info_async(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, const std::string& attributes, int io_priority) +FileOutputStream::query_info_async(const SlotAsyncReady& slot, + const Glib::RefPtr& cancellable, const std::string& attributes, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_file_output_stream_query_info_async(gobj(), - const_cast(attributes.c_str()), - io_priority, - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_file_output_stream_query_info_async(gobj(), const_cast(attributes.c_str()), io_priority, + Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } void -FileOutputStream::query_info_async(const SlotAsyncReady& slot, const std::string& attributes, int io_priority) +FileOutputStream::query_info_async( + const SlotAsyncReady& slot, const std::string& attributes, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_file_output_stream_query_info_async(gobj(), - const_cast(attributes.c_str()), - io_priority, - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_file_output_stream_query_info_async(gobj(), const_cast(attributes.c_str()), io_priority, + nullptr, &SignalProxy_async_callback, slot_copy); } } // namespace Gio diff --git a/gio/src/icon.ccg b/gio/src/icon.ccg index 583897a2..fdc6c872 100644 --- a/gio/src/icon.ccg +++ b/gio/src/icon.ccg @@ -20,21 +20,22 @@ #include #include -namespace Gio { +namespace Gio +{ bool Icon::equal(const Glib::RefPtr& other) const { return static_cast( - g_icon_equal(const_cast(this->gobj()), - const_cast(other->gobj()))); + g_icon_equal(const_cast(this->gobj()), const_cast(other->gobj()))); } -Glib::RefPtr Icon::create(const std::string& str) +Glib::RefPtr +Icon::create(const std::string& str) { GError* gerror = nullptr; auto icon = g_icon_new_for_string(str.c_str(), &gerror); - if(gerror) + if (gerror) ::Glib::Error::throw_exception(gerror); return Glib::wrap(icon); diff --git a/gio/src/inetaddress.ccg b/gio/src/inetaddress.ccg index cc87cc05..f8c926fd 100644 --- a/gio/src/inetaddress.ccg +++ b/gio/src/inetaddress.ccg @@ -22,22 +22,22 @@ namespace Gio { -Glib::RefPtr InetAddress::create(const Glib::ustring& string) +Glib::RefPtr +InetAddress::create(const Glib::ustring& string) { - return Glib::wrap (g_inet_address_new_from_string (string.c_str ())); + return Glib::wrap(g_inet_address_new_from_string(string.c_str())); } Glib::RefPtr InetAddress::create_any(SocketFamily family) { - return Glib::wrap (g_inet_address_new_any ((GSocketFamily) family)); + return Glib::wrap(g_inet_address_new_any((GSocketFamily)family)); } - Glib::RefPtr InetAddress::create_loopback(SocketFamily family) { - return Glib::wrap (g_inet_address_new_loopback ((GSocketFamily) family)); + return Glib::wrap(g_inet_address_new_loopback((GSocketFamily)family)); } -} //namespace Gio +} // namespace Gio diff --git a/gio/src/inetsocketaddress.ccg b/gio/src/inetsocketaddress.ccg index c146baae..5317f389 100644 --- a/gio/src/inetsocketaddress.ccg +++ b/gio/src/inetsocketaddress.ccg @@ -22,4 +22,4 @@ namespace Gio { -} //namespace Gio +} // namespace Gio diff --git a/gio/src/inputstream.ccg b/gio/src/inputstream.ccg index 9a6ca6c7..97160032 100644 --- a/gio/src/inputstream.ccg +++ b/gio/src/inputstream.ccg @@ -26,20 +26,16 @@ namespace Gio { void -InputStream::read_async(void* buffer, gsize count, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, int io_priority) +InputStream::read_async(void* buffer, gsize count, const SlotAsyncReady& slot, + const Glib::RefPtr& cancellable, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_input_stream_read_async(gobj(), - buffer, - count, - io_priority, - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_input_stream_read_async(gobj(), buffer, count, io_priority, Glib::unwrap(cancellable), + &SignalProxy_async_callback, slot_copy); } void @@ -50,31 +46,21 @@ InputStream::read_async(void* buffer, gsize count, const SlotAsyncReady& slot, i // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_input_stream_read_async(gobj(), - buffer, - count, - io_priority, - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_input_stream_read_async( + gobj(), buffer, count, io_priority, nullptr, &SignalProxy_async_callback, slot_copy); } - void -InputStream::read_all_async(void* buffer, gsize count, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, int io_priority) +InputStream::read_all_async(void* buffer, gsize count, const SlotAsyncReady& slot, + const Glib::RefPtr& cancellable, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_input_stream_read_all_async(gobj(), - buffer, - count, - io_priority, - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_input_stream_read_all_async(gobj(), buffer, count, io_priority, Glib::unwrap(cancellable), + &SignalProxy_async_callback, slot_copy); } void @@ -85,30 +71,21 @@ InputStream::read_all_async(void* buffer, gsize count, const SlotAsyncReady& slo // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_input_stream_read_all_async(gobj(), - buffer, - count, - io_priority, - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_input_stream_read_all_async( + gobj(), buffer, count, io_priority, nullptr, &SignalProxy_async_callback, slot_copy); } - void -InputStream::read_bytes_async(gsize count, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, int io_priority) +InputStream::read_bytes_async(gsize count, const SlotAsyncReady& slot, + const Glib::RefPtr& cancellable, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_input_stream_read_bytes_async(gobj(), - count, - io_priority, - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_input_stream_read_bytes_async( + gobj(), count, io_priority, Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } void @@ -119,29 +96,21 @@ InputStream::read_bytes_async(gsize count, const SlotAsyncReady& slot, int io_pr // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_input_stream_read_bytes_async(gobj(), - count, - io_priority, - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_input_stream_read_bytes_async( + gobj(), count, io_priority, nullptr, &SignalProxy_async_callback, slot_copy); } - void -InputStream::skip_async(gsize count, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, int io_priority) +InputStream::skip_async(gsize count, const SlotAsyncReady& slot, + const Glib::RefPtr& cancellable, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_input_stream_skip_async(gobj(), - count, - io_priority, - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_input_stream_skip_async( + gobj(), count, io_priority, Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } void @@ -152,27 +121,21 @@ InputStream::skip_async(gsize count, const SlotAsyncReady& slot, int io_priority // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_input_stream_skip_async(gobj(), - count, - io_priority, - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_input_stream_skip_async( + gobj(), count, io_priority, nullptr, &SignalProxy_async_callback, slot_copy); } void -InputStream::close_async(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, int io_priority) +InputStream::close_async( + const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_input_stream_close_async(gobj(), - io_priority, - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_input_stream_close_async( + gobj(), io_priority, Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } void @@ -183,12 +146,7 @@ InputStream::close_async(const SlotAsyncReady& slot, int io_priority) // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_input_stream_close_async(gobj(), - io_priority, - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_input_stream_close_async(gobj(), io_priority, nullptr, &SignalProxy_async_callback, slot_copy); } - } // namespace Gio diff --git a/gio/src/iostream.ccg b/gio/src/iostream.ccg index 057bda85..6242c79e 100644 --- a/gio/src/iostream.ccg +++ b/gio/src/iostream.ccg @@ -26,18 +26,16 @@ namespace Gio { void -IOStream::close_async(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, int io_priority) +IOStream::close_async( + const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_io_stream_close_async(gobj(), - io_priority, - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_io_stream_close_async( + gobj(), io_priority, Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } void @@ -48,40 +46,33 @@ IOStream::close_async(const SlotAsyncReady& slot, int io_priority) // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_io_stream_close_async(gobj(), - io_priority, - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_io_stream_close_async(gobj(), io_priority, nullptr, &SignalProxy_async_callback, slot_copy); } void -IOStream::splice_async(const Glib::RefPtr& stream2, - const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, - IOStreamSpliceFlags flags, int io_priority) +IOStream::splice_async(const Glib::RefPtr& stream2, const SlotAsyncReady& slot, + const Glib::RefPtr& cancellable, IOStreamSpliceFlags flags, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_io_stream_splice_async(gobj(), Glib::unwrap(stream2), - static_cast(flags), io_priority, - Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); + g_io_stream_splice_async(gobj(), Glib::unwrap(stream2), static_cast(flags), + io_priority, Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } void -IOStream::splice_async(const Glib::RefPtr& stream2, - const SlotAsyncReady& slot, IOStreamSpliceFlags flags, int io_priority) +IOStream::splice_async(const Glib::RefPtr& stream2, const SlotAsyncReady& slot, + IOStreamSpliceFlags flags, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_io_stream_splice_async(gobj(), Glib::unwrap(stream2), - static_cast(flags), io_priority, nullptr, - &SignalProxy_async_callback, slot_copy); + g_io_stream_splice_async(gobj(), Glib::unwrap(stream2), static_cast(flags), + io_priority, nullptr, &SignalProxy_async_callback, slot_copy); } } // namespace Gio diff --git a/gio/src/loadableicon.ccg b/gio/src/loadableicon.ccg index 718d3012..9ccc741f 100644 --- a/gio/src/loadableicon.ccg +++ b/gio/src/loadableicon.ccg @@ -31,18 +31,14 @@ LoadableIcon::load(int size, Glib::ustring& type, const Glib::RefPtrreference(); //The function does not do a ref for us. + if (retval) + retval->reference(); // The function does not do a ref for us. return retval; } @@ -51,36 +47,28 @@ LoadableIcon::load(int size, Glib::ustring& type) { char* c_type; GError* gerror = nullptr; - auto retval = - Glib::wrap(g_loadable_icon_load(gobj(), - size, - &c_type, - nullptr, - &gerror)); - if(gerror) + auto retval = Glib::wrap(g_loadable_icon_load(gobj(), size, &c_type, nullptr, &gerror)); + if (gerror) ::Glib::Error::throw_exception(gerror); type = c_type; g_free(c_type); - if(retval) - retval->reference(); //The function does not do a ref for us. + if (retval) + retval->reference(); // The function does not do a ref for us. return retval; } void -LoadableIcon::load_async(int size, const SlotAsyncReady& slot, const - Glib::RefPtr& cancellable) +LoadableIcon::load_async( + int size, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_loadable_icon_load_async(gobj(), - size, - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_loadable_icon_load_async( + gobj(), size, Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } void @@ -91,11 +79,7 @@ LoadableIcon::load_async(int size, const SlotAsyncReady& slot) // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_loadable_icon_load_async(gobj(), - size, - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_loadable_icon_load_async(gobj(), size, nullptr, &SignalProxy_async_callback, slot_copy); } } // namespace Gio diff --git a/gio/src/memoryinputstream.ccg b/gio/src/memoryinputstream.ccg index 72ceb52a..e8965282 100644 --- a/gio/src/memoryinputstream.ccg +++ b/gio/src/memoryinputstream.ccg @@ -26,9 +26,9 @@ class SlotWithData { public: SlotWithData(const Gio::MemoryInputStream::SlotDestroyData& slot, void* data) - : - m_slot(new Gio::MemoryInputStream::SlotDestroyData(slot)), m_data(data) - { } + : m_slot(new Gio::MemoryInputStream::SlotDestroyData(slot)), m_data(data) + { + } ~SlotWithData() { delete m_slot; } @@ -39,7 +39,8 @@ private: void* m_data; }; -void destroy_data_callback(void* user_data) +void +destroy_data_callback(void* user_data) { auto slot_with_data = static_cast(user_data); g_return_if_fail(slot_with_data != nullptr); @@ -62,27 +63,30 @@ namespace Gio { _DEPRECATE_IFDEF_START -void MemoryInputStream::add_data(const std::string& data) +void +MemoryInputStream::add_data(const std::string& data) { - char *data_copy = g_strdup (data.c_str ()); + char* data_copy = g_strdup(data.c_str()); g_memory_input_stream_add_data(gobj(), data_copy, -1, g_free); } -void MemoryInputStream::add_data(const void* data, gssize len) +void +MemoryInputStream::add_data(const void* data, gssize len) { - char *data_copy = nullptr; + char* data_copy = nullptr; // copy the data so that the caller doesn't need to keep the data alive if (len < 0) - data_copy = g_strdup (static_cast(data)); + data_copy = g_strdup(static_cast(data)); else - data_copy = static_cast(g_memdup (data, len)); + data_copy = static_cast(g_memdup(data, len)); g_memory_input_stream_add_data(gobj(), data_copy, len, g_free); } _DEPRECATE_IFDEF_END -void MemoryInputStream::add_data(const void* data, gssize len, const SlotDestroyData& destroy_slot) +void +MemoryInputStream::add_data(const void* data, gssize len, const SlotDestroyData& destroy_slot) { auto slot_with_data = new SlotWithData(destroy_slot, const_cast(data)); auto bytes = g_bytes_new_with_free_func(data, len, &destroy_data_callback, slot_with_data); diff --git a/gio/src/menuattributeiter.ccg b/gio/src/menuattributeiter.ccg index 08e8d4e8..83ea74a2 100644 --- a/gio/src/menuattributeiter.ccg +++ b/gio/src/menuattributeiter.ccg @@ -20,14 +20,13 @@ namespace Gio { -bool MenuAttributeIter::get_next(Glib::ustring& out_name, - Glib::VariantBase& value) +bool +MenuAttributeIter::get_next(Glib::ustring& out_name, Glib::VariantBase& value) { const char* g_out_name = nullptr; GVariant* g_value = nullptr; - bool const result = g_menu_attribute_iter_get_next(gobj(), &g_out_name, - &g_value); + bool const result = g_menu_attribute_iter_get_next(gobj(), &g_out_name, &g_value); out_name = g_out_name; value.init(g_value); diff --git a/gio/src/menuitem.ccg b/gio/src/menuitem.ccg index 6483f42d..6912c056 100644 --- a/gio/src/menuitem.ccg +++ b/gio/src/menuitem.ccg @@ -20,57 +20,60 @@ namespace Gio { -MenuItem::MenuItem(const Glib::ustring& label, const Glib::ustring& detailed_action) -: _CONSTRUCT() +MenuItem::MenuItem(const Glib::ustring& label, const Glib::ustring& detailed_action) : _CONSTRUCT() { - if(!label.empty()) + if (!label.empty()) set_label(label); - if(!detailed_action.empty()) + if (!detailed_action.empty()) set_detailed_action(detailed_action); } MenuItem::MenuItem(const Glib::ustring& label, const Glib::RefPtr& submenu) : _CONSTRUCT() { - if(!label.empty()) + if (!label.empty()) set_label(label); set_submenu(submenu); } -MenuItem::MenuItem(const Glib::RefPtr& submenu) -: _CONSTRUCT() +MenuItem::MenuItem(const Glib::RefPtr& submenu) : _CONSTRUCT() { set_submenu(submenu); } _DEPRECATE_IFDEF_START -void MenuItem::set_action_and_target(const Glib::ustring& action) +void +MenuItem::set_action_and_target(const Glib::ustring& action) { g_menu_item_set_action_and_target_value(gobj(), action.c_str(), nullptr); } _DEPRECATE_IFDEF_END -void MenuItem::set_action(const Glib::ustring& action) +void +MenuItem::set_action(const Glib::ustring& action) { g_menu_item_set_action_and_target_value(gobj(), action.c_str(), nullptr); } -void MenuItem::unset_target() +void +MenuItem::unset_target() { - const gchar *action_name = nullptr; - g_menu_item_get_attribute (gobj(), G_MENU_ATTRIBUTE_ACTION, "&s", &action_name); - + const gchar* action_name = nullptr; + g_menu_item_get_attribute(gobj(), G_MENU_ATTRIBUTE_ACTION, "&s", &action_name); + g_menu_item_set_action_and_target_value(gobj(), action_name, nullptr); } -void MenuItem::unset_action_and_target() +void +MenuItem::unset_action_and_target() { g_menu_item_set_action_and_target_value(gobj(), nullptr, nullptr); } -void MenuItem::unset_icon() +void +MenuItem::unset_icon() { g_menu_item_set_icon(gobj(), nullptr); } diff --git a/gio/src/menulinkiter.ccg b/gio/src/menulinkiter.ccg index b41fbb11..542e46d2 100644 --- a/gio/src/menulinkiter.ccg +++ b/gio/src/menulinkiter.ccg @@ -21,8 +21,8 @@ namespace Gio { -bool MenuLinkIter::get_next(Glib::ustring& out_link, - Glib::RefPtr& value) +bool +MenuLinkIter::get_next(Glib::ustring& out_link, Glib::RefPtr& value) { const char* g_out_link = nullptr; GMenuModel* g_value = nullptr; diff --git a/gio/src/menumodel.ccg b/gio/src/menumodel.ccg index 5d6612eb..48b9b2bb 100644 --- a/gio/src/menumodel.ccg +++ b/gio/src/menumodel.ccg @@ -23,26 +23,20 @@ namespace Gio { // Make sure the order here is the same order as in Gio::MenuAttribute. -static const char* const _attribute_strings[] = -{ - G_MENU_ATTRIBUTE_ACTION, - G_MENU_ATTRIBUTE_LABEL, - G_MENU_ATTRIBUTE_TARGET -}; +static const char* const _attribute_strings[] = { G_MENU_ATTRIBUTE_ACTION, G_MENU_ATTRIBUTE_LABEL, + G_MENU_ATTRIBUTE_TARGET }; -const char* giomm_get_menu_attribute(MenuAttribute attribute) +const char* +giomm_get_menu_attribute(MenuAttribute attribute) { return _attribute_strings[attribute]; } // Make sure the order here is the same order as in Gio::MenuLink. -static const char* const _link_strings[] = -{ - G_MENU_LINK_SECTION, - G_MENU_LINK_SUBMENU -}; +static const char* const _link_strings[] = { G_MENU_LINK_SECTION, G_MENU_LINK_SUBMENU }; -const char* giomm_get_menu_link(MenuLink link) +const char* +giomm_get_menu_link(MenuLink link) { return _link_strings[link]; } diff --git a/gio/src/mount.ccg b/gio/src/mount.ccg index ae2e619b..6b78a8b2 100644 --- a/gio/src/mount.ccg +++ b/gio/src/mount.ccg @@ -27,275 +27,239 @@ namespace Gio { -void Mount::unmount(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, MountUnmountFlags flags) +void +Mount::unmount( + const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, MountUnmountFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_mount_unmount_with_operation(gobj(), - GMountUnmountFlags(flags), - nullptr, // mount_operation - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_mount_unmount_with_operation(gobj(), GMountUnmountFlags(flags), + nullptr, // mount_operation + Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } -void Mount::unmount(const SlotAsyncReady& slot, MountUnmountFlags flags) +void +Mount::unmount(const SlotAsyncReady& slot, MountUnmountFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_mount_unmount_with_operation(gobj(), - GMountUnmountFlags(flags), - nullptr, // mount_operation - nullptr, // cancellable - &SignalProxy_async_callback, - slot_copy); + g_mount_unmount_with_operation(gobj(), GMountUnmountFlags(flags), + nullptr, // mount_operation + nullptr, // cancellable + &SignalProxy_async_callback, slot_copy); } -void Mount::unmount(MountUnmountFlags flags) +void +Mount::unmount(MountUnmountFlags flags) { - g_mount_unmount_with_operation(gobj(), - GMountUnmountFlags(flags), - nullptr, // mount_operation - nullptr, // cancellable - nullptr, // callback - nullptr); // data + g_mount_unmount_with_operation(gobj(), GMountUnmountFlags(flags), + nullptr, // mount_operation + nullptr, // cancellable + nullptr, // callback + nullptr); // data } -void Mount::unmount(const Glib::RefPtr& mount_operation, - const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, MountUnmountFlags flags) +void +Mount::unmount(const Glib::RefPtr& mount_operation, const SlotAsyncReady& slot, + const Glib::RefPtr& cancellable, MountUnmountFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_mount_unmount_with_operation(gobj(), - GMountUnmountFlags(flags), - Glib::unwrap(mount_operation), - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_mount_unmount_with_operation(gobj(), GMountUnmountFlags(flags), Glib::unwrap(mount_operation), + Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } -void Mount::unmount(const Glib::RefPtr& mount_operation, - const SlotAsyncReady& slot, MountUnmountFlags flags) +void +Mount::unmount(const Glib::RefPtr& mount_operation, const SlotAsyncReady& slot, + MountUnmountFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_mount_unmount_with_operation(gobj(), - GMountUnmountFlags(flags), - Glib::unwrap(mount_operation), - nullptr, // cancellable - &SignalProxy_async_callback, - slot_copy); + g_mount_unmount_with_operation(gobj(), GMountUnmountFlags(flags), Glib::unwrap(mount_operation), + nullptr, // cancellable + &SignalProxy_async_callback, slot_copy); } -void Mount::unmount(const Glib::RefPtr& mount_operation, - MountUnmountFlags flags) +void +Mount::unmount(const Glib::RefPtr& mount_operation, MountUnmountFlags flags) { - g_mount_unmount_with_operation(gobj(), - GMountUnmountFlags(flags), - Glib::unwrap(mount_operation), - nullptr, // cancellable - nullptr, // callback - nullptr); // data + g_mount_unmount_with_operation(gobj(), GMountUnmountFlags(flags), Glib::unwrap(mount_operation), + nullptr, // cancellable + nullptr, // callback + nullptr); // data } - -void Mount::remount(const Glib::RefPtr& operation, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, MountMountFlags flags) +void +Mount::remount(const Glib::RefPtr& operation, const SlotAsyncReady& slot, + const Glib::RefPtr& cancellable, MountMountFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_mount_remount(gobj(), - static_cast(flags), - Glib::unwrap(operation), - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_mount_remount(gobj(), static_cast(flags), Glib::unwrap(operation), + Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } -void Mount::remount(const Glib::RefPtr& operation, const SlotAsyncReady& slot, MountMountFlags flags) +void +Mount::remount( + const Glib::RefPtr& operation, const SlotAsyncReady& slot, MountMountFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_mount_remount(gobj(), - static_cast(flags), - Glib::unwrap(operation), - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_mount_remount(gobj(), static_cast(flags), Glib::unwrap(operation), nullptr, + &SignalProxy_async_callback, slot_copy); } -void Mount::remount(const Glib::RefPtr& operation, MountMountFlags flags) +void +Mount::remount(const Glib::RefPtr& operation, MountMountFlags flags) { - g_mount_remount(gobj(), - static_cast(flags), - Glib::unwrap(operation), - nullptr, - nullptr, - nullptr); + g_mount_remount(gobj(), static_cast(flags), Glib::unwrap(operation), nullptr, + nullptr, nullptr); } -void Mount::remount(MountMountFlags flags) +void +Mount::remount(MountMountFlags flags) { - g_mount_remount(gobj(), - static_cast(flags), - nullptr, - nullptr, - nullptr, - nullptr); + g_mount_remount(gobj(), static_cast(flags), nullptr, nullptr, nullptr, nullptr); } -void Mount::eject(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, MountUnmountFlags flags) +void +Mount::eject( + const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, MountUnmountFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_mount_eject_with_operation(gobj(), - GMountUnmountFlags(flags), - nullptr, // mount_operation - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_mount_eject_with_operation(gobj(), GMountUnmountFlags(flags), + nullptr, // mount_operation + Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } -void Mount::eject(const SlotAsyncReady& slot, MountUnmountFlags flags) +void +Mount::eject(const SlotAsyncReady& slot, MountUnmountFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_mount_eject_with_operation(gobj(), - GMountUnmountFlags(flags), - nullptr, // mount_operation - nullptr, // cancellable - &SignalProxy_async_callback, - slot_copy); + g_mount_eject_with_operation(gobj(), GMountUnmountFlags(flags), + nullptr, // mount_operation + nullptr, // cancellable + &SignalProxy_async_callback, slot_copy); } -void Mount::eject(MountUnmountFlags flags) +void +Mount::eject(MountUnmountFlags flags) { - g_mount_eject_with_operation(gobj(), - GMountUnmountFlags(flags), - nullptr, // mount_operation - nullptr, // cancellable - nullptr, // callback - nullptr); // data + g_mount_eject_with_operation(gobj(), GMountUnmountFlags(flags), + nullptr, // mount_operation + nullptr, // cancellable + nullptr, // callback + nullptr); // data } -void Mount::eject(const Glib::RefPtr& mount_operation, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, MountUnmountFlags flags) +void +Mount::eject(const Glib::RefPtr& mount_operation, const SlotAsyncReady& slot, + const Glib::RefPtr& cancellable, MountUnmountFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_mount_eject_with_operation(gobj(), - GMountUnmountFlags(flags), - Glib::unwrap(mount_operation), - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_mount_eject_with_operation(gobj(), GMountUnmountFlags(flags), Glib::unwrap(mount_operation), + Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } -void Mount::eject(const Glib::RefPtr& mount_operation, const SlotAsyncReady& slot, MountUnmountFlags flags) +void +Mount::eject(const Glib::RefPtr& mount_operation, const SlotAsyncReady& slot, + MountUnmountFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_mount_eject_with_operation(gobj(), - GMountUnmountFlags(flags), - Glib::unwrap(mount_operation), - nullptr, // cancellable - &SignalProxy_async_callback, - slot_copy); + g_mount_eject_with_operation(gobj(), GMountUnmountFlags(flags), Glib::unwrap(mount_operation), + nullptr, // cancellable + &SignalProxy_async_callback, slot_copy); } -void Mount::eject(const Glib::RefPtr& mount_operation, MountUnmountFlags flags) +void +Mount::eject(const Glib::RefPtr& mount_operation, MountUnmountFlags flags) { - g_mount_eject_with_operation(gobj(), - GMountUnmountFlags(flags), - Glib::unwrap(mount_operation), - nullptr, // cancellable - nullptr, // callback - nullptr); // data + g_mount_eject_with_operation(gobj(), GMountUnmountFlags(flags), Glib::unwrap(mount_operation), + nullptr, // cancellable + nullptr, // callback + nullptr); // data } - -void Mount::guess_content_type(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, bool force_rescan) +void +Mount::guess_content_type( + const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, bool force_rescan) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_mount_guess_content_type(gobj(), - force_rescan, - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_mount_guess_content_type( + gobj(), force_rescan, Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } -void Mount::guess_content_type(const SlotAsyncReady& slot, bool force_rescan) +void +Mount::guess_content_type(const SlotAsyncReady& slot, bool force_rescan) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_mount_guess_content_type(gobj(), - force_rescan, - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_mount_guess_content_type(gobj(), force_rescan, nullptr, &SignalProxy_async_callback, slot_copy); } -void Mount::guess_content_type(bool force_rescan) +void +Mount::guess_content_type(bool force_rescan) { - g_mount_guess_content_type(gobj(), - force_rescan, - nullptr, - nullptr, - nullptr); + g_mount_guess_content_type(gobj(), force_rescan, nullptr, nullptr, nullptr); } -void Mount::guess_content_type_sync(const Glib::RefPtr& cancellable, bool force_rescan) +void +Mount::guess_content_type_sync(const Glib::RefPtr& cancellable, bool force_rescan) { - GError* gerror = nullptr; - g_mount_guess_content_type_sync(gobj(), force_rescan, Glib::unwrap(cancellable), - &gerror); - if(gerror) - ::Glib::Error::throw_exception(gerror); + GError* gerror = nullptr; + g_mount_guess_content_type_sync(gobj(), force_rescan, Glib::unwrap(cancellable), &gerror); + if (gerror) + ::Glib::Error::throw_exception(gerror); } -void Mount::guess_content_type_sync(bool force_rescan) +void +Mount::guess_content_type_sync(bool force_rescan) { - GError* gerror = nullptr; - g_mount_guess_content_type_sync(gobj(), force_rescan, nullptr, &gerror); - if(gerror) - ::Glib::Error::throw_exception(gerror); + GError* gerror = nullptr; + g_mount_guess_content_type_sync(gobj(), force_rescan, nullptr, &gerror); + if (gerror) + ::Glib::Error::throw_exception(gerror); } - } // namespace Gio - diff --git a/gio/src/networkaddress.ccg b/gio/src/networkaddress.ccg index dad0dcf1..43e2d879 100644 --- a/gio/src/networkaddress.ccg +++ b/gio/src/networkaddress.ccg @@ -28,14 +28,13 @@ namespace Gio Glib::RefPtr NetworkAddress::parse(const std::string& host_and_port, guint16 default_port) { - GError *error = nullptr; - auto *address = G_NETWORK_ADDRESS - (g_network_address_parse (host_and_port.c_str (), default_port, - &error)); - if (error) - Glib::Error::throw_exception (error); + GError* error = nullptr; + auto* address = + G_NETWORK_ADDRESS(g_network_address_parse(host_and_port.c_str(), default_port, &error)); + if (error) + Glib::Error::throw_exception(error); - return Glib::wrap (address); + return Glib::wrap(address); } } // namespace Gio diff --git a/gio/src/networkmonitor.ccg b/gio/src/networkmonitor.ccg index 550a6ac3..1b940c54 100644 --- a/gio/src/networkmonitor.ccg +++ b/gio/src/networkmonitor.ccg @@ -19,20 +19,20 @@ #include #include "slot_async.h" -namespace Gio { +namespace Gio +{ -void NetworkMonitor::can_reach_async(const Glib::RefPtr& connectable, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable) +void +NetworkMonitor::can_reach_async(const Glib::RefPtr& connectable, + const SlotAsyncReady& slot, const Glib::RefPtr& cancellable) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_network_monitor_can_reach_async(gobj(), - Glib::unwrap(connectable), - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_network_monitor_can_reach_async(gobj(), Glib::unwrap(connectable), Glib::unwrap(cancellable), + &SignalProxy_async_callback, slot_copy); } } // namespace Gio diff --git a/gio/src/notification.ccg b/gio/src/notification.ccg index 05783950..3697f101 100644 --- a/gio/src/notification.ccg +++ b/gio/src/notification.ccg @@ -21,8 +21,7 @@ namespace Gio { -Notification::Notification(const Glib::ustring& title) -: _CONSTRUCT() +Notification::Notification(const Glib::ustring& title) : _CONSTRUCT() { // The title is compulsory. Don't skip it, if it's empty. set_title(title); diff --git a/gio/src/outputstream.ccg b/gio/src/outputstream.ccg index caef1eba..2f471497 100644 --- a/gio/src/outputstream.ccg +++ b/gio/src/outputstream.ccg @@ -22,126 +22,100 @@ #include #include "slot_async.h" -namespace Gio { +namespace Gio +{ void -OutputStream::write_async(const void* buffer, gsize count, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, int io_priority) +OutputStream::write_async(const void* buffer, gsize count, const SlotAsyncReady& slot, + const Glib::RefPtr& cancellable, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_output_stream_write_async(gobj(), - buffer, - count, - io_priority, - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_output_stream_write_async(gobj(), buffer, count, io_priority, Glib::unwrap(cancellable), + &SignalProxy_async_callback, slot_copy); } void -OutputStream::write_async(const void* buffer, gsize count, const SlotAsyncReady& slot, int io_priority) +OutputStream::write_async( + const void* buffer, gsize count, const SlotAsyncReady& slot, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_output_stream_write_async(gobj(), - buffer, - count, - io_priority, - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_output_stream_write_async( + gobj(), buffer, count, io_priority, nullptr, &SignalProxy_async_callback, slot_copy); } - - void -OutputStream::write_all_async(const void* buffer, gsize count, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, int io_priority) +OutputStream::write_all_async(const void* buffer, gsize count, const SlotAsyncReady& slot, + const Glib::RefPtr& cancellable, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_output_stream_write_all_async(gobj(), - buffer, - count, - io_priority, - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_output_stream_write_all_async(gobj(), buffer, count, io_priority, Glib::unwrap(cancellable), + &SignalProxy_async_callback, slot_copy); } void -OutputStream::write_all_async(const void* buffer, gsize count, const SlotAsyncReady& slot, int io_priority) +OutputStream::write_all_async( + const void* buffer, gsize count, const SlotAsyncReady& slot, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_output_stream_write_all_async(gobj(), - buffer, - count, - io_priority, - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_output_stream_write_all_async( + gobj(), buffer, count, io_priority, nullptr, &SignalProxy_async_callback, slot_copy); } - void -OutputStream::splice_async(const Glib::RefPtr& source, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, OutputStreamSpliceFlags flags, int io_priority) +OutputStream::splice_async(const Glib::RefPtr& source, const SlotAsyncReady& slot, + const Glib::RefPtr& cancellable, OutputStreamSpliceFlags flags, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_output_stream_splice_async(gobj(), - Glib::unwrap(source), - static_cast(flags), - io_priority, - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_output_stream_splice_async(gobj(), Glib::unwrap(source), + static_cast(flags), io_priority, Glib::unwrap(cancellable), + &SignalProxy_async_callback, slot_copy); } void -OutputStream::splice_async(const Glib::RefPtr& source, const SlotAsyncReady& slot, OutputStreamSpliceFlags flags, int io_priority) +OutputStream::splice_async(const Glib::RefPtr& source, const SlotAsyncReady& slot, + OutputStreamSpliceFlags flags, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_output_stream_splice_async(gobj(), - Glib::unwrap(source), - static_cast(flags), - io_priority, - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_output_stream_splice_async(gobj(), Glib::unwrap(source), + static_cast(flags), io_priority, nullptr, &SignalProxy_async_callback, + slot_copy); } void -OutputStream::flush_async(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, int io_priority) +OutputStream::flush_async( + const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_output_stream_flush_async(gobj(), - io_priority, - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_output_stream_flush_async( + gobj(), io_priority, Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } void @@ -152,26 +126,20 @@ OutputStream::flush_async(const SlotAsyncReady& slot, int io_priority) // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_output_stream_flush_async(gobj(), - io_priority, - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_output_stream_flush_async(gobj(), io_priority, nullptr, &SignalProxy_async_callback, slot_copy); } void -OutputStream::close_async(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, int io_priority) +OutputStream::close_async( + const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_output_stream_close_async(gobj(), - io_priority, - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_output_stream_close_async( + gobj(), io_priority, Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } void @@ -182,101 +150,103 @@ OutputStream::close_async(const SlotAsyncReady& slot, int io_priority) // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_output_stream_close_async(gobj(), - io_priority, - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_output_stream_close_async(gobj(), io_priority, nullptr, &SignalProxy_async_callback, slot_copy); } -gssize OutputStream::write(const std::string& buffer, const Glib::RefPtr& cancellable) +gssize +OutputStream::write(const std::string& buffer, const Glib::RefPtr& cancellable) { GError* gerror = nullptr; - gssize retvalue = g_output_stream_write(gobj(), buffer.data(), buffer.size(), Glib::unwrap(cancellable), &(gerror)); - if(gerror) + gssize retvalue = g_output_stream_write( + gobj(), buffer.data(), buffer.size(), Glib::unwrap(cancellable), &(gerror)); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } -gssize OutputStream::write(const std::string& buffer) +gssize +OutputStream::write(const std::string& buffer) { GError* gerror = nullptr; gssize retvalue = g_output_stream_write(gobj(), buffer.data(), buffer.size(), nullptr, &(gerror)); - if(gerror) + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } -bool OutputStream::write_all(const std::string& buffer, gsize& bytes_written, const Glib::RefPtr& cancellable) +bool +OutputStream::write_all( + const std::string& buffer, gsize& bytes_written, const Glib::RefPtr& cancellable) { GError* gerror = nullptr; - bool retvalue = g_output_stream_write_all(gobj(), buffer.data(), buffer.size(), &(bytes_written), Glib::unwrap(cancellable), &(gerror)); - if(gerror) + bool retvalue = g_output_stream_write_all( + gobj(), buffer.data(), buffer.size(), &(bytes_written), Glib::unwrap(cancellable), &(gerror)); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } -bool OutputStream::write_all(const std::string& buffer, gsize& bytes_written) +bool +OutputStream::write_all(const std::string& buffer, gsize& bytes_written) { GError* gerror = nullptr; - bool retvalue = g_output_stream_write_all(gobj(), buffer.data(), buffer.size(), &(bytes_written), nullptr, &(gerror)); - if(gerror) + bool retvalue = g_output_stream_write_all( + gobj(), buffer.data(), buffer.size(), &(bytes_written), nullptr, &(gerror)); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } - void -OutputStream::write_bytes_async(const Glib::RefPtr& bytes, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, int io_priority) +OutputStream::write_bytes_async(const Glib::RefPtr& bytes, + const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_output_stream_write_bytes_async(gobj(), - const_cast(Glib::unwrap(bytes)), - io_priority, - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_output_stream_write_bytes_async(gobj(), const_cast(Glib::unwrap(bytes)), io_priority, + Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } void -OutputStream::write_bytes_async(const Glib::RefPtr& bytes, const SlotAsyncReady& slot, int io_priority) +OutputStream::write_bytes_async( + const Glib::RefPtr& bytes, const SlotAsyncReady& slot, int io_priority) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. SlotAsyncReady* slot_copy = new SlotAsyncReady(slot); - g_output_stream_write_bytes_async(gobj(), - const_cast(Glib::unwrap(bytes)), - io_priority, - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_output_stream_write_bytes_async(gobj(), const_cast(Glib::unwrap(bytes)), io_priority, + nullptr, &SignalProxy_async_callback, slot_copy); } -gssize OutputStream::splice(const Glib::RefPtr& source, const Glib::RefPtr& cancellable, OutputStreamSpliceFlags flags) +gssize +OutputStream::splice(const Glib::RefPtr& source, + const Glib::RefPtr& cancellable, OutputStreamSpliceFlags flags) { GError* gerror = nullptr; - gssize retvalue = g_output_stream_splice(gobj(), Glib::unwrap(source), ((GOutputStreamSpliceFlags)(flags)), Glib::unwrap(cancellable), &(gerror)); - if(gerror) + gssize retvalue = g_output_stream_splice(gobj(), Glib::unwrap(source), + ((GOutputStreamSpliceFlags)(flags)), Glib::unwrap(cancellable), &(gerror)); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } -gssize OutputStream::splice(const Glib::RefPtr& source, OutputStreamSpliceFlags flags) +gssize +OutputStream::splice(const Glib::RefPtr& source, OutputStreamSpliceFlags flags) { GError* gerror = nullptr; - gssize retvalue = g_output_stream_splice(gobj(), Glib::unwrap(source), ((GOutputStreamSpliceFlags)(flags)), nullptr, &(gerror)); - if(gerror) + gssize retvalue = g_output_stream_splice( + gobj(), Glib::unwrap(source), ((GOutputStreamSpliceFlags)(flags)), nullptr, &(gerror)); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; diff --git a/gio/src/permission.ccg b/gio/src/permission.ccg index c3debd28..69574577 100644 --- a/gio/src/permission.ccg +++ b/gio/src/permission.ccg @@ -18,7 +18,6 @@ #include #include "slot_async.h" - namespace Gio { } // namespace Gio diff --git a/gio/src/proxy.ccg b/gio/src/proxy.ccg index c47db49e..f744a772 100644 --- a/gio/src/proxy.ccg +++ b/gio/src/proxy.ccg @@ -26,34 +26,33 @@ namespace Gio { -void Proxy::connect_async(const Glib::RefPtr& connection, const Glib::RefPtr& proxy_address, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable) +void +Proxy::connect_async(const Glib::RefPtr& connection, + const Glib::RefPtr& proxy_address, const SlotAsyncReady& slot, + const Glib::RefPtr& cancellable) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_proxy_connect_async(gobj(), - Glib::unwrap(connection), - const_cast(Glib::unwrap(proxy_address)), - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_proxy_connect_async(gobj(), Glib::unwrap(connection), + const_cast(Glib::unwrap(proxy_address)), Glib::unwrap(cancellable), + &SignalProxy_async_callback, slot_copy); } -void Proxy::connect_async(const Glib::RefPtr& connection, const Glib::RefPtr& proxy_address, const SlotAsyncReady& slot) +void +Proxy::connect_async(const Glib::RefPtr& connection, + const Glib::RefPtr& proxy_address, const SlotAsyncReady& slot) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_proxy_connect_async(gobj(), - Glib::unwrap(connection), - const_cast(Glib::unwrap(proxy_address)), - nullptr, - &SignalProxy_async_callback, + g_proxy_connect_async(gobj(), Glib::unwrap(connection), + const_cast(Glib::unwrap(proxy_address)), nullptr, &SignalProxy_async_callback, slot_copy); } -} //namespace Gio +} // namespace Gio diff --git a/gio/src/proxyaddress.ccg b/gio/src/proxyaddress.ccg index 96aed62c..ab1fdd7b 100644 --- a/gio/src/proxyaddress.ccg +++ b/gio/src/proxyaddress.ccg @@ -22,4 +22,4 @@ namespace Gio { -} //namespace Gio +} // namespace Gio diff --git a/gio/src/proxyresolver.ccg b/gio/src/proxyresolver.ccg index 1f67a9b8..f9303e35 100644 --- a/gio/src/proxyresolver.ccg +++ b/gio/src/proxyresolver.ccg @@ -27,43 +27,41 @@ namespace Gio { -std::vector ProxyResolver::lookup(const Glib::ustring& uri) +std::vector +ProxyResolver::lookup(const Glib::ustring& uri) { GError* gerror = nullptr; - auto retvalue = - Glib::ArrayHandler::array_to_vector(g_proxy_resolver_lookup(gobj(), uri.c_str(), nullptr, &(gerror)), Glib::OWNERSHIP_DEEP); - if(gerror) + auto retvalue = Glib::ArrayHandler::array_to_vector( + g_proxy_resolver_lookup(gobj(), uri.c_str(), nullptr, &(gerror)), Glib::OWNERSHIP_DEEP); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } -void ProxyResolver::lookup_async(const Glib::ustring& uri, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable) +void +ProxyResolver::lookup_async(const Glib::ustring& uri, const SlotAsyncReady& slot, + const Glib::RefPtr& cancellable) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_proxy_resolver_lookup_async(gobj(), - uri.c_str(), - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_proxy_resolver_lookup_async( + gobj(), uri.c_str(), Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } -void ProxyResolver::lookup_async(const Glib::ustring& uri, const SlotAsyncReady& slot) +void +ProxyResolver::lookup_async(const Glib::ustring& uri, const SlotAsyncReady& slot) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_proxy_resolver_lookup_async(gobj(), - uri.c_str(), - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_proxy_resolver_lookup_async( + gobj(), uri.c_str(), nullptr, &SignalProxy_async_callback, slot_copy); } -} //namespace Gio +} // namespace Gio diff --git a/gio/src/resolver.ccg b/gio/src/resolver.ccg index 60d329d8..093f6981 100644 --- a/gio/src/resolver.ccg +++ b/gio/src/resolver.ccg @@ -22,166 +22,127 @@ namespace Gio { -Glib::RefPtr Resolver::get_default() +Glib::RefPtr +Resolver::get_default() { - return Glib::wrap(g_resolver_get_default()); + return Glib::wrap(g_resolver_get_default()); } -void Resolver::set_default(const Glib::RefPtr& resolver) +void +Resolver::set_default(const Glib::RefPtr& resolver) { - g_resolver_set_default(Glib::unwrap(resolver)); + g_resolver_set_default(Glib::unwrap(resolver)); } void -Resolver::lookup_by_name_async(const Glib::ustring& hostname, - const SlotAsyncReady& slot, - const Glib::RefPtr& cancellable) +Resolver::lookup_by_name_async(const Glib::ustring& hostname, const SlotAsyncReady& slot, + const Glib::RefPtr& cancellable) { auto slot_copy = new SlotAsyncReady(slot); - g_resolver_lookup_by_name_async (gobj(), - hostname.c_str(), - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_resolver_lookup_by_name_async( + gobj(), hostname.c_str(), Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } void -Resolver::lookup_by_name_async(const Glib::ustring& hostname, - const SlotAsyncReady& slot) +Resolver::lookup_by_name_async(const Glib::ustring& hostname, const SlotAsyncReady& slot) { auto slot_copy = new SlotAsyncReady(slot); - g_resolver_lookup_by_name_async (gobj(), - hostname.c_str(), - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_resolver_lookup_by_name_async( + gobj(), hostname.c_str(), nullptr, &SignalProxy_async_callback, slot_copy); } void Resolver::lookup_by_address_async(const Glib::RefPtr& address, - const SlotAsyncReady& slot, - const Glib::RefPtr& cancellable) + const SlotAsyncReady& slot, const Glib::RefPtr& cancellable) { auto slot_copy = new SlotAsyncReady(slot); - g_resolver_lookup_by_address_async (gobj(), - Glib::unwrap(address), - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_resolver_lookup_by_address_async(gobj(), Glib::unwrap(address), Glib::unwrap(cancellable), + &SignalProxy_async_callback, slot_copy); } void -Resolver::lookup_by_address_async(const Glib::RefPtr& address, - const SlotAsyncReady& slot) +Resolver::lookup_by_address_async( + const Glib::RefPtr& address, const SlotAsyncReady& slot) { auto slot_copy = new SlotAsyncReady(slot); - g_resolver_lookup_by_address_async (gobj(), - Glib::unwrap(address), - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_resolver_lookup_by_address_async( + gobj(), Glib::unwrap(address), nullptr, &SignalProxy_async_callback, slot_copy); } void -Resolver::lookup_service_async(const Glib::ustring& service, - const Glib::ustring& protocol, - const Glib::ustring& domain, - const SlotAsyncReady& slot, - const Glib::RefPtr& cancellable) +Resolver::lookup_service_async(const Glib::ustring& service, const Glib::ustring& protocol, + const Glib::ustring& domain, const SlotAsyncReady& slot, + const Glib::RefPtr& cancellable) { auto slot_copy = new SlotAsyncReady(slot); - g_resolver_lookup_service_async (gobj(), - service.c_str(), - protocol.c_str(), - domain.c_str(), - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_resolver_lookup_service_async(gobj(), service.c_str(), protocol.c_str(), domain.c_str(), + Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } void -Resolver::lookup_service_async(const Glib::ustring& service, - const Glib::ustring& protocol, - const Glib::ustring& domain, - const SlotAsyncReady& slot) +Resolver::lookup_service_async(const Glib::ustring& service, const Glib::ustring& protocol, + const Glib::ustring& domain, const SlotAsyncReady& slot) { auto slot_copy = new SlotAsyncReady(slot); - g_resolver_lookup_service_async (gobj(), - service.c_str(), - protocol.c_str(), - domain.c_str(), - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_resolver_lookup_service_async(gobj(), service.c_str(), protocol.c_str(), domain.c_str(), + nullptr, &SignalProxy_async_callback, slot_copy); } void -Resolver::lookup_records_async(const Glib::ustring& rrname, - ResolverRecordType record_type, - const SlotAsyncReady& slot, - const Glib::RefPtr& cancellable) +Resolver::lookup_records_async(const Glib::ustring& rrname, ResolverRecordType record_type, + const SlotAsyncReady& slot, const Glib::RefPtr& cancellable) { auto slot_copy = new SlotAsyncReady(slot); - g_resolver_lookup_records_async(gobj(), - Glib::c_str_or_nullptr(rrname), - static_cast(record_type), - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_resolver_lookup_records_async(gobj(), Glib::c_str_or_nullptr(rrname), + static_cast(record_type), Glib::unwrap(cancellable), + &SignalProxy_async_callback, slot_copy); } void -Resolver::lookup_records_async(const Glib::ustring& rrname, - ResolverRecordType record_type, - const SlotAsyncReady& slot) +Resolver::lookup_records_async( + const Glib::ustring& rrname, ResolverRecordType record_type, const SlotAsyncReady& slot) { auto slot_copy = new SlotAsyncReady(slot); - g_resolver_lookup_records_async(gobj(), - Glib::c_str_or_nullptr(rrname), - static_cast(record_type), - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_resolver_lookup_records_async(gobj(), Glib::c_str_or_nullptr(rrname), + static_cast(record_type), nullptr, &SignalProxy_async_callback, slot_copy); } std::string -hostname_to_ascii (const Glib::ustring& hostname) +hostname_to_ascii(const Glib::ustring& hostname) { - return Glib::convert_return_gchar_ptr_to_stdstring - (g_hostname_to_ascii (hostname.c_str ())); + return Glib::convert_return_gchar_ptr_to_stdstring(g_hostname_to_ascii(hostname.c_str())); } Glib::ustring -hostname_to_unicode (const Glib::ustring& hostname) +hostname_to_unicode(const Glib::ustring& hostname) { - return Glib::convert_return_gchar_ptr_to_ustring - (g_hostname_to_unicode (hostname.c_str ())); + return Glib::convert_return_gchar_ptr_to_ustring(g_hostname_to_unicode(hostname.c_str())); } bool -hostname_is_non_ascii (const Glib::ustring& hostname) +hostname_is_non_ascii(const Glib::ustring& hostname) { - return g_hostname_is_non_ascii (hostname.c_str ()); + return g_hostname_is_non_ascii(hostname.c_str()); } bool -hostname_is_ascii_encoded (const Glib::ustring& hostname) +hostname_is_ascii_encoded(const Glib::ustring& hostname) { - return g_hostname_is_ascii_encoded (hostname.c_str ()); + return g_hostname_is_ascii_encoded(hostname.c_str()); } bool -hostname_is_ip_address (const Glib::ustring& hostname) +hostname_is_ip_address(const Glib::ustring& hostname) { - return g_hostname_is_ip_address (hostname.c_str ()); + return g_hostname_is_ip_address(hostname.c_str()); } -} //namespace Gio +} // namespace Gio diff --git a/gio/src/resource.ccg b/gio/src/resource.ccg index f8401000..0c7a599b 100644 --- a/gio/src/resource.ccg +++ b/gio/src/resource.ccg @@ -20,8 +20,9 @@ namespace Gio { // Hand-coded because we want ResourceFlags& instead of guint32&. -void Resource::get_info(const std::string& path, gsize& size, - ResourceFlags& flags, ResourceLookupFlags lookup_flags) const +void +Resource::get_info(const std::string& path, gsize& size, ResourceFlags& flags, + ResourceLookupFlags lookup_flags) const { guint32 file_flags = 0; GError* gerror = nullptr; @@ -34,7 +35,8 @@ void Resource::get_info(const std::string& path, gsize& size, flags = static_cast(file_flags); } -void Resource::get_file_exists(const std::string& path, ResourceLookupFlags lookup_flags) const +void +Resource::get_file_exists(const std::string& path, ResourceLookupFlags lookup_flags) const { GError* gerror = nullptr; g_resource_get_info(const_cast(gobj()), path.c_str(), @@ -43,42 +45,46 @@ void Resource::get_file_exists(const std::string& path, ResourceLookupFlags look ::Glib::Error::throw_exception(gerror); } -bool Resource::get_file_exists_nothrow(const std::string& path, ResourceLookupFlags lookup_flags) const +bool +Resource::get_file_exists_nothrow(const std::string& path, ResourceLookupFlags lookup_flags) const { return g_resource_get_info(const_cast(gobj()), path.c_str(), (GResourceLookupFlags)lookup_flags, nullptr, nullptr, nullptr); } // Hand-coded because we want ResourceFlags& instead of guint32&. -//static -void Resource::get_info_global(const std::string& path, gsize& size, - ResourceFlags& flags, ResourceLookupFlags lookup_flags) +// static +void +Resource::get_info_global( + const std::string& path, gsize& size, ResourceFlags& flags, ResourceLookupFlags lookup_flags) { guint32 file_flags = 0; GError* gerror = nullptr; // Ignore the gboolean return value from g_resources_get_info(). // gerror is set if and only if the return value is FALSE. - g_resources_get_info(path.c_str(), - (GResourceLookupFlags)lookup_flags, &size, &file_flags, &gerror); + g_resources_get_info( + path.c_str(), (GResourceLookupFlags)lookup_flags, &size, &file_flags, &gerror); if (gerror) ::Glib::Error::throw_exception(gerror); flags = static_cast(file_flags); } -//static -void Resource::get_file_exists_global(const std::string& path, ResourceLookupFlags lookup_flags) +// static +void +Resource::get_file_exists_global(const std::string& path, ResourceLookupFlags lookup_flags) { GError* gerror = nullptr; - g_resources_get_info(path.c_str(), - (GResourceLookupFlags)lookup_flags, nullptr, nullptr, &gerror); + g_resources_get_info(path.c_str(), (GResourceLookupFlags)lookup_flags, nullptr, nullptr, &gerror); if (gerror) ::Glib::Error::throw_exception(gerror); } -//static -bool Resource::get_file_exists_global_nothrow(const std::string& path, ResourceLookupFlags lookup_flags) +// static +bool +Resource::get_file_exists_global_nothrow(const std::string& path, ResourceLookupFlags lookup_flags) { - return g_resources_get_info(path.c_str(), (GResourceLookupFlags)lookup_flags, nullptr, nullptr, nullptr); + return g_resources_get_info( + path.c_str(), (GResourceLookupFlags)lookup_flags, nullptr, nullptr, nullptr); } } // namespace Gio diff --git a/gio/src/seekable.ccg b/gio/src/seekable.ccg index 193bbeb8..43f4afea 100644 --- a/gio/src/seekable.ccg +++ b/gio/src/seekable.ccg @@ -23,4 +23,3 @@ namespace Gio { } // namespace Gio - diff --git a/gio/src/settings.ccg b/gio/src/settings.ccg index 98b6ccd4..3ec86919 100644 --- a/gio/src/settings.ccg +++ b/gio/src/settings.ccg @@ -22,54 +22,58 @@ namespace Gio { -void Settings::get_value(const Glib::ustring& key, Glib::VariantBase& value) const +void +Settings::get_value(const Glib::ustring& key, Glib::VariantBase& value) const { const auto g_value = g_settings_get_value(const_cast(gobj()), key.c_str()); - if(!g_value) + if (!g_value) return; value.init(g_value, false /* don't take a reference */); } -bool Settings::get_user_value(const Glib::ustring& key, Glib::VariantBase& value) const +bool +Settings::get_user_value(const Glib::ustring& key, Glib::VariantBase& value) const { const auto g_value = g_settings_get_user_value(const_cast(gobj()), key.c_str()); - if(!g_value) + if (!g_value) return false; value.init(g_value, false /* don't take a reference */); return true; } -void Settings::get_default_value(const Glib::ustring& key, Glib::VariantBase& value) const +void +Settings::get_default_value(const Glib::ustring& key, Glib::VariantBase& value) const { const auto g_value = g_settings_get_default_value(const_cast(gobj()), key.c_str()); - if(!g_value) + if (!g_value) return; value.init(g_value, false /* don't take a reference */); } -void Settings::bind(const Glib::ustring& key, - const Glib::PropertyProxy_Base& property_proxy, - SettingsBindFlags flags) +void +Settings::bind( + const Glib::ustring& key, const Glib::PropertyProxy_Base& property_proxy, SettingsBindFlags flags) { - bind(key, property_proxy.get_object(), property_proxy.get_name(), flags); + bind(key, property_proxy.get_object(), property_proxy.get_name(), flags); } -void Settings::bind_writable(const Glib::ustring& key, - const Glib::PropertyProxy_Base& property_proxy, - bool inverted) +void +Settings::bind_writable( + const Glib::ustring& key, const Glib::PropertyProxy_Base& property_proxy, bool inverted) { - bind_writable(key, property_proxy.get_object(), property_proxy.get_name(), inverted); + bind_writable(key, property_proxy.get_object(), property_proxy.get_name(), inverted); } _DEPRECATE_IFDEF_START G_GNUC_BEGIN_IGNORE_DEPRECATIONS -std::vector Settings::list_schemas() +std::vector +Settings::list_schemas() { - return Glib::ArrayHandler::array_to_vector(g_settings_list_schemas(), Glib::OWNERSHIP_NONE); + return Glib::ArrayHandler::array_to_vector( + g_settings_list_schemas(), Glib::OWNERSHIP_NONE); } G_GNUC_END_IGNORE_DEPRECATIONS _DEPRECATE_IFDEF_END - } diff --git a/gio/src/settingsschema.ccg b/gio/src/settingsschema.ccg index a8ef5d43..27d1a1ee 100644 --- a/gio/src/settingsschema.ccg +++ b/gio/src/settingsschema.ccg @@ -20,4 +20,4 @@ namespace Gio { -} //namespace Gio +} // namespace Gio diff --git a/gio/src/settingsschemakey.ccg b/gio/src/settingsschemakey.ccg index a8ef5d43..27d1a1ee 100644 --- a/gio/src/settingsschemakey.ccg +++ b/gio/src/settingsschemakey.ccg @@ -20,4 +20,4 @@ namespace Gio { -} //namespace Gio +} // namespace Gio diff --git a/gio/src/settingsschemasource.ccg b/gio/src/settingsschemasource.ccg index a8ef5d43..27d1a1ee 100644 --- a/gio/src/settingsschemasource.ccg +++ b/gio/src/settingsschemasource.ccg @@ -20,4 +20,4 @@ namespace Gio { -} //namespace Gio +} // namespace Gio diff --git a/gio/src/simpleaction.ccg b/gio/src/simpleaction.ccg index 2b91ecf1..42b236e7 100644 --- a/gio/src/simpleaction.ccg +++ b/gio/src/simpleaction.ccg @@ -22,32 +22,36 @@ namespace Gio { -SimpleAction::SimpleAction(const Glib::ustring& name) -: - _CONSTRUCT("name", name.c_str()) -{} +SimpleAction::SimpleAction(const Glib::ustring& name) : _CONSTRUCT("name", name.c_str()) +{ +} SimpleAction::SimpleAction(const Glib::ustring& name, const Glib::VariantBase& state) -: - _CONSTRUCT("name", name.c_str(), "state", const_cast((state).gobj())) -{} +: _CONSTRUCT("name", name.c_str(), "state", const_cast((state).gobj())) +{ +} -Glib::RefPtr SimpleAction::create_bool(const Glib::ustring& name, bool state) +Glib::RefPtr +SimpleAction::create_bool(const Glib::ustring& name, bool state) { - //We must provide some initial state, as a way to specify the type of the state. + // We must provide some initial state, as a way to specify the type of the state. return create(name, Glib::Variant::create(state)); } - -Glib::RefPtr SimpleAction::create_radio_string(const Glib::ustring& name, const Glib::ustring& initial_state) +Glib::RefPtr +SimpleAction::create_radio_string(const Glib::ustring& name, const Glib::ustring& initial_state) { - //See https://developer.gnome.org/glib/stable/gvariant-format-strings.html#gvariant-format-strings-strings - return create(name, Glib::VARIANT_TYPE_STRING, Glib::Variant::create(initial_state)); + // See + // https://developer.gnome.org/glib/stable/gvariant-format-strings.html#gvariant-format-strings-strings + return create( + name, Glib::VARIANT_TYPE_STRING, Glib::Variant::create(initial_state)); } -Glib::RefPtr SimpleAction::create_radio_integer(const Glib::ustring& name, gint32 initial_state) +Glib::RefPtr +SimpleAction::create_radio_integer(const Glib::ustring& name, gint32 initial_state) { - //See https://developer.gnome.org/glib/stable/gvariant-format-strings.html#gvariant-format-strings-numeric-types + // See + // https://developer.gnome.org/glib/stable/gvariant-format-strings.html#gvariant-format-strings-numeric-types return create(name, Glib::VARIANT_TYPE_INT32, Glib::Variant::create(initial_state)); } diff --git a/gio/src/simpleactiongroup.ccg b/gio/src/simpleactiongroup.ccg index cd3e297a..3a802518 100644 --- a/gio/src/simpleactiongroup.ccg +++ b/gio/src/simpleactiongroup.ccg @@ -21,4 +21,4 @@ namespace Gio { -}// namespace Gio +} // namespace Gio diff --git a/gio/src/simplepermission.ccg b/gio/src/simplepermission.ccg index c22ac8b2..e627cda1 100644 --- a/gio/src/simplepermission.ccg +++ b/gio/src/simplepermission.ccg @@ -17,7 +17,6 @@ #include - namespace Gio { } // namespace Gio diff --git a/gio/src/socket.ccg b/gio/src/socket.ccg index a7e0ff69..6dfd71ee 100644 --- a/gio/src/socket.ccg +++ b/gio/src/socket.ccg @@ -27,86 +27,92 @@ namespace Gio { Socket::Socket(SocketFamily family, SocketType type, SocketProtocol protocol, - const Glib::RefPtr& cancellable) -: - _CONSTRUCT("family", int(family), "type", int(type), "protocol", int(protocol)) + const Glib::RefPtr& cancellable) +: _CONSTRUCT("family", int(family), "type", int(type), "protocol", int(protocol)) { init(cancellable); } -Socket::Socket(int fd, const Glib::RefPtr& cancellable) -: - _CONSTRUCT("fd", fd) +Socket::Socket(int fd, const Glib::RefPtr& cancellable) : _CONSTRUCT("fd", fd) { init(cancellable); } // static -Glib::RefPtr Socket::create(SocketFamily family, SocketType type, SocketProtocol protocol, - const Glib::RefPtr& cancellable) +Glib::RefPtr +Socket::create(SocketFamily family, SocketType type, SocketProtocol protocol, + const Glib::RefPtr& cancellable) { return Glib::RefPtr(new Socket(family, type, protocol, cancellable)); } // static -Glib::RefPtr Socket::create_from_fd(int fd, const Glib::RefPtr& cancellable) +Glib::RefPtr +Socket::create_from_fd(int fd, const Glib::RefPtr& cancellable) { return Glib::RefPtr(new Socket(fd, cancellable)); } -gssize Socket::receive_from(Glib::RefPtr& address, char* buffer, gsize size, const Glib::RefPtr& cancellable) +gssize +Socket::receive_from(Glib::RefPtr& address, char* buffer, gsize size, + const Glib::RefPtr& cancellable) { GError* gerror = nullptr; GSocketAddress* caddr = nullptr; - auto retvalue = g_socket_receive_from(gobj(), &caddr, buffer, size, const_cast(Glib::unwrap(cancellable)), &(gerror)); - if(gerror) + auto retvalue = g_socket_receive_from( + gobj(), &caddr, buffer, size, const_cast(Glib::unwrap(cancellable)), &(gerror)); + if (gerror) ::Glib::Error::throw_exception(gerror); if (caddr) - address = Glib::wrap (caddr); + address = Glib::wrap(caddr); return retvalue; } -gssize Socket::receive_from(Glib::RefPtr& address, char* buffer, gsize size) +gssize +Socket::receive_from(Glib::RefPtr& address, char* buffer, gsize size) { GError* gerror = nullptr; GSocketAddress* caddr = nullptr; auto retvalue = g_socket_receive_from(gobj(), &caddr, buffer, size, nullptr, &(gerror)); - if(gerror) + if (gerror) ::Glib::Error::throw_exception(gerror); if (caddr) - address = Glib::wrap (caddr); + address = Glib::wrap(caddr); return retvalue; } -gssize Socket::receive_with_blocking(gchar* buffer, gsize size, bool blocking, - const Glib::RefPtr& cancellable) +gssize +Socket::receive_with_blocking( + gchar* buffer, gsize size, bool blocking, const Glib::RefPtr& cancellable) { GError* gerror = nullptr; - const auto retvalue = g_socket_receive_with_blocking(gobj(), buffer, size, - blocking, Glib::unwrap(cancellable), &(gerror)); - if(gerror) + const auto retvalue = g_socket_receive_with_blocking( + gobj(), buffer, size, blocking, Glib::unwrap(cancellable), &(gerror)); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } -gssize Socket::send_with_blocking(gchar* buffer, gsize size, bool blocking, - const Glib::RefPtr& cancellable) +gssize +Socket::send_with_blocking( + gchar* buffer, gsize size, bool blocking, const Glib::RefPtr& cancellable) { GError* gerror = nullptr; - const auto retvalue = g_socket_send_with_blocking(gobj(), buffer, size, - blocking, Glib::unwrap(cancellable), &(gerror)); - if(gerror) + const auto retvalue = g_socket_send_with_blocking( + gobj(), buffer, size, blocking, Glib::unwrap(cancellable), &(gerror)); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } -Glib::RefPtr Socket::create_source(Glib::IOCondition condition, const Glib::RefPtr& cancellable) +Glib::RefPtr +Socket::create_source(Glib::IOCondition condition, const Glib::RefPtr& cancellable) { // The corresponding unreference() takes place in the dtor // of the Glib::RefPtr object below. diff --git a/gio/src/socketaddressenumerator.ccg b/gio/src/socketaddressenumerator.ccg index d7aca9b6..405773f5 100644 --- a/gio/src/socketaddressenumerator.ccg +++ b/gio/src/socketaddressenumerator.ccg @@ -22,21 +22,20 @@ #include #include "slot_async.h" -namespace Gio { +namespace Gio +{ - void - SocketAddressEnumerator::next_async(const Glib::RefPtr& cancellable, - const SlotAsyncReady& slot) - { - // Create a copy of the slot. - // A pointer to it will be passed through the callback's data parameter - // and deleted in the callback. - auto slot_copy = new SlotAsyncReady(slot); +void +SocketAddressEnumerator::next_async( + const Glib::RefPtr& cancellable, const SlotAsyncReady& slot) +{ + // Create a copy of the slot. + // A pointer to it will be passed through the callback's data parameter + // and deleted in the callback. + auto slot_copy = new SlotAsyncReady(slot); - g_socket_address_enumerator_next_async(gobj(), - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); - } + g_socket_address_enumerator_next_async( + gobj(), Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); +} } // namespace Gio diff --git a/gio/src/socketclient.ccg b/gio/src/socketclient.ccg index e2793826..c3ec6f05 100644 --- a/gio/src/socketclient.ccg +++ b/gio/src/socketclient.ccg @@ -26,143 +26,106 @@ namespace Gio void SocketClient::connect_async(const Glib::RefPtr& connectable, - const Glib::RefPtr& cancellable, - const SlotAsyncReady& slot) + const Glib::RefPtr& cancellable, const SlotAsyncReady& slot) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_socket_client_connect_async (gobj(), - connectable->gobj (), - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_socket_client_connect_async( + gobj(), connectable->gobj(), Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } void -SocketClient::connect_async(const Glib::RefPtr& connectable, - const SlotAsyncReady& slot) +SocketClient::connect_async( + const Glib::RefPtr& connectable, const SlotAsyncReady& slot) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_socket_client_connect_async (gobj(), - connectable->gobj (), - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_socket_client_connect_async( + gobj(), connectable->gobj(), nullptr, &SignalProxy_async_callback, slot_copy); } void -SocketClient::connect_to_host_async(const Glib::ustring& host_and_port, - guint16 default_port, - const Glib::RefPtr& cancellable, - const SlotAsyncReady& slot) +SocketClient::connect_to_host_async(const Glib::ustring& host_and_port, guint16 default_port, + const Glib::RefPtr& cancellable, const SlotAsyncReady& slot) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_socket_client_connect_to_host_async (gobj(), - host_and_port.c_str (), - default_port, - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_socket_client_connect_to_host_async(gobj(), host_and_port.c_str(), default_port, + Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } void -SocketClient::connect_to_host_async(const Glib::ustring& host_and_port, - guint16 default_port, - const SlotAsyncReady& slot) +SocketClient::connect_to_host_async( + const Glib::ustring& host_and_port, guint16 default_port, const SlotAsyncReady& slot) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_socket_client_connect_to_host_async (gobj(), - host_and_port.c_str (), - default_port, - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_socket_client_connect_to_host_async( + gobj(), host_and_port.c_str(), default_port, nullptr, &SignalProxy_async_callback, slot_copy); } void -SocketClient::connect_to_service_async(const Glib::ustring& domain, - const Glib::ustring& service, - const Glib::RefPtr& cancellable, - const SlotAsyncReady& slot) +SocketClient::connect_to_service_async(const Glib::ustring& domain, const Glib::ustring& service, + const Glib::RefPtr& cancellable, const SlotAsyncReady& slot) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_socket_client_connect_to_service_async (gobj(), - domain.c_str (), - service.c_str (), - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_socket_client_connect_to_service_async(gobj(), domain.c_str(), service.c_str(), + Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } void -SocketClient::connect_to_service_async(const Glib::ustring& domain, - const Glib::ustring& service, - const SlotAsyncReady& slot) +SocketClient::connect_to_service_async( + const Glib::ustring& domain, const Glib::ustring& service, const SlotAsyncReady& slot) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_socket_client_connect_to_service_async (gobj(), - domain.c_str (), - service.c_str (), - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_socket_client_connect_to_service_async( + gobj(), domain.c_str(), service.c_str(), nullptr, &SignalProxy_async_callback, slot_copy); } void SocketClient::connect_to_uri_async(const Glib::ustring& uri, guint16 default_port, - const Glib::RefPtr& cancellable, - const SlotAsyncReady& slot) + const Glib::RefPtr& cancellable, const SlotAsyncReady& slot) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_socket_client_connect_to_uri_async (gobj(), - uri.c_str(), default_port, - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_socket_client_connect_to_uri_async(gobj(), uri.c_str(), default_port, Glib::unwrap(cancellable), + &SignalProxy_async_callback, slot_copy); } void -SocketClient::connect_to_uri_async(const Glib::ustring& uri, guint16 default_port, - const SlotAsyncReady& slot) +SocketClient::connect_to_uri_async( + const Glib::ustring& uri, guint16 default_port, const SlotAsyncReady& slot) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_socket_client_connect_to_uri_async (gobj(), - uri.c_str(), default_port, - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_socket_client_connect_to_uri_async( + gobj(), uri.c_str(), default_port, nullptr, &SignalProxy_async_callback, slot_copy); } - } // namespace Gio diff --git a/gio/src/socketconnectable.ccg b/gio/src/socketconnectable.ccg index 27f8f0c1..0f94c186 100644 --- a/gio/src/socketconnectable.ccg +++ b/gio/src/socketconnectable.ccg @@ -19,5 +19,6 @@ #include -namespace Gio { +namespace Gio +{ } // namespace Gio diff --git a/gio/src/socketconnection.ccg b/gio/src/socketconnection.ccg index fcda9954..4c71d8f2 100644 --- a/gio/src/socketconnection.ccg +++ b/gio/src/socketconnection.ccg @@ -25,29 +25,22 @@ namespace Gio void SocketConnection::connect_async(const Glib::RefPtr& address, - const SlotAsyncReady& slot, - const Glib::RefPtr& cancellable) + const SlotAsyncReady& slot, const Glib::RefPtr& cancellable) { auto slot_copy = new SlotAsyncReady(slot); - g_socket_connection_connect_async(gobj(), - Glib::unwrap(address), - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_socket_connection_connect_async(gobj(), Glib::unwrap(address), Glib::unwrap(cancellable), + &SignalProxy_async_callback, slot_copy); } void -SocketConnection::connect_async(const Glib::RefPtr& address, - const SlotAsyncReady& slot) +SocketConnection::connect_async( + const Glib::RefPtr& address, const SlotAsyncReady& slot) { auto slot_copy = new SlotAsyncReady(slot); - g_socket_connection_connect_async(gobj(), - Glib::unwrap(address), - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_socket_connection_connect_async( + gobj(), Glib::unwrap(address), nullptr, &SignalProxy_async_callback, slot_copy); } } // namespace Gio diff --git a/gio/src/socketlistener.ccg b/gio/src/socketlistener.ccg index afcad2cd..08ba099e 100644 --- a/gio/src/socketlistener.ccg +++ b/gio/src/socketlistener.ccg @@ -23,312 +23,282 @@ namespace Gio { -bool SocketListener::add_socket(const Glib::RefPtr& socket) +bool +SocketListener::add_socket(const Glib::RefPtr& socket) { GError* gerror = nullptr; - const bool retval = g_socket_listener_add_socket(gobj(), - Glib::unwrap(socket), - nullptr, - &gerror); + const bool retval = g_socket_listener_add_socket(gobj(), Glib::unwrap(socket), nullptr, &gerror); - if(gerror) + if (gerror) ::Glib::Error::throw_exception(gerror); return retval; } - -bool SocketListener::add_address(const Glib::RefPtr& address, SocketType type, SocketProtocol protocol, const Glib::RefPtr& source_object, Glib::RefPtr& effective_address) +bool +SocketListener::add_address(const Glib::RefPtr& address, SocketType type, + SocketProtocol protocol, const Glib::RefPtr& source_object, + Glib::RefPtr& effective_address) { GError* gerror = nullptr; - GSocketAddress *retaddr = nullptr; - const bool retval = g_socket_listener_add_address (gobj(), - Glib::unwrap(address), - static_cast(type), - static_cast(protocol), - Glib::unwrap(source_object), - &retaddr, - &gerror); - if(gerror) + GSocketAddress* retaddr = nullptr; + const bool retval = + g_socket_listener_add_address(gobj(), Glib::unwrap(address), static_cast(type), + static_cast(protocol), Glib::unwrap(source_object), &retaddr, &gerror); + if (gerror) ::Glib::Error::throw_exception(gerror); - if(retaddr) + if (retaddr) effective_address = Glib::wrap(retaddr); return retval; } -bool SocketListener::add_address(const Glib::RefPtr& address, SocketType type, SocketProtocol protocol, Glib::RefPtr& effective_address) +bool +SocketListener::add_address(const Glib::RefPtr& address, SocketType type, + SocketProtocol protocol, Glib::RefPtr& effective_address) { GError* gerror = nullptr; - GSocketAddress *retaddr = nullptr; - const bool retval = g_socket_listener_add_address (gobj(), - Glib::unwrap(address), - static_cast(type), - static_cast(protocol), - nullptr, - &retaddr, - &gerror); - if(gerror) + GSocketAddress* retaddr = nullptr; + const bool retval = + g_socket_listener_add_address(gobj(), Glib::unwrap(address), static_cast(type), + static_cast(protocol), nullptr, &retaddr, &gerror); + if (gerror) ::Glib::Error::throw_exception(gerror); - if(retaddr) + if (retaddr) effective_address = Glib::wrap(retaddr); return retval; } - -bool SocketListener::add_inet_port(guint16 port) +bool +SocketListener::add_inet_port(guint16 port) { GError* gerror = nullptr; const bool retvalue = g_socket_listener_add_inet_port(gobj(), port, nullptr, &gerror); - if(gerror) + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } - -guint16 SocketListener::add_any_inet_port() +guint16 +SocketListener::add_any_inet_port() { GError* gerror = nullptr; const auto retvalue = g_socket_listener_add_any_inet_port(gobj(), nullptr, &gerror); - if(gerror) + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } - -Glib::RefPtr SocketListener::accept_socket(Glib::RefPtr& source_object, const Glib::RefPtr& cancellable) +Glib::RefPtr +SocketListener::accept_socket( + Glib::RefPtr& source_object, const Glib::RefPtr& cancellable) { GError* gerror = nullptr; - GObject *retobj = nullptr; - auto retvalue = g_socket_listener_accept_socket(gobj(), - &retobj, - Glib::unwrap(cancellable), - &gerror); - if(gerror) + GObject* retobj = nullptr; + auto retvalue = + g_socket_listener_accept_socket(gobj(), &retobj, Glib::unwrap(cancellable), &gerror); + if (gerror) ::Glib::Error::throw_exception(gerror); - if(retobj) + if (retobj) source_object = Glib::wrap(retobj); return Glib::wrap(retvalue); } -Glib::RefPtr SocketListener::accept_socket(Glib::RefPtr& source_object) +Glib::RefPtr +SocketListener::accept_socket(Glib::RefPtr& source_object) { GError* gerror = nullptr; - GObject *retobj = nullptr; - auto retvalue = g_socket_listener_accept_socket(gobj(), - &retobj, - nullptr, - &gerror); - if(gerror) + GObject* retobj = nullptr; + auto retvalue = g_socket_listener_accept_socket(gobj(), &retobj, nullptr, &gerror); + if (gerror) ::Glib::Error::throw_exception(gerror); - if(retobj) + if (retobj) source_object = Glib::wrap(retobj); return Glib::wrap(retvalue); } -Glib::RefPtr SocketListener::accept_socket(const Glib::RefPtr& cancellable) +Glib::RefPtr +SocketListener::accept_socket(const Glib::RefPtr& cancellable) { GError* gerror = nullptr; - auto retvalue = g_socket_listener_accept_socket(gobj(), - nullptr, - Glib::unwrap(cancellable), - &gerror); - if(gerror) + auto retvalue = + g_socket_listener_accept_socket(gobj(), nullptr, Glib::unwrap(cancellable), &gerror); + if (gerror) ::Glib::Error::throw_exception(gerror); return Glib::wrap(retvalue); } -Glib::RefPtr SocketListener::accept_socket() +Glib::RefPtr +SocketListener::accept_socket() { GError* gerror = nullptr; - auto retvalue = g_socket_listener_accept_socket(gobj(), - nullptr, - nullptr, - &gerror); - if(gerror) + auto retvalue = g_socket_listener_accept_socket(gobj(), nullptr, nullptr, &gerror); + if (gerror) ::Glib::Error::throw_exception(gerror); return Glib::wrap(retvalue); } - -void SocketListener::accept_socket_async(const Glib::RefPtr& cancellable, const SlotAsyncReady& slot) +void +SocketListener::accept_socket_async( + const Glib::RefPtr& cancellable, const SlotAsyncReady& slot) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_socket_listener_accept_socket_async(gobj(), - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_socket_listener_accept_socket_async( + gobj(), Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } -void SocketListener::accept_socket_async(const SlotAsyncReady& slot) +void +SocketListener::accept_socket_async(const SlotAsyncReady& slot) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_socket_listener_accept_socket_async(gobj(), - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_socket_listener_accept_socket_async(gobj(), nullptr, &SignalProxy_async_callback, slot_copy); } -Glib::RefPtr SocketListener::accept_socket_finish(const Glib::RefPtr& result, Glib::RefPtr& source_object) +Glib::RefPtr +SocketListener::accept_socket_finish( + const Glib::RefPtr& result, Glib::RefPtr& source_object) { GError* gerror = nullptr; - GObject *retobj = nullptr; - auto retvalue = g_socket_listener_accept_socket_finish(gobj(), - Glib::unwrap(result), - &retobj, - &gerror); - if(gerror) + GObject* retobj = nullptr; + auto retvalue = + g_socket_listener_accept_socket_finish(gobj(), Glib::unwrap(result), &retobj, &gerror); + if (gerror) ::Glib::Error::throw_exception(gerror); - if(retobj) + if (retobj) source_object = Glib::wrap(retobj); return Glib::wrap(retvalue); } -Glib::RefPtr SocketListener::accept_socket_finish(const Glib::RefPtr& result) +Glib::RefPtr +SocketListener::accept_socket_finish(const Glib::RefPtr& result) { GError* gerror = nullptr; - auto retvalue = g_socket_listener_accept_socket_finish(gobj(), - Glib::unwrap(result), - nullptr, - &gerror); - if(gerror) + auto retvalue = + g_socket_listener_accept_socket_finish(gobj(), Glib::unwrap(result), nullptr, &gerror); + if (gerror) ::Glib::Error::throw_exception(gerror); return Glib::wrap(retvalue); } - -Glib::RefPtr SocketListener::accept(Glib::RefPtr& source_object, const Glib::RefPtr& cancellable) +Glib::RefPtr +SocketListener::accept( + Glib::RefPtr& source_object, const Glib::RefPtr& cancellable) { GError* gerror = nullptr; - GObject *retobj = nullptr; - auto retvalue = g_socket_listener_accept(gobj(), - &retobj, - Glib::unwrap(cancellable), - &gerror); - if(gerror) + GObject* retobj = nullptr; + auto retvalue = g_socket_listener_accept(gobj(), &retobj, Glib::unwrap(cancellable), &gerror); + if (gerror) ::Glib::Error::throw_exception(gerror); - if(retobj) + if (retobj) source_object = Glib::wrap(retobj); return Glib::wrap(retvalue); } -Glib::RefPtr SocketListener::accept(Glib::RefPtr& source_object) +Glib::RefPtr +SocketListener::accept(Glib::RefPtr& source_object) { GError* gerror = nullptr; - GObject *retobj = nullptr; - auto retvalue = g_socket_listener_accept(gobj(), - &retobj, - nullptr, - &gerror); - if(gerror) + GObject* retobj = nullptr; + auto retvalue = g_socket_listener_accept(gobj(), &retobj, nullptr, &gerror); + if (gerror) ::Glib::Error::throw_exception(gerror); - if(retobj) + if (retobj) source_object = Glib::wrap(retobj); return Glib::wrap(retvalue); } -Glib::RefPtr SocketListener::accept(const Glib::RefPtr& cancellable) +Glib::RefPtr +SocketListener::accept(const Glib::RefPtr& cancellable) { GError* gerror = nullptr; - auto retvalue = g_socket_listener_accept(gobj(), - nullptr, - Glib::unwrap(cancellable), - &gerror); - if(gerror) + auto retvalue = g_socket_listener_accept(gobj(), nullptr, Glib::unwrap(cancellable), &gerror); + if (gerror) ::Glib::Error::throw_exception(gerror); return Glib::wrap(retvalue); } -Glib::RefPtr SocketListener::accept() +Glib::RefPtr +SocketListener::accept() { GError* gerror = nullptr; - auto retvalue = g_socket_listener_accept(gobj(), - nullptr, - nullptr, - &gerror); - if(gerror) + auto retvalue = g_socket_listener_accept(gobj(), nullptr, nullptr, &gerror); + if (gerror) ::Glib::Error::throw_exception(gerror); return Glib::wrap(retvalue); } - -void SocketListener::accept_async(const SlotAsyncReady& slot) +void +SocketListener::accept_async(const SlotAsyncReady& slot) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_socket_listener_accept_async(gobj(), - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_socket_listener_accept_async(gobj(), nullptr, &SignalProxy_async_callback, slot_copy); } -void SocketListener::accept_async(const Glib::RefPtr& cancellable, const SlotAsyncReady& slot) +void +SocketListener::accept_async( + const Glib::RefPtr& cancellable, const SlotAsyncReady& slot) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_socket_listener_accept_async(gobj(), - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_socket_listener_accept_async( + gobj(), Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } -Glib::RefPtr SocketListener::accept_finish(const Glib::RefPtr& result, Glib::RefPtr& source_object) +Glib::RefPtr +SocketListener::accept_finish( + const Glib::RefPtr& result, Glib::RefPtr& source_object) { GError* gerror = nullptr; - GObject *retobj = nullptr; - auto retvalue = g_socket_listener_accept_finish(gobj(), - Glib::unwrap(result), - &retobj, - &gerror); - if(gerror) + GObject* retobj = nullptr; + auto retvalue = g_socket_listener_accept_finish(gobj(), Glib::unwrap(result), &retobj, &gerror); + if (gerror) ::Glib::Error::throw_exception(gerror); - if(retobj) + if (retobj) source_object = Glib::wrap(retobj); return Glib::wrap(retvalue); } -Glib::RefPtr SocketListener::accept_finish(const Glib::RefPtr& result) +Glib::RefPtr +SocketListener::accept_finish(const Glib::RefPtr& result) { GError* gerror = nullptr; - auto retvalue = g_socket_listener_accept_finish(gobj(), - Glib::unwrap(result), - nullptr, - &gerror); - if(gerror) + auto retvalue = g_socket_listener_accept_finish(gobj(), Glib::unwrap(result), nullptr, &gerror); + if (gerror) ::Glib::Error::throw_exception(gerror); return Glib::wrap(retvalue); diff --git a/gio/src/srvtarget.ccg b/gio/src/srvtarget.ccg index 10c0e4ed..931000cb 100644 --- a/gio/src/srvtarget.ccg +++ b/gio/src/srvtarget.ccg @@ -23,4 +23,4 @@ namespace Gio { -} //namespace Gio +} // namespace Gio diff --git a/gio/src/themedicon.ccg b/gio/src/themedicon.ccg index af938ee9..e9a7f301 100644 --- a/gio/src/themedicon.ccg +++ b/gio/src/themedicon.ccg @@ -21,8 +21,8 @@ namespace Gio { ThemedIcon::ThemedIcon(const std::string& iconname, bool use_default_fallbacks) -: - _CONSTRUCT("name", iconname.c_str(), "use-default-fallbacks", gboolean(use_default_fallbacks)) -{} +: _CONSTRUCT("name", iconname.c_str(), "use-default-fallbacks", gboolean(use_default_fallbacks)) +{ +} -} //namespace Gio +} // namespace Gio diff --git a/gio/src/tlscertificate.ccg b/gio/src/tlscertificate.ccg index dd68cadb..448757fb 100644 --- a/gio/src/tlscertificate.ccg +++ b/gio/src/tlscertificate.ccg @@ -25,7 +25,7 @@ namespace Gio Glib::RefPtr TlsCertificate::create_from_pem(const std::string& data, gssize length) { - return Glib::RefPtr( new TlsCertificate(data, length) ); + return Glib::RefPtr(new TlsCertificate(data, length)); } } // namesapce Gio diff --git a/gio/src/tlsclientconnection.ccg b/gio/src/tlsclientconnection.ccg index 30333643..e18f6c73 100644 --- a/gio/src/tlsclientconnection.ccg +++ b/gio/src/tlsclientconnection.ccg @@ -23,6 +23,7 @@ namespace Gio TlsClientConnection::TlsClientConnection(GTlsClientConnection* castitem) : TlsConnection(G_TLS_CONNECTION(castitem)) -{} +{ +} } // namespace Gio diff --git a/gio/src/tlsserverconnection.ccg b/gio/src/tlsserverconnection.ccg index c5d86a01..4f97609e 100644 --- a/gio/src/tlsserverconnection.ccg +++ b/gio/src/tlsserverconnection.ccg @@ -22,6 +22,7 @@ namespace Gio TlsServerConnection::TlsServerConnection(GTlsServerConnection* castitem) : TlsConnection(G_TLS_CONNECTION(castitem)) -{} +{ +} } // namespace Gio diff --git a/gio/src/unixconnection.ccg b/gio/src/unixconnection.ccg index 597dd8af..20a3cdeb 100644 --- a/gio/src/unixconnection.ccg +++ b/gio/src/unixconnection.ccg @@ -24,37 +24,33 @@ namespace Gio { -void UnixConnection::receive_credentials_async(const SlotAsyncReady& slot, - const Glib::RefPtr& cancellable) +void +UnixConnection::receive_credentials_async( + const SlotAsyncReady& slot, const Glib::RefPtr& cancellable) { auto slot_copy = new SlotAsyncReady(slot); - g_unix_connection_receive_credentials_async(gobj(), - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_unix_connection_receive_credentials_async( + gobj(), Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } -void UnixConnection::receive_credentials_async(const SlotAsyncReady& slot) +void +UnixConnection::receive_credentials_async(const SlotAsyncReady& slot) { auto slot_copy = new SlotAsyncReady(slot); - g_unix_connection_receive_credentials_async(gobj(), - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_unix_connection_receive_credentials_async( + gobj(), nullptr, &SignalProxy_async_callback, slot_copy); } void -UnixConnection::send_credentials_async(const SlotAsyncReady& slot, - const Glib::RefPtr& cancellable) +UnixConnection::send_credentials_async( + const SlotAsyncReady& slot, const Glib::RefPtr& cancellable) { auto slot_copy = new SlotAsyncReady(slot); - g_unix_connection_send_credentials_async(gobj(), - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_unix_connection_send_credentials_async( + gobj(), Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } void @@ -63,10 +59,7 @@ UnixConnection::send_credentials_async(const SlotAsyncReady& slot) { auto slot_copy = new SlotAsyncReady(slot); - g_unix_connection_send_credentials_async(gobj(), - nullptr, - &SignalProxy_async_callback, - slot_copy); + g_unix_connection_send_credentials_async(gobj(), nullptr, &SignalProxy_async_callback, slot_copy); } } // namespace Gio diff --git a/gio/src/unixfdlist.ccg b/gio/src/unixfdlist.ccg index c4a65087..92aef941 100644 --- a/gio/src/unixfdlist.ccg +++ b/gio/src/unixfdlist.ccg @@ -22,8 +22,7 @@ namespace Gio { UnixFDList::UnixFDList(const Glib::ArrayHandle& fds) -: - // Mark this class as non-derived to allow C++ vfuncs to be skipped. +: // Mark this class as non-derived to allow C++ vfuncs to be skipped. Glib::ObjectBase(nullptr), // g_unix_fd_list_new_from_array() must be called. // Its parameters don't correspond to properties. @@ -35,8 +34,7 @@ UnixFDList::UnixFDList(const Glib::ArrayHandle& fds) } UnixFDList::UnixFDList(const Glib::ArrayHandle& fds, int n_fds) -: - // Mark this class as non-derived to allow C++ vfuncs to be skipped. +: // Mark this class as non-derived to allow C++ vfuncs to be skipped. Glib::ObjectBase(nullptr), // g_unix_fd_list_new_from_array() must be called. // Its parameters don't correspond to properties. @@ -47,7 +45,8 @@ UnixFDList::UnixFDList(const Glib::ArrayHandle& fds, int n_fds) { } -const Glib::ArrayHandle UnixFDList::peek_fds() const +const Glib::ArrayHandle +UnixFDList::peek_fds() const { int length = 0; const auto fds = g_unix_fd_list_peek_fds(const_cast(gobj()), &length); @@ -56,7 +55,8 @@ const Glib::ArrayHandle UnixFDList::peek_fds() const return Glib::ArrayHandle(fds, length, Glib::OWNERSHIP_NONE); } -Glib::ArrayHandle UnixFDList::steal_fds() +Glib::ArrayHandle +UnixFDList::steal_fds() { int length = 0; const auto fds = g_unix_fd_list_steal_fds(gobj(), &length); diff --git a/gio/src/unixfdmessage.ccg b/gio/src/unixfdmessage.ccg index 7849a208..9d1afc26 100644 --- a/gio/src/unixfdmessage.ccg +++ b/gio/src/unixfdmessage.ccg @@ -22,7 +22,8 @@ namespace Gio { -Glib::ArrayHandle UnixFDMessage::steal_fds() +Glib::ArrayHandle +UnixFDMessage::steal_fds() { int length = 0; const auto fds = g_unix_fd_message_steal_fds(gobj(), &length); diff --git a/gio/src/unixsocketaddress.ccg b/gio/src/unixsocketaddress.ccg index 3c2eb1c8..d163b03d 100644 --- a/gio/src/unixsocketaddress.ccg +++ b/gio/src/unixsocketaddress.ccg @@ -23,10 +23,10 @@ namespace Gio { Glib::RefPtr -UnixSocketAddress::create(const std::string& path, UnixSocketAddressType type, - int path_len) +UnixSocketAddress::create(const std::string& path, UnixSocketAddressType type, int path_len) { - return Glib::wrap(reinterpret_cast(g_unix_socket_address_new_with_type(path.c_str(), path_len, static_cast(type)))); + return Glib::wrap(reinterpret_cast(g_unix_socket_address_new_with_type( + path.c_str(), path_len, static_cast(type)))); } -} //namespace Gio +} // namespace Gio diff --git a/gio/src/volume.ccg b/gio/src/volume.ccg index 00c17f6f..9d61a520 100644 --- a/gio/src/volume.ccg +++ b/gio/src/volume.ccg @@ -17,7 +17,6 @@ * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ - #include #include #include @@ -25,143 +24,127 @@ #include #include "slot_async.h" -namespace Gio { +namespace Gio +{ void -Volume::mount(const Glib::RefPtr& mount_operation, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, MountMountFlags flags) +Volume::mount(const Glib::RefPtr& mount_operation, const SlotAsyncReady& slot, + const Glib::RefPtr& cancellable, MountMountFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_volume_mount(gobj(), - static_cast(flags), - Glib::unwrap(mount_operation), - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); - + g_volume_mount(gobj(), static_cast(flags), Glib::unwrap(mount_operation), + Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } void -Volume::mount(const Glib::RefPtr& mount_operation, const SlotAsyncReady& slot, MountMountFlags flags) +Volume::mount(const Glib::RefPtr& mount_operation, const SlotAsyncReady& slot, + MountMountFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_volume_mount(gobj(), - static_cast(flags), - Glib::unwrap(mount_operation), - nullptr, // cancellable - &SignalProxy_async_callback, - slot_copy); + g_volume_mount(gobj(), static_cast(flags), Glib::unwrap(mount_operation), + nullptr, // cancellable + &SignalProxy_async_callback, slot_copy); } void Volume::mount(const Glib::RefPtr& mount_operation, MountMountFlags flags) { - g_volume_mount(gobj(), - static_cast(flags), - Glib::unwrap(mount_operation), - nullptr, // cancellable - nullptr, - nullptr); + g_volume_mount(gobj(), static_cast(flags), Glib::unwrap(mount_operation), + nullptr, // cancellable + nullptr, nullptr); } void Volume::mount(MountMountFlags flags) { - g_volume_mount(gobj(), - static_cast(flags), - nullptr, - nullptr, // cancellable - nullptr, - nullptr); + g_volume_mount(gobj(), static_cast(flags), nullptr, + nullptr, // cancellable + nullptr, nullptr); } - -void Volume::eject(const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, MountUnmountFlags flags) +void +Volume::eject( + const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, MountUnmountFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_volume_eject_with_operation(gobj(), - static_cast(flags), - nullptr, // mount_operation - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_volume_eject_with_operation(gobj(), static_cast(flags), + nullptr, // mount_operation + Glib::unwrap(cancellable), &SignalProxy_async_callback, slot_copy); } -void Volume::eject(const SlotAsyncReady& slot, MountUnmountFlags flags) +void +Volume::eject(const SlotAsyncReady& slot, MountUnmountFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_volume_eject_with_operation(gobj(), - static_cast(flags), - nullptr, // mount_operation - nullptr, // cancellable - &SignalProxy_async_callback, - slot_copy); + g_volume_eject_with_operation(gobj(), static_cast(flags), + nullptr, // mount_operation + nullptr, // cancellable + &SignalProxy_async_callback, slot_copy); } -void Volume::eject(MountUnmountFlags flags) +void +Volume::eject(MountUnmountFlags flags) { - g_volume_eject_with_operation(gobj(), - static_cast(flags), - nullptr, // mount_operation - nullptr, // cancellable - nullptr, // callback - nullptr); // data + g_volume_eject_with_operation(gobj(), static_cast(flags), + nullptr, // mount_operation + nullptr, // cancellable + nullptr, // callback + nullptr); // data } -void Volume::eject(const Glib::RefPtr& mount_operation, const SlotAsyncReady& slot, const Glib::RefPtr& cancellable, MountUnmountFlags flags) +void +Volume::eject(const Glib::RefPtr& mount_operation, const SlotAsyncReady& slot, + const Glib::RefPtr& cancellable, MountUnmountFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_volume_eject_with_operation(gobj(), - static_cast(flags), - Glib::unwrap(mount_operation), - Glib::unwrap(cancellable), - &SignalProxy_async_callback, - slot_copy); + g_volume_eject_with_operation(gobj(), static_cast(flags), + Glib::unwrap(mount_operation), Glib::unwrap(cancellable), &SignalProxy_async_callback, + slot_copy); } -void Volume::eject(const Glib::RefPtr& mount_operation, const SlotAsyncReady& slot, MountUnmountFlags flags) +void +Volume::eject(const Glib::RefPtr& mount_operation, const SlotAsyncReady& slot, + MountUnmountFlags flags) { // Create a copy of the slot. // A pointer to it will be passed through the callback's data parameter // and deleted in the callback. auto slot_copy = new SlotAsyncReady(slot); - g_volume_eject_with_operation(gobj(), - static_cast(flags), - Glib::unwrap(mount_operation), - nullptr, // cancellable - &SignalProxy_async_callback, - slot_copy); + g_volume_eject_with_operation(gobj(), static_cast(flags), + Glib::unwrap(mount_operation), + nullptr, // cancellable + &SignalProxy_async_callback, slot_copy); } -void Volume::eject(const Glib::RefPtr& mount_operation, MountUnmountFlags flags) +void +Volume::eject(const Glib::RefPtr& mount_operation, MountUnmountFlags flags) { - g_volume_eject_with_operation(gobj(), - static_cast(flags), - Glib::unwrap(mount_operation), - nullptr, // cancellable - nullptr, // callback - nullptr); // data + g_volume_eject_with_operation(gobj(), static_cast(flags), + Glib::unwrap(mount_operation), + nullptr, // cancellable + nullptr, // callback + nullptr); // data } } // namespace Gio - diff --git a/gio/src/volumemonitor.ccg b/gio/src/volumemonitor.ccg index ef4ee3f5..48ac82ab 100644 --- a/gio/src/volumemonitor.ccg +++ b/gio/src/volumemonitor.ccg @@ -20,7 +20,7 @@ #include #include -namespace Gio { - +namespace Gio +{ } // namespace Gio diff --git a/glib/src/binding.ccg b/glib/src/binding.ccg index a36b01c8..576b64f6 100644 --- a/glib/src/binding.ccg +++ b/glib/src/binding.ccg @@ -21,20 +21,19 @@ namespace { struct BindingTransformSlots { - BindingTransformSlots( - const Glib::Binding::SlotTransform& transform_to, + BindingTransformSlots(const Glib::Binding::SlotTransform& transform_to, const Glib::Binding::SlotTransform& transform_from) - : - from_source_to_target(transform_to), from_target_to_source(transform_from) - {} + : from_source_to_target(transform_to), from_target_to_source(transform_from) + { + } Glib::Binding::SlotTransform from_source_to_target; Glib::Binding::SlotTransform from_target_to_source; }; -gboolean Binding_transform_callback_common( - const GValue* from_value, GValue* to_value, - Glib::Binding::SlotTransform& the_slot) +gboolean +Binding_transform_callback_common( + const GValue* from_value, GValue* to_value, Glib::Binding::SlotTransform& the_slot) { bool result = false; try @@ -48,8 +47,9 @@ gboolean Binding_transform_callback_common( return result; } -gboolean Binding_transform_to_callback(GBinding*, - const GValue* from_value, GValue* to_value, gpointer user_data) +gboolean +Binding_transform_to_callback( + GBinding*, const GValue* from_value, GValue* to_value, gpointer user_data) { Glib::Binding::SlotTransform& the_slot = static_cast(user_data)->from_source_to_target; @@ -57,8 +57,9 @@ gboolean Binding_transform_to_callback(GBinding*, return Binding_transform_callback_common(from_value, to_value, the_slot); } -gboolean Binding_transform_from_callback(GBinding*, - const GValue* from_value, GValue* to_value, gpointer user_data) +gboolean +Binding_transform_from_callback( + GBinding*, const GValue* from_value, GValue* to_value, gpointer user_data) { Glib::Binding::SlotTransform& the_slot = static_cast(user_data)->from_target_to_source; @@ -66,7 +67,8 @@ gboolean Binding_transform_from_callback(GBinding*, return Binding_transform_callback_common(from_value, to_value, the_slot); } -void Binding_transform_callback_destroy(gpointer user_data) +void +Binding_transform_callback_destroy(gpointer user_data) { delete static_cast(user_data); } @@ -75,22 +77,19 @@ void Binding_transform_callback_destroy(gpointer user_data) namespace Glib { -//static -Glib::RefPtr Binding::bind_property_value( - const PropertyProxy_Base& source_property, - const PropertyProxy_Base& target_property, - BindingFlags flags, - const SlotTransform& transform_to, +// static +Glib::RefPtr +Binding::bind_property_value(const PropertyProxy_Base& source_property, + const PropertyProxy_Base& target_property, BindingFlags flags, const SlotTransform& transform_to, const SlotTransform& transform_from) { GBinding* binding = nullptr; if (transform_to.empty() && transform_from.empty()) { // No user-supplied transformations. - binding = g_object_bind_property( - source_property.get_object()->gobj(), source_property.get_name(), - target_property.get_object()->gobj(), target_property.get_name(), - (GBindingFlags)flags); + binding = + g_object_bind_property(source_property.get_object()->gobj(), source_property.get_name(), + target_property.get_object()->gobj(), target_property.get_name(), (GBindingFlags)flags); } else { @@ -99,13 +98,11 @@ Glib::RefPtr Binding::bind_property_value( // when Binding_transform_callback_destroy() is called. BindingTransformSlots* slots_copy = new BindingTransformSlots(transform_to, transform_from); - binding = g_object_bind_property_full( - source_property.get_object()->gobj(), source_property.get_name(), - target_property.get_object()->gobj(), target_property.get_name(), - (GBindingFlags)flags, - transform_to.empty() ? nullptr : &Binding_transform_to_callback, - transform_from.empty() ? nullptr : &Binding_transform_from_callback, - slots_copy, &Binding_transform_callback_destroy); + binding = g_object_bind_property_full(source_property.get_object()->gobj(), + source_property.get_name(), target_property.get_object()->gobj(), target_property.get_name(), + (GBindingFlags)flags, transform_to.empty() ? nullptr : &Binding_transform_to_callback, + transform_from.empty() ? nullptr : &Binding_transform_from_callback, slots_copy, + &Binding_transform_callback_destroy); } if (!binding) @@ -118,7 +115,8 @@ Glib::RefPtr Binding::bind_property_value( return Glib::RefPtr(new Binding(binding)); } -void Binding::unbind() +void +Binding::unbind() { // Call g_binding_unbind() only once. It always calls g_object_unref(). if (g_binding_get_source(gobj())) @@ -132,7 +130,8 @@ void Binding::unbind() // target object is finalized, almost like g_binding_unbind(). // But the GBinding object shall be destroyed when and only when the last // reference from a Glib::RefPtr is dropped. -void Binding::unreference() const +void +Binding::unreference() const { GBinding* const binding = const_cast(gobj()); diff --git a/glib/src/bytearray.ccg b/glib/src/bytearray.ccg index 4cf3ff16..2cb910ca 100644 --- a/glib/src/bytearray.ccg +++ b/glib/src/bytearray.ccg @@ -18,41 +18,41 @@ namespace { -extern "C" -{ +extern "C" { -int ByteArray_Compare_Data_Func(gconstpointer a, gconstpointer b, - gpointer user_data) +int +ByteArray_Compare_Data_Func(gconstpointer a, gconstpointer b, gpointer user_data) { - Glib::ByteArray::SlotCompare* slot = - static_cast(user_data); + Glib::ByteArray::SlotCompare* slot = static_cast(user_data); return (*slot)(static_cast(a), static_cast(b)); } - } - } namespace Glib { -guint ByteArray::size() const +guint +ByteArray::size() const { return gobj()->len; } -guint8* ByteArray::get_data() +guint8* +ByteArray::get_data() { return gobj()->data; } -const guint8* ByteArray::get_data() const +const guint8* +ByteArray::get_data() const { return gobj()->data; } -GType ByteArray::get_type() +GType +ByteArray::get_type() { return g_byte_array_get_type(); } diff --git a/glib/src/bytes.ccg b/glib/src/bytes.ccg index ae7270a5..0ff936ad 100644 --- a/glib/src/bytes.ccg +++ b/glib/src/bytes.ccg @@ -18,9 +18,10 @@ namespace Glib { -Glib::RefPtr Bytes::create(gconstpointer data, gsize size) +Glib::RefPtr +Bytes::create(gconstpointer data, gsize size) { - GBytes* bytes= g_bytes_new(data, size); + GBytes* bytes = g_bytes_new(data, size); return Glib::wrap(bytes); } diff --git a/glib/src/checksum.ccg b/glib/src/checksum.ccg index 9a700501..140ea792 100644 --- a/glib/src/checksum.ccg +++ b/glib/src/checksum.ccg @@ -21,8 +21,7 @@ namespace Glib { -Checksum::Checksum(ChecksumType type) -: gobject_(g_checksum_new((GChecksumType)type)) +Checksum::Checksum(ChecksumType type) : gobject_(g_checksum_new((GChecksumType)type)) { } @@ -31,17 +30,21 @@ Checksum::operator bool() const return gobject_ != nullptr; } -gssize Checksum::get_length(ChecksumType checksum_type) +gssize +Checksum::get_length(ChecksumType checksum_type) { return g_checksum_type_get_length((GChecksumType)checksum_type); } -std::string Checksum::compute_checksum(ChecksumType checksum_type, const std::string& data) +std::string +Checksum::compute_checksum(ChecksumType checksum_type, const std::string& data) { - return Glib::convert_return_gchar_ptr_to_ustring(g_compute_checksum_for_string(((GChecksumType)checksum_type), data.c_str(), data.size())); + return Glib::convert_return_gchar_ptr_to_ustring( + g_compute_checksum_for_string(((GChecksumType)checksum_type), data.c_str(), data.size())); } -void Checksum::update(const std::string& data) +void +Checksum::update(const std::string& data) { g_checksum_update(gobj(), (const guchar*)data.c_str(), data.size()); } diff --git a/glib/src/convert.ccg b/glib/src/convert.ccg index 135f135b..6a848475 100644 --- a/glib/src/convert.ccg +++ b/glib/src/convert.ccg @@ -23,17 +23,15 @@ #include - namespace Glib { /**** Glib::IConv **********************************************************/ IConv::IConv(const std::string& to_codeset, const std::string& from_codeset) -: - gobject_ (g_iconv_open(to_codeset.c_str(), from_codeset.c_str())) +: gobject_(g_iconv_open(to_codeset.c_str(), from_codeset.c_str())) { - if(gobject_ == reinterpret_cast(-1)) + if (gobject_ == reinterpret_cast(-1)) { GError* gerror = nullptr; @@ -45,61 +43,66 @@ IConv::IConv(const std::string& to_codeset, const std::string& from_codeset) // If this should ever fail we're fucked. g_assert(gerror != nullptr); - if(gerror) ::Glib::Error::throw_exception(gerror); + if (gerror) + ::Glib::Error::throw_exception(gerror); } } -IConv::IConv(GIConv gobject) -: - gobject_ (gobject) -{} +IConv::IConv(GIConv gobject) : gobject_(gobject) +{ +} IConv::~IConv() { g_iconv_close(gobject_); } -std::size_t IConv::iconv(char** inbuf, gsize* inbytes_left, char** outbuf, gsize* outbytes_left) +std::size_t +IConv::iconv(char** inbuf, gsize* inbytes_left, char** outbuf, gsize* outbytes_left) { return g_iconv(gobject_, inbuf, inbytes_left, outbuf, outbytes_left); } -void IConv::reset() +void +IConv::reset() { // Apparently iconv() on Solaris <= 7 segfaults if you pass in // NULL for anything but inbuf; work around that. (NULL outbuf // or NULL *outbuf is allowed by Unix98.) - char* outbuf = nullptr; - gsize inbytes_left = 0; + char* outbuf = nullptr; + gsize inbytes_left = 0; gsize outbytes_left = 0; g_iconv(gobject_, nullptr, &inbytes_left, &outbuf, &outbytes_left); } -std::string IConv::convert(const std::string& str) +std::string +IConv::convert(const std::string& str) { gsize bytes_written = 0; GError* gerror = nullptr; - char *const buf = g_convert_with_iconv( - str.data(), str.size(), gobject_, nullptr, &bytes_written, &gerror); + char* const buf = + g_convert_with_iconv(str.data(), str.size(), gobject_, nullptr, &bytes_written, &gerror); - if(gerror) ::Glib::Error::throw_exception(gerror); + if (gerror) + ::Glib::Error::throw_exception(gerror); - //TODO: Avoid the copy by using a perfect-forwarding std::string constructor? + // TODO: Avoid the copy by using a perfect-forwarding std::string constructor? return std::string(make_unique_ptr_gfree(buf).get(), bytes_written); } - /**** charset conversion functions *****************************************/ -bool get_charset() +bool +get_charset() { return g_get_charset(nullptr); } -bool get_charset(std::string& charset) +bool +get_charset(std::string& charset) { const char* charset_cstr = nullptr; const bool is_utf8 = g_get_charset(&charset_cstr); @@ -108,132 +111,132 @@ bool get_charset(std::string& charset) return is_utf8; } - -std::string convert(const std::string& str, - const std::string& to_codeset, - const std::string& from_codeset) +std::string +convert(const std::string& str, const std::string& to_codeset, const std::string& from_codeset) { gsize bytes_written = 0; GError* gerror = nullptr; - char *const buf = g_convert( - str.data(), str.size(), to_codeset.c_str(), from_codeset.c_str(), - nullptr, &bytes_written, &gerror); + char* const buf = g_convert(str.data(), str.size(), to_codeset.c_str(), from_codeset.c_str(), + nullptr, &bytes_written, &gerror); - if(gerror) ::Glib::Error::throw_exception(gerror); + if (gerror) + ::Glib::Error::throw_exception(gerror); - //TODO: Avoid the copy by using a perfect-forwarding std::string constructor? + // TODO: Avoid the copy by using a perfect-forwarding std::string constructor? return std::string(make_unique_ptr_gfree(buf).get(), bytes_written); } - -std::string convert_with_fallback(const std::string& str, - const std::string& to_codeset, - const std::string& from_codeset) +std::string +convert_with_fallback( + const std::string& str, const std::string& to_codeset, const std::string& from_codeset) { gsize bytes_written = 0; GError* gerror = nullptr; - char *const buf = g_convert_with_fallback( - str.data(), str.size(), to_codeset.c_str(), from_codeset.c_str(), nullptr, - nullptr, &bytes_written, &gerror); + char* const buf = g_convert_with_fallback(str.data(), str.size(), to_codeset.c_str(), + from_codeset.c_str(), nullptr, nullptr, &bytes_written, &gerror); - if(gerror) ::Glib::Error::throw_exception(gerror); + if (gerror) + ::Glib::Error::throw_exception(gerror); - //TODO: Avoid the copy by using a perfect-forwarding std::string constructor? + // TODO: Avoid the copy by using a perfect-forwarding std::string constructor? return std::string(make_unique_ptr_gfree(buf).get(), bytes_written); } - -std::string convert_with_fallback(const std::string& str, - const std::string& to_codeset, - const std::string& from_codeset, - const Glib::ustring& fallback) +std::string +convert_with_fallback(const std::string& str, const std::string& to_codeset, + const std::string& from_codeset, const Glib::ustring& fallback) { gsize bytes_written = 0; GError* gerror = nullptr; - char *const buf = g_convert_with_fallback( - str.data(), str.size(), to_codeset.c_str(), from_codeset.c_str(), - const_cast(fallback.c_str()), nullptr, &bytes_written, &gerror); + char* const buf = g_convert_with_fallback(str.data(), str.size(), to_codeset.c_str(), + from_codeset.c_str(), const_cast(fallback.c_str()), nullptr, &bytes_written, &gerror); - if(gerror) ::Glib::Error::throw_exception(gerror); + if (gerror) + ::Glib::Error::throw_exception(gerror); return std::string(make_unique_ptr_gfree(buf).get(), bytes_written); } - -Glib::ustring locale_to_utf8(const std::string& opsys_string) +Glib::ustring +locale_to_utf8(const std::string& opsys_string) { gsize bytes_written = 0; GError* gerror = nullptr; - char *const buf = g_locale_to_utf8( - opsys_string.data(), opsys_string.size(), nullptr, &bytes_written, &gerror); + char* const buf = + g_locale_to_utf8(opsys_string.data(), opsys_string.size(), nullptr, &bytes_written, &gerror); - if(gerror) ::Glib::Error::throw_exception(gerror); + if (gerror) + ::Glib::Error::throw_exception(gerror); const auto scoped_buf = make_unique_ptr_gfree(buf); return Glib::ustring(scoped_buf.get(), scoped_buf.get() + bytes_written); } - -std::string locale_from_utf8(const Glib::ustring& utf8_string) +std::string +locale_from_utf8(const Glib::ustring& utf8_string) { gsize bytes_written = 0; GError* gerror = nullptr; - char *const buf = g_locale_from_utf8( - utf8_string.data(), utf8_string.bytes(), nullptr, &bytes_written, &gerror); + char* const buf = + g_locale_from_utf8(utf8_string.data(), utf8_string.bytes(), nullptr, &bytes_written, &gerror); - if(gerror) ::Glib::Error::throw_exception(gerror); + if (gerror) + ::Glib::Error::throw_exception(gerror); return std::string(make_unique_ptr_gfree(buf).get(), bytes_written); } - -Glib::ustring filename_to_utf8(const std::string& opsys_string) +Glib::ustring +filename_to_utf8(const std::string& opsys_string) { gsize bytes_written = 0; GError* gerror = nullptr; - char *const buf = g_filename_to_utf8( - opsys_string.data(), opsys_string.size(), nullptr, &bytes_written, &gerror); + char* const buf = + g_filename_to_utf8(opsys_string.data(), opsys_string.size(), nullptr, &bytes_written, &gerror); - if(gerror) ::Glib::Error::throw_exception(gerror); + if (gerror) + ::Glib::Error::throw_exception(gerror); const auto scoped_buf = make_unique_ptr_gfree(buf); return Glib::ustring(scoped_buf.get(), scoped_buf.get() + bytes_written); } - -std::string filename_from_utf8(const Glib::ustring& utf8_string) +std::string +filename_from_utf8(const Glib::ustring& utf8_string) { gsize bytes_written = 0; GError* gerror = nullptr; - char *const buf = g_filename_from_utf8( - utf8_string.data(), utf8_string.bytes(), nullptr, &bytes_written, &gerror); + char* const buf = + g_filename_from_utf8(utf8_string.data(), utf8_string.bytes(), nullptr, &bytes_written, &gerror); - if(gerror) ::Glib::Error::throw_exception(gerror); + if (gerror) + ::Glib::Error::throw_exception(gerror); return std::string(make_unique_ptr_gfree(buf).get(), bytes_written); } - -std::string filename_from_uri(const Glib::ustring& uri, Glib::ustring& hostname) +std::string +filename_from_uri(const Glib::ustring& uri, Glib::ustring& hostname) { char* hostname_buf = nullptr; GError* gerror = nullptr; - char *const buf = g_filename_from_uri(uri.c_str(), &hostname_buf, &gerror); + char* const buf = g_filename_from_uri(uri.c_str(), &hostname_buf, &gerror); - if(gerror) ::Glib::Error::throw_exception(gerror); + if (gerror) + ::Glib::Error::throw_exception(gerror); // Let's take ownership at this point. const auto scoped_buf = make_unique_ptr_gfree(buf); - if(hostname_buf) + if (hostname_buf) hostname = make_unique_ptr_gfree(buf).get(); else hostname.erase(); @@ -241,50 +244,54 @@ std::string filename_from_uri(const Glib::ustring& uri, Glib::ustring& hostname) return std::string(scoped_buf.get()); } - -std::string filename_from_uri(const Glib::ustring& uri) +std::string +filename_from_uri(const Glib::ustring& uri) { GError* gerror = nullptr; - char *const buf = g_filename_from_uri(uri.c_str(), nullptr, &gerror); + char* const buf = g_filename_from_uri(uri.c_str(), nullptr, &gerror); - if(gerror) ::Glib::Error::throw_exception(gerror); + if (gerror) + ::Glib::Error::throw_exception(gerror); return std::string(make_unique_ptr_gfree(buf).get()); } - -Glib::ustring filename_to_uri(const std::string& filename, const Glib::ustring& hostname) +Glib::ustring +filename_to_uri(const std::string& filename, const Glib::ustring& hostname) { GError* gerror = nullptr; - char *const buf = g_filename_to_uri(filename.c_str(), hostname.c_str(), &gerror); + char* const buf = g_filename_to_uri(filename.c_str(), hostname.c_str(), &gerror); - if(gerror) ::Glib::Error::throw_exception(gerror); + if (gerror) + ::Glib::Error::throw_exception(gerror); return Glib::ustring(make_unique_ptr_gfree(buf).get()); } - -Glib::ustring filename_to_uri(const std::string& filename) +Glib::ustring +filename_to_uri(const std::string& filename) { GError* gerror = nullptr; - char *const buf = g_filename_to_uri(filename.c_str(), nullptr, &gerror); + char* const buf = g_filename_to_uri(filename.c_str(), nullptr, &gerror); - if(gerror) ::Glib::Error::throw_exception(gerror); + if (gerror) + ::Glib::Error::throw_exception(gerror); return Glib::ustring(make_unique_ptr_gfree(buf).get()); } -Glib::ustring filename_display_basename(const std::string& filename) +Glib::ustring +filename_display_basename(const std::string& filename) { - char *const buf = g_filename_display_basename(filename.c_str()); + char* const buf = g_filename_display_basename(filename.c_str()); return Glib::ustring(make_unique_ptr_gfree(buf).get()); } - -Glib::ustring filename_display_name(const std::string& filename) +Glib::ustring +filename_display_name(const std::string& filename) { - char *const buf = g_filename_display_name(filename.c_str()); + char* const buf = g_filename_display_name(filename.c_str()); return Glib::ustring(make_unique_ptr_gfree(buf).get()); } diff --git a/glib/src/date.ccg b/glib/src/date.ccg index 4dcc3f4a..4f15ddaf 100644 --- a/glib/src/date.ccg +++ b/glib/src/date.ccg @@ -35,7 +35,7 @@ Date::Date() Date::Date(Date::Day day, Date::Month month, Date::Year year) { g_date_clear(&gobject_, 1); - g_date_set_dmy(&gobject_, day, (GDateMonth) month, year); + g_date_set_dmy(&gobject_, day, (GDateMonth)month, year); } Date::Date(guint32 julian_day) @@ -44,10 +44,9 @@ Date::Date(guint32 julian_day) g_date_set_julian(&gobject_, julian_day); } -Date::Date(const GDate& castitem) -: - gobject_ (castitem) -{} +Date::Date(const GDate& castitem) : gobject_(castitem) +{ +} Date::Date(const Date& other) { @@ -56,7 +55,8 @@ Date::Date(const Date& other) g_date_set_julian(&gobject_, other.get_julian()); } -Date& Date::operator=(const Date& other) +Date& +Date::operator=(const Date& other) { if (&other != this && g_date_valid(&other.gobject_)) g_date_set_julian(&gobject_, other.get_julian()); @@ -64,243 +64,280 @@ Date& Date::operator=(const Date& other) return *this; } -void Date::clear() +void +Date::clear() { g_date_clear(&gobject_, 1); } -void Date::set_parse(const Glib::ustring& str) +void +Date::set_parse(const Glib::ustring& str) { g_date_set_parse(&gobject_, str.c_str()); } - _DEPRECATE_IFDEF_START -//Avoid a build problem in the case that std::time_t is equivalent to gint32 (GTime is also gint32) -//That would make the set_time() method overload impossible. +// Avoid a build problem in the case that std::time_t is equivalent to gint32 (GTime is also gint32) +// That would make the set_time() method overload impossible. #ifdef GLIBMM_HAVE_C_STD_TIME_T_IS_NOT_INT32 -void Date::set_time(GTime time) +void +Date::set_time(GTime time) { - //This method, and the C function g_date_set_time() that it wraps, are deprecated. + // This method, and the C function g_date_set_time() that it wraps, are deprecated. //(::time_t is used here instead of std::time_t, since the C function is declared - //with ::time_t. It's not important. The C++ standard requires that ::time_t - //and std::time_t shall be identical when both are defined.) + // with ::time_t. It's not important. The C++ standard requires that ::time_t + // and std::time_t shall be identical when both are defined.) g_date_set_time_t(&gobject_, static_cast(time)); } -#endif //GLIBMM_HAVE_C_STD_TIME_T_IS_NOT_INT32 +#endif // GLIBMM_HAVE_C_STD_TIME_T_IS_NOT_INT32 _DEPRECATE_IFDEF_END - -void Date::set_time(std::time_t timet) +void +Date::set_time(std::time_t timet) { g_date_set_time_t(&gobject_, timet); } -void Date::set_time_current() +void +Date::set_time_current() { - //As suggested in the C documentation: + // As suggested in the C documentation: g_date_set_time_t(&gobject_, time(nullptr)); } -void Date::set_time(const GTimeVal& timeval) +void +Date::set_time(const GTimeVal& timeval) { g_date_set_time_val(&gobject_, const_cast(&timeval)); } -void Date::set_month(Date::Month month) +void +Date::set_month(Date::Month month) { - g_date_set_month(&gobject_, (GDateMonth) month); + g_date_set_month(&gobject_, (GDateMonth)month); } -void Date::set_day(Date::Day day) +void +Date::set_day(Date::Day day) { g_date_set_day(&gobject_, day); } -void Date::set_year(Date::Year year) +void +Date::set_year(Date::Year year) { g_date_set_year(&gobject_, year); } -void Date::set_dmy(Date::Day day, Date::Month month, Date::Year year) +void +Date::set_dmy(Date::Day day, Date::Month month, Date::Year year) { - g_date_set_dmy(&gobject_, day, (GDateMonth) month, year); + g_date_set_dmy(&gobject_, day, (GDateMonth)month, year); } -void Date::set_julian(guint32 julian_day) +void +Date::set_julian(guint32 julian_day) { g_date_set_julian(&gobject_, julian_day); } -Date& Date::add_days(int n_days) +Date& +Date::add_days(int n_days) { - if(n_days >= 0) + if (n_days >= 0) g_date_add_days(&gobject_, n_days); else g_date_subtract_days(&gobject_, -n_days); return *this; } -Date& Date::subtract_days(int n_days) +Date& +Date::subtract_days(int n_days) { - if(n_days >= 0) + if (n_days >= 0) g_date_subtract_days(&gobject_, n_days); else g_date_add_days(&gobject_, -n_days); return *this; } -Date& Date::add_months(int n_months) +Date& +Date::add_months(int n_months) { - if(n_months >= 0) + if (n_months >= 0) g_date_add_months(&gobject_, n_months); else g_date_subtract_months(&gobject_, -n_months); return *this; } -Date& Date::subtract_months(int n_months) +Date& +Date::subtract_months(int n_months) { - if(n_months >= 0) + if (n_months >= 0) g_date_subtract_months(&gobject_, n_months); else g_date_add_months(&gobject_, -n_months); return *this; } -Date& Date::add_years(int n_years) +Date& +Date::add_years(int n_years) { - if(n_years >= 0) + if (n_years >= 0) g_date_add_years(&gobject_, n_years); else g_date_subtract_years(&gobject_, -n_years); return *this; } -Date& Date::subtract_years(int n_years) +Date& +Date::subtract_years(int n_years) { - if(n_years >= 0) + if (n_years >= 0) g_date_subtract_years(&gobject_, n_years); else g_date_add_years(&gobject_, -n_years); return *this; } -int Date::days_between(const Date& rhs) const +int +Date::days_between(const Date& rhs) const { return g_date_days_between(&gobject_, &rhs.gobject_); } -int Date::compare(const Date& rhs) const +int +Date::compare(const Date& rhs) const { return g_date_compare(&gobject_, &rhs.gobject_); } -Date& Date::clamp(const Date& min_date, const Date& max_date) +Date& +Date::clamp(const Date& min_date, const Date& max_date) { g_date_clamp(&gobject_, &min_date.gobject_, &max_date.gobject_); return *this; } -Date& Date::clamp_min(const Date& min_date) +Date& +Date::clamp_min(const Date& min_date) { g_date_clamp(&gobject_, &min_date.gobject_, nullptr /* see the C docs */); return *this; } -Date& Date::clamp_max(const Date& max_date) +Date& +Date::clamp_max(const Date& max_date) { g_date_clamp(&gobject_, nullptr /* see the C docs */, &max_date.gobject_); return *this; } -void Date::order(Date& other) +void +Date::order(Date& other) { g_date_order(&gobject_, &other.gobject_); } -Date::Weekday Date::get_weekday() const +Date::Weekday +Date::get_weekday() const { - return (Date::Weekday) g_date_get_weekday(&gobject_); + return (Date::Weekday)g_date_get_weekday(&gobject_); } -Date::Month Date::get_month() const +Date::Month +Date::get_month() const { - return (Date::Month) g_date_get_month(&gobject_); + return (Date::Month)g_date_get_month(&gobject_); } -Date::Year Date::get_year() const +Date::Year +Date::get_year() const { return g_date_get_year(&gobject_); } -Date::Day Date::get_day() const +Date::Day +Date::get_day() const { return g_date_get_day(&gobject_); } -guint32 Date::get_julian() const +guint32 +Date::get_julian() const { return g_date_get_julian(&gobject_); } -unsigned int Date::get_day_of_year() const +unsigned int +Date::get_day_of_year() const { return g_date_get_day_of_year(&gobject_); } -unsigned int Date::get_monday_week_of_year() const +unsigned int +Date::get_monday_week_of_year() const { return g_date_get_monday_week_of_year(&gobject_); } -unsigned int Date::get_sunday_week_of_year() const +unsigned int +Date::get_sunday_week_of_year() const { return g_date_get_sunday_week_of_year(&gobject_); } -unsigned int Date::get_iso8601_week_of_year() const +unsigned int +Date::get_iso8601_week_of_year() const { return g_date_get_iso8601_week_of_year(&gobject_); } -bool Date::is_first_of_month() const +bool +Date::is_first_of_month() const { return g_date_is_first_of_month(&gobject_); } -bool Date::is_last_of_month() const +bool +Date::is_last_of_month() const { return g_date_is_last_of_month(&gobject_); } -//static -guint8 Date::get_days_in_month(Date::Month month, Date::Year year) +// static +guint8 +Date::get_days_in_month(Date::Month month, Date::Year year) { - return g_date_get_days_in_month((GDateMonth) month, year); + return g_date_get_days_in_month((GDateMonth)month, year); } -//static -guint8 Date::get_monday_weeks_in_year(Date::Year year) +// static +guint8 +Date::get_monday_weeks_in_year(Date::Year year) { return g_date_get_monday_weeks_in_year(year); } -//static -guint8 Date::get_sunday_weeks_in_year(Date::Year year) +// static +guint8 +Date::get_sunday_weeks_in_year(Date::Year year) { return g_date_get_sunday_weeks_in_year(year); } -//static -bool Date::is_leap_year(Date::Year year) +// static +bool +Date::is_leap_year(Date::Year year) { return g_date_is_leap_year(year); } -Glib::ustring Date::format_string(const Glib::ustring& format) const +Glib::ustring +Date::format_string(const Glib::ustring& format) const { struct tm tm_data; g_date_to_struct_tm(&gobject_, &tm_data); @@ -318,13 +355,12 @@ Glib::ustring Date::format_string(const Glib::ustring& format) const buf.get()[0] = '\1'; const auto len = strftime(buf.get(), bufsize, locale_format.c_str(), &tm_data); - if(len != 0 || buf.get()[0] == '\0') + if (len != 0 || buf.get()[0] == '\0') { g_assert(len < bufsize); return locale_to_utf8(std::string(buf.get(), len)); } - } - while((bufsize *= 2) <= 65536); + } while ((bufsize *= 2) <= 65536); // This error is quite unlikely (unless strftime is buggy). g_warning("Glib::Date::format_string(): maximum size of strftime buffer exceeded, giving up"); @@ -332,51 +368,58 @@ Glib::ustring Date::format_string(const Glib::ustring& format) const return Glib::ustring(); } -void Date::to_struct_tm(struct tm& dest) const +void +Date::to_struct_tm(struct tm& dest) const { g_date_to_struct_tm(&gobject_, &dest); } -bool Date::valid() const +bool +Date::valid() const { return g_date_valid(&gobject_); } -//static -bool Date::valid_day(Date::Day day) +// static +bool +Date::valid_day(Date::Day day) { return g_date_valid_day(day); } -//static -bool Date::valid_month(Date::Month month) +// static +bool +Date::valid_month(Date::Month month) { - return g_date_valid_month((GDateMonth) month); + return g_date_valid_month((GDateMonth)month); } -//static -bool Date::valid_year(Date::Year year) +// static +bool +Date::valid_year(Date::Year year) { return g_date_valid_year(year); } -//static -bool Date::valid_weekday(Date::Weekday weekday) +// static +bool +Date::valid_weekday(Date::Weekday weekday) { - return g_date_valid_weekday((GDateWeekday) weekday); + return g_date_valid_weekday((GDateWeekday)weekday); } -//static -bool Date::valid_julian(guint32 julian_day) +// static +bool +Date::valid_julian(guint32 julian_day) { return g_date_valid_julian(julian_day); } -//static -bool Date::valid_dmy(Date::Day day, Date::Month month, Date::Year year) +// static +bool +Date::valid_dmy(Date::Day day, Date::Month month, Date::Year year) { - return g_date_valid_dmy(day, (GDateMonth) month, year); + return g_date_valid_dmy(day, (GDateMonth)month, year); } } // namespace Glib - diff --git a/glib/src/datetime.ccg b/glib/src/datetime.ccg index f27df969..d47f05cd 100644 --- a/glib/src/datetime.ccg +++ b/glib/src/datetime.ccg @@ -23,4 +23,4 @@ namespace Glib { -}// namespace Glib +} // namespace Glib diff --git a/glib/src/fileutils.ccg b/glib/src/fileutils.ccg index 36385f68..eabe8e2c 100644 --- a/glib/src/fileutils.ccg +++ b/glib/src/fileutils.ccg @@ -18,7 +18,6 @@ #include #include - namespace Glib { @@ -29,66 +28,65 @@ Dir::Dir(const std::string& path) GError* error = nullptr; gobject_ = g_dir_open(path.c_str(), 0, &error); - if(error) + if (error) Glib::Error::throw_exception(error); } -Dir::Dir(GDir* gobject) -: - gobject_ (gobject) -{} +Dir::Dir(GDir* gobject) : gobject_(gobject) +{ +} Dir::~Dir() { - if(gobject_) + if (gobject_) g_dir_close(gobject_); } -std::string Dir::read_name() +std::string +Dir::read_name() { - const char *const name = g_dir_read_name(gobject_); + const char* const name = g_dir_read_name(gobject_); return Glib::convert_const_gchar_ptr_to_stdstring(name); } -void Dir::rewind() +void +Dir::rewind() { g_dir_rewind(gobject_); } -void Dir::close() +void +Dir::close() { - if(gobject_) + if (gobject_) { g_dir_close(gobject_); gobject_ = nullptr; } } -DirIterator Dir::begin() +DirIterator +Dir::begin() { g_dir_rewind(gobject_); return DirIterator(gobject_, g_dir_read_name(gobject_)); } -DirIterator Dir::end() +DirIterator +Dir::end() { return DirIterator(gobject_, nullptr); } - /**** Glib::DirIterator ****************************************************/ -DirIterator::DirIterator() -: - gobject_ (nullptr), - current_ (nullptr) -{} +DirIterator::DirIterator() : gobject_(nullptr), current_(nullptr) +{ +} -DirIterator::DirIterator(GDir* gobject, const char* current) -: - gobject_ (gobject), - current_ (current) -{} +DirIterator::DirIterator(GDir* gobject, const char* current) : gobject_(gobject), current_(current) +{ +} std::string DirIterator::operator*() const { @@ -106,34 +104,39 @@ void DirIterator::operator++(int) current_ = g_dir_read_name(gobject_); } -bool DirIterator::operator==(const DirIterator& rhs) const +bool +DirIterator::operator==(const DirIterator& rhs) const { return (current_ == rhs.current_); } -bool DirIterator::operator!=(const DirIterator& rhs) const +bool +DirIterator::operator!=(const DirIterator& rhs) const { return (current_ != rhs.current_); } - -bool file_test(const std::string& filename, FileTest test) +bool +file_test(const std::string& filename, FileTest test) { return g_file_test(filename.c_str(), static_cast(unsigned(test))); } -int mkstemp(std::string& filename_template) +int +mkstemp(std::string& filename_template) { - const auto buf = make_unique_ptr_gfree(g_strndup(filename_template.data(), filename_template.size())); + const auto buf = + make_unique_ptr_gfree(g_strndup(filename_template.data(), filename_template.size())); const auto fileno = g_mkstemp(buf.get()); filename_template = buf.get(); return fileno; } -int file_open_tmp(std::string& name_used, const std::string& prefix) +int +file_open_tmp(std::string& name_used, const std::string& prefix) { - std::string basename_template (prefix); + std::string basename_template(prefix); basename_template += "XXXXXX"; // this sillyness shouldn't be in the interface GError* error = nullptr; @@ -141,58 +144,58 @@ int file_open_tmp(std::string& name_used, const std::string& prefix) const auto fileno = g_file_open_tmp(basename_template.c_str(), &pch_buf_name_used, &error); auto buf_name_used = make_unique_ptr_gfree(pch_buf_name_used); - if(error) + if (error) Glib::Error::throw_exception(error); name_used = buf_name_used.get(); return fileno; } -int file_open_tmp(std::string& name_used) +int +file_open_tmp(std::string& name_used) { GError* error = nullptr; char* pch_buf_name_used = nullptr; const auto fileno = g_file_open_tmp(nullptr, &pch_buf_name_used, &error); auto buf_name_used = make_unique_ptr_gfree(pch_buf_name_used); - if(error) + if (error) Glib::Error::throw_exception(error); name_used = buf_name_used.get(); return fileno; } -std::string file_get_contents(const std::string& filename) +std::string +file_get_contents(const std::string& filename) { - gsize length = 0; - GError* error = nullptr; + gsize length = 0; + GError* error = nullptr; char* pch_contents = nullptr; g_file_get_contents(filename.c_str(), &pch_contents, &length, &error); auto contents = make_unique_ptr_gfree(pch_contents); - if(error) + if (error) Glib::Error::throw_exception(error); return std::string(contents.get(), length); } void -file_set_contents(const std::string& filename, - const gchar *contents, - gssize length) +file_set_contents(const std::string& filename, const gchar* contents, gssize length) { - GError* error = nullptr; + GError* error = nullptr; g_file_set_contents(filename.c_str(), contents, length, &error); - if(error) + if (error) Glib::Error::throw_exception(error); } void -file_set_contents (const std::string& filename, const std::string& contents) +file_set_contents(const std::string& filename, const std::string& contents) { - file_set_contents(filename, contents.c_str(), contents.size()); + file_set_contents(filename, contents.c_str(), contents.size()); } } // namespace Glib diff --git a/glib/src/iochannel.ccg b/glib/src/iochannel.ccg index fc5bb6c2..7577a846 100644 --- a/glib/src/iochannel.ccg +++ b/glib/src/iochannel.ccg @@ -20,7 +20,6 @@ #include #include - namespace { @@ -48,7 +47,9 @@ class ForeignIOChannel : public Glib::IOChannel { public: ForeignIOChannel(GIOChannel* gobject, bool take_copy) - : Glib::IOChannel(gobject, take_copy), ref_count_(0) {} + : Glib::IOChannel(gobject, take_copy), ref_count_(0) + { + } void reference() const override; void unreference() const override; @@ -57,69 +58,62 @@ private: mutable int ref_count_; }; -void ForeignIOChannel::reference() const +void +ForeignIOChannel::reference() const { ++ref_count_; } -void ForeignIOChannel::unreference() const +void +ForeignIOChannel::unreference() const { - if (!(--ref_count_)) delete this; + if (!(--ref_count_)) + delete this; } } // anonymous namespace - namespace Glib { class GlibmmIOChannel { public: - GIOChannel base; - Glib::IOChannel* wrapper; + GIOChannel base; + Glib::IOChannel* wrapper; static const GIOFuncs vfunc_table; - static GIOStatus io_read(GIOChannel* channel, char* buf, gsize count, - gsize* bytes_read, GError** err); + static GIOStatus io_read( + GIOChannel* channel, char* buf, gsize count, gsize* bytes_read, GError** err); - static GIOStatus io_write(GIOChannel* channel, const char* buf, gsize count, - gsize* bytes_written, GError** err); + static GIOStatus io_write( + GIOChannel* channel, const char* buf, gsize count, gsize* bytes_written, GError** err); - static GIOStatus io_seek (GIOChannel* channel, gint64 offset, GSeekType type, GError** err); + static GIOStatus io_seek(GIOChannel* channel, gint64 offset, GSeekType type, GError** err); static GIOStatus io_close(GIOChannel* channel, GError** err); - static GSource* io_create_watch(GIOChannel* channel, GIOCondition condition); - static void io_free(GIOChannel* channel); + static GSource* io_create_watch(GIOChannel* channel, GIOCondition condition); + static void io_free(GIOChannel* channel); static GIOStatus io_set_flags(GIOChannel* channel, GIOFlags flags, GError** err); - static GIOFlags io_get_flags(GIOChannel* channel); + static GIOFlags io_get_flags(GIOChannel* channel); }; // static -const GIOFuncs GlibmmIOChannel::vfunc_table = -{ - &GlibmmIOChannel::io_read, - &GlibmmIOChannel::io_write, - &GlibmmIOChannel::io_seek, - &GlibmmIOChannel::io_close, - &GlibmmIOChannel::io_create_watch, - &GlibmmIOChannel::io_free, - &GlibmmIOChannel::io_set_flags, - &GlibmmIOChannel::io_get_flags, +const GIOFuncs GlibmmIOChannel::vfunc_table = { + &GlibmmIOChannel::io_read, &GlibmmIOChannel::io_write, &GlibmmIOChannel::io_seek, + &GlibmmIOChannel::io_close, &GlibmmIOChannel::io_create_watch, &GlibmmIOChannel::io_free, + &GlibmmIOChannel::io_set_flags, &GlibmmIOChannel::io_get_flags, }; - /**** GLib::IOChannel ******************************************************/ /* Construct a custom C++-implemented IOChannel. GlibmmIOChannel is an * extended GIOChannel struct which allows us to hook up a pointer to this * persistent wrapper instance. */ -IOChannel::IOChannel() -: - gobject_ (static_cast(g_malloc(sizeof(GlibmmIOChannel)))) +IOChannel::IOChannel() : gobject_(static_cast(g_malloc(sizeof(GlibmmIOChannel)))) { g_io_channel_init(gobject_); gobject_->funcs = const_cast(&GlibmmIOChannel::vfunc_table); @@ -127,14 +121,14 @@ IOChannel::IOChannel() reinterpret_cast(gobject_)->wrapper = this; } -IOChannel::IOChannel(IOChannel&& other) noexcept -: sigc::trackable(std::move(other)), - gobject_(std::move(other.gobject_)) +IOChannel::IOChannel(IOChannel&& other) noexcept : sigc::trackable(std::move(other)), + gobject_(std::move(other.gobject_)) { other.gobject_ = nullptr; } -IOChannel& IOChannel::operator=(IOChannel&& other) noexcept +IOChannel& +IOChannel::operator=(IOChannel&& other) noexcept { sigc::trackable::operator=(std::move(other)); @@ -150,21 +144,20 @@ IOChannel& IOChannel::operator=(IOChannel&& other) noexcept * See the comment at the top of this file for an explanation of the * problems with this approach. */ -IOChannel::IOChannel(GIOChannel* gobject, bool take_copy) -: - gobject_ (gobject) +IOChannel::IOChannel(GIOChannel* gobject, bool take_copy) : gobject_(gobject) { // This ctor should never be called for GlibmmIOChannel instances. g_assert(gobject != nullptr); g_assert(gobject->funcs != &GlibmmIOChannel::vfunc_table); - if(take_copy) + if (take_copy) g_io_channel_ref(gobject_); } -void IOChannel::release_gobject() +void +IOChannel::release_gobject() { - if(gobject_) + if (gobject_) { // Check whether this IOChannel is implemented in C++, i.e. whether it // uses our GlibmmIOChannel forwarding backend. Normally, this will never @@ -173,7 +166,7 @@ void IOChannel::release_gobject() // of a derived class threw an exception the GIOChannel must be destroyed // prematurely. // - if(gobject_->funcs == &GlibmmIOChannel::vfunc_table) + if (gobject_->funcs == &GlibmmIOChannel::vfunc_table) { // Disconnect the wrapper object so that it won't be deleted twice. reinterpret_cast(gobject_)->wrapper = nullptr; @@ -191,12 +184,13 @@ IOChannel::~IOChannel() release_gobject(); } -Glib::RefPtr IOChannel::create_from_file(const std::string& filename, const std::string& mode) +Glib::RefPtr +IOChannel::create_from_file(const std::string& filename, const std::string& mode) { GError* gerror = nullptr; const auto channel = g_io_channel_new_file(filename.c_str(), mode.c_str(), &gerror); - if(gerror) + if (gerror) { Glib::Error::throw_exception(gerror); } @@ -204,132 +198,143 @@ Glib::RefPtr IOChannel::create_from_file(const std::string& filename, return Glib::wrap(channel, false); } -Glib::RefPtr IOChannel::create_from_fd(int fd) +Glib::RefPtr +IOChannel::create_from_fd(int fd) { return Glib::wrap(g_io_channel_unix_new(fd), false); } #ifdef G_OS_WIN32 -Glib::RefPtr IOChannel::create_from_win32_fd(int fd) +Glib::RefPtr +IOChannel::create_from_win32_fd(int fd) { return Glib::wrap(g_io_channel_win32_new_fd(fd), false); } -Glib::RefPtr IOChannel::create_from_win32_socket(int socket) +Glib::RefPtr +IOChannel::create_from_win32_socket(int socket) { return Glib::wrap(g_io_channel_win32_new_socket(socket), false); } #endif /* G_OS_WIN32 */ -IOStatus IOChannel::write(const Glib::ustring& str) +IOStatus +IOChannel::write(const Glib::ustring& str) { gsize bytes_written = 0; return write(str.data(), str.bytes(), bytes_written); } -IOStatus IOChannel::read_line(Glib::ustring& line) +IOStatus +IOChannel::read_line(Glib::ustring& line) { GError* gerror = nullptr; - gsize bytes = 0; + gsize bytes = 0; char* pch_buf = nullptr; const auto status = g_io_channel_read_line(gobj(), &pch_buf, &bytes, nullptr, &gerror); auto buf = make_unique_ptr_gfree(pch_buf); - if(gerror) + if (gerror) { Glib::Error::throw_exception(gerror); } - if(buf.get()) + if (buf.get()) line.assign(buf.get(), buf.get() + bytes); else line.erase(); - return (IOStatus) status; + return (IOStatus)status; } -IOStatus IOChannel::read_to_end(Glib::ustring& str) +IOStatus +IOChannel::read_to_end(Glib::ustring& str) { GError* gerror = nullptr; - gsize bytes = 0; + gsize bytes = 0; char* pch_buf = nullptr; const auto status = g_io_channel_read_to_end(gobj(), &pch_buf, &bytes, &gerror); auto buf = make_unique_ptr_gfree(pch_buf); - if(gerror) + if (gerror) { Glib::Error::throw_exception(gerror); } - if(buf.get()) + if (buf.get()) str.assign(buf.get(), buf.get() + bytes); else str.erase(); - return (IOStatus) status; + return (IOStatus)status; } -IOStatus IOChannel::read(Glib::ustring& str, gsize count) +IOStatus +IOChannel::read(Glib::ustring& str, gsize count) { auto buf = make_unique_ptr_gfree(g_new(char, count)); GError* gerror = nullptr; - gsize bytes = 0; + gsize bytes = 0; const auto status = g_io_channel_read_chars(gobj(), buf.get(), count, &bytes, &gerror); - if(gerror) + if (gerror) { Glib::Error::throw_exception(gerror); } - if(buf.get()) + if (buf.get()) str.assign(buf.get(), buf.get() + bytes); else str.erase(); - return (IOStatus) status; + return (IOStatus)status; } -IOStatus IOChannel::set_encoding(const std::string& encoding) +IOStatus +IOChannel::set_encoding(const std::string& encoding) { GError* gerror = nullptr; - const auto status = g_io_channel_set_encoding( - gobj(), Glib::c_str_or_nullptr(encoding), &gerror); + const auto status = g_io_channel_set_encoding(gobj(), Glib::c_str_or_nullptr(encoding), &gerror); - if(gerror) + if (gerror) { Glib::Error::throw_exception(gerror); } - return (IOStatus) status; + return (IOStatus)status; } -std::string IOChannel::get_encoding() const +std::string +IOChannel::get_encoding() const { - const char *const encoding = g_io_channel_get_encoding(gobject_); + const char* const encoding = g_io_channel_get_encoding(gobject_); return convert_const_gchar_ptr_to_stdstring(encoding); } -void IOChannel::set_line_term(const std::string& term) +void +IOChannel::set_line_term(const std::string& term) { - if(term.empty()) + if (term.empty()) g_io_channel_set_line_term(gobj(), nullptr, 0); else g_io_channel_set_line_term(gobj(), term.data(), term.size()); } -std::string IOChannel::get_line_term() const +std::string +IOChannel::get_line_term() const { int len = 0; - const char *const term = g_io_channel_get_line_term(gobject_, &len); + const char* const term = g_io_channel_get_line_term(gobject_, &len); return (term) ? std::string(term, len) : std::string(); } -Glib::RefPtr IOChannel::create_watch(IOCondition condition) +Glib::RefPtr +IOChannel::create_watch(IOCondition condition) { // The corresponding unreference() takes place in the dtor // of the Glib::RefPtr object below. @@ -337,13 +342,15 @@ Glib::RefPtr IOChannel::create_watch(IOCondition condition) return IOSource::create(Glib::RefPtr(this), condition); } -IOStatus IOChannel::read_vfunc(char*, gsize, gsize&) +IOStatus +IOChannel::read_vfunc(char*, gsize, gsize&) { g_assert_not_reached(); return IO_STATUS_ERROR; } -IOStatus IOChannel::write_vfunc(const char*, gsize, gsize&) +IOStatus +IOChannel::write_vfunc(const char*, gsize, gsize&) { g_assert_not_reached(); return IO_STATUS_ERROR; @@ -355,7 +362,8 @@ IOStatus IOChannel::seek_vfunc(gint64, SeekType) return IO_STATUS_ERROR; } -IOStatus IOChannel::close_vfunc() +IOStatus +IOChannel::close_vfunc() { g_assert_not_reached(); return IO_STATUS_ERROR; @@ -373,33 +381,37 @@ IOStatus IOChannel::set_flags_vfunc(IOFlags) return IO_STATUS_ERROR; } -IOFlags IOChannel::get_flags_vfunc() +IOFlags +IOChannel::get_flags_vfunc() { g_assert_not_reached(); return IOFlags(0); } -void IOChannel::reference() const +void +IOChannel::reference() const { g_io_channel_ref(gobject_); } -void IOChannel::unreference() const +void +IOChannel::unreference() const { g_io_channel_unref(gobject_); } -Glib::RefPtr wrap(GIOChannel* gobject, bool take_copy) +Glib::RefPtr +wrap(GIOChannel* gobject, bool take_copy) { IOChannel* cpp_object = nullptr; - if(gobject) + if (gobject) { - if(gobject->funcs == &GlibmmIOChannel::vfunc_table) + if (gobject->funcs == &GlibmmIOChannel::vfunc_table) { cpp_object = reinterpret_cast(gobject)->wrapper; - if(take_copy && cpp_object) + if (take_copy && cpp_object) cpp_object->reference(); } else @@ -412,23 +424,23 @@ Glib::RefPtr wrap(GIOChannel* gobject, bool take_copy) return Glib::RefPtr(cpp_object); } - /**** Glib::GlibmmIOChannel ************************************************/ -GIOStatus GlibmmIOChannel::io_read(GIOChannel* channel, char* buf, gsize count, - gsize* bytes_read, GError** err) +GIOStatus +GlibmmIOChannel::io_read( + GIOChannel* channel, char* buf, gsize count, gsize* bytes_read, GError** err) { const auto wrapper = reinterpret_cast(channel)->wrapper; try { - return (GIOStatus) wrapper->read_vfunc(buf, count, *bytes_read); + return (GIOStatus)wrapper->read_vfunc(buf, count, *bytes_read); } - catch(Glib::Error& error) + catch (Glib::Error& error) { error.propagate(err); } - catch(...) + catch (...) { Glib::exception_handlers_invoke(); } @@ -436,20 +448,21 @@ GIOStatus GlibmmIOChannel::io_read(GIOChannel* channel, char* buf, gsize count, return G_IO_STATUS_ERROR; } -GIOStatus GlibmmIOChannel::io_write(GIOChannel* channel, const char* buf, gsize count, - gsize* bytes_written, GError** err) +GIOStatus +GlibmmIOChannel::io_write( + GIOChannel* channel, const char* buf, gsize count, gsize* bytes_written, GError** err) { const auto wrapper = reinterpret_cast(channel)->wrapper; try { - return (GIOStatus) wrapper->write_vfunc(buf, count, *bytes_written); + return (GIOStatus)wrapper->write_vfunc(buf, count, *bytes_written); } - catch(Glib::Error& error) + catch (Glib::Error& error) { error.propagate(err); } - catch(...) + catch (...) { Glib::exception_handlers_invoke(); } @@ -457,19 +470,20 @@ GIOStatus GlibmmIOChannel::io_write(GIOChannel* channel, const char* buf, gsize return G_IO_STATUS_ERROR; } -GIOStatus GlibmmIOChannel::io_seek(GIOChannel* channel, gint64 offset, GSeekType type, GError** err) +GIOStatus +GlibmmIOChannel::io_seek(GIOChannel* channel, gint64 offset, GSeekType type, GError** err) { const auto wrapper = reinterpret_cast(channel)->wrapper; try { - return (GIOStatus) wrapper->seek_vfunc(offset, (SeekType) type); + return (GIOStatus)wrapper->seek_vfunc(offset, (SeekType)type); } - catch(Glib::Error& error) + catch (Glib::Error& error) { error.propagate(err); } - catch(...) + catch (...) { Glib::exception_handlers_invoke(); } @@ -477,38 +491,39 @@ GIOStatus GlibmmIOChannel::io_seek(GIOChannel* channel, gint64 offset, GSeekType return G_IO_STATUS_ERROR; } -GIOStatus GlibmmIOChannel::io_close(GIOChannel* channel, GError** err) +GIOStatus +GlibmmIOChannel::io_close(GIOChannel* channel, GError** err) { const auto wrapper = reinterpret_cast(channel)->wrapper; try { - return (GIOStatus) wrapper->close_vfunc(); + return (GIOStatus)wrapper->close_vfunc(); } - catch(Glib::Error& error) + catch (Glib::Error& error) { error.propagate(err); } - catch(...) + catch (...) { Glib::exception_handlers_invoke(); } - return G_IO_STATUS_ERROR; } // static -GSource* GlibmmIOChannel::io_create_watch(GIOChannel* channel, GIOCondition condition) +GSource* +GlibmmIOChannel::io_create_watch(GIOChannel* channel, GIOCondition condition) { const auto wrapper = reinterpret_cast(channel)->wrapper; try { - const auto source = wrapper->create_watch_vfunc((IOCondition) condition); + const auto source = wrapper->create_watch_vfunc((IOCondition)condition); return (source) ? source->gobj_copy() : nullptr; } - catch(...) + catch (...) { Glib::exception_handlers_invoke(); } @@ -517,9 +532,10 @@ GSource* GlibmmIOChannel::io_create_watch(GIOChannel* channel, GIOCondition cond } // static -void GlibmmIOChannel::io_free(GIOChannel* channel) +void +GlibmmIOChannel::io_free(GIOChannel* channel) { - if(IOChannel *const wrapper = reinterpret_cast(channel)->wrapper) + if (IOChannel* const wrapper = reinterpret_cast(channel)->wrapper) { wrapper->gobject_ = nullptr; delete wrapper; @@ -528,19 +544,20 @@ void GlibmmIOChannel::io_free(GIOChannel* channel) g_free(channel); } -GIOStatus GlibmmIOChannel::io_set_flags(GIOChannel* channel, GIOFlags flags, GError** err) +GIOStatus +GlibmmIOChannel::io_set_flags(GIOChannel* channel, GIOFlags flags, GError** err) { const auto wrapper = reinterpret_cast(channel)->wrapper; try { - return (GIOStatus) wrapper->set_flags_vfunc((IOFlags) flags); + return (GIOStatus)wrapper->set_flags_vfunc((IOFlags)flags); } - catch(Glib::Error& error) + catch (Glib::Error& error) { error.propagate(err); } - catch(...) + catch (...) { Glib::exception_handlers_invoke(); } @@ -549,15 +566,16 @@ GIOStatus GlibmmIOChannel::io_set_flags(GIOChannel* channel, GIOFlags flags, GEr } // static -GIOFlags GlibmmIOChannel::io_get_flags(GIOChannel* channel) +GIOFlags +GlibmmIOChannel::io_get_flags(GIOChannel* channel) { const auto wrapper = reinterpret_cast(channel)->wrapper; try { - return (GIOFlags) wrapper->get_flags_vfunc(); + return (GIOFlags)wrapper->get_flags_vfunc(); } - catch(...) + catch (...) { Glib::exception_handlers_invoke(); } diff --git a/glib/src/keyfile.ccg b/glib/src/keyfile.ccg index 6487cbc1..65e2fb67 100644 --- a/glib/src/keyfile.ccg +++ b/glib/src/keyfile.ccg @@ -32,15 +32,15 @@ KeyFile::KeyFile(GKeyFile* castitem, bool takes_ownership) owns_gobject_ = takes_ownership; } -KeyFile::KeyFile(KeyFile&& other) noexcept -: gobject_(std::move(other.gobject_)), - owns_gobject_(std::move(other.owns_gobject_)) +KeyFile::KeyFile(KeyFile&& other) noexcept : gobject_(std::move(other.gobject_)), + owns_gobject_(std::move(other.owns_gobject_)) { other.gobject_ = nullptr; other.owns_gobject_ = false; } -KeyFile& KeyFile::operator=(KeyFile&& other) noexcept +KeyFile& +KeyFile::operator=(KeyFile&& other) noexcept { if (owns_gobject_) g_key_file_free(gobject_); @@ -60,35 +60,33 @@ KeyFile::~KeyFile() g_key_file_free(gobject_); } -bool KeyFile::load_from_data(const Glib::ustring& data, KeyFileFlags flags) +bool +KeyFile::load_from_data(const Glib::ustring& data, KeyFileFlags flags) { GError* gerror = nullptr; const gboolean result = g_key_file_load_from_data( - gobj(), data.c_str(), data.bytes(), - static_cast(unsigned(flags)), - &gerror); + gobj(), data.c_str(), data.bytes(), static_cast(unsigned(flags)), &gerror); - if(gerror) + if (gerror) Glib::Error::throw_exception(gerror); return (result != 0); } -bool KeyFile::load_from_data_dirs(const std::string& file, std::string& full_path, KeyFileFlags flags) +bool +KeyFile::load_from_data_dirs(const std::string& file, std::string& full_path, KeyFileFlags flags) { GError* gerror = nullptr; char* full_path_c = nullptr; const gboolean result = g_key_file_load_from_data_dirs( - gobj(), file.c_str(), &full_path_c, - static_cast(unsigned(flags)), - &gerror); + gobj(), file.c_str(), &full_path_c, static_cast(unsigned(flags)), &gerror); - if(gerror) + if (gerror) Glib::Error::throw_exception(gerror); - if(full_path_c) + if (full_path_c) full_path = Glib::make_unique_ptr_gfree(full_path_c).get(); else full_path.erase(); @@ -96,17 +94,18 @@ bool KeyFile::load_from_data_dirs(const std::string& file, std::string& full_pat return (result != 0); } -bool KeyFile::load_from_dirs(const std::string& file, const Glib::ArrayHandle& search_dirs, std::string& full_path, KeyFileFlags flags) +bool +KeyFile::load_from_dirs(const std::string& file, const Glib::ArrayHandle& search_dirs, + std::string& full_path, KeyFileFlags flags) { GError* gerror = nullptr; char* full_path_c = nullptr; - const gboolean result = g_key_file_load_from_dirs( - gobj(), file.c_str(), const_cast(search_dirs.data()), - &full_path_c, static_cast(unsigned(flags)), - &gerror); + const gboolean result = + g_key_file_load_from_dirs(gobj(), file.c_str(), const_cast(search_dirs.data()), + &full_path_c, static_cast(unsigned(flags)), &gerror); - if(gerror) + if (gerror) { if (full_path_c) { @@ -115,7 +114,7 @@ bool KeyFile::load_from_dirs(const std::string& file, const Glib::ArrayHandle KeyFile::get_groups() const +Glib::ArrayHandle +KeyFile::get_groups() const { gsize length = 0; char** const array = g_key_file_get_groups(const_cast(gobj()), &length); @@ -142,247 +143,249 @@ Glib::ArrayHandle KeyFile::get_groups() const return Glib::ArrayHandle(array, length, Glib::OWNERSHIP_DEEP); } -Glib::ArrayHandle KeyFile::get_keys(const Glib::ustring& group_name) const +Glib::ArrayHandle +KeyFile::get_keys(const Glib::ustring& group_name) const { - gsize length = 0; + gsize length = 0; GError* gerror = nullptr; char** const array = g_key_file_get_keys( - const_cast(gobj()), - Glib::c_str_or_nullptr(group_name), - &length, &gerror); + const_cast(gobj()), Glib::c_str_or_nullptr(group_name), &length, &gerror); - if(gerror) + if (gerror) Glib::Error::throw_exception(gerror); return Glib::ArrayHandle(array, length, Glib::OWNERSHIP_DEEP); } -Glib::ustring KeyFile::get_locale_string(const Glib::ustring& group_name, - const Glib::ustring& key) const +Glib::ustring +KeyFile::get_locale_string(const Glib::ustring& group_name, const Glib::ustring& key) const { GError* gerror = nullptr; - char *const str = g_key_file_get_locale_string( - const_cast(gobj()), - Glib::c_str_or_nullptr(group_name), - key.c_str(), nullptr, &gerror); + char* const str = g_key_file_get_locale_string(const_cast(gobj()), + Glib::c_str_or_nullptr(group_name), key.c_str(), nullptr, &gerror); - if(gerror) + if (gerror) Glib::Error::throw_exception(gerror); return Glib::convert_return_gchar_ptr_to_ustring(str); } -bool KeyFile::get_boolean(const Glib::ustring& key) const +bool +KeyFile::get_boolean(const Glib::ustring& key) const { GError* gerror = nullptr; - const bool value = - static_cast(g_key_file_get_boolean(const_cast(gobj()), - nullptr, key.c_str(), &gerror)); - if(gerror) + const bool value = static_cast( + g_key_file_get_boolean(const_cast(gobj()), nullptr, key.c_str(), &gerror)); + if (gerror) Glib::Error::throw_exception(gerror); return value; } -int KeyFile::get_integer(const Glib::ustring& key) const +int +KeyFile::get_integer(const Glib::ustring& key) const { GError* gerror = nullptr; - const int value = g_key_file_get_integer(const_cast(gobj()), - nullptr, key.c_str(), &gerror); - if(gerror) + const int value = + g_key_file_get_integer(const_cast(gobj()), nullptr, key.c_str(), &gerror); + if (gerror) Glib::Error::throw_exception(gerror); return value; } -gint64 KeyFile::get_int64(const Glib::ustring& key) const +gint64 +KeyFile::get_int64(const Glib::ustring& key) const { GError* gerror = nullptr; - const gint64 value = g_key_file_get_int64(const_cast(gobj()), nullptr, - key.c_str(), &gerror); + const gint64 value = + g_key_file_get_int64(const_cast(gobj()), nullptr, key.c_str(), &gerror); - if(gerror) + if (gerror) Glib::Error::throw_exception(gerror); return value; } -guint64 KeyFile::get_uint64(const Glib::ustring& key) const +guint64 +KeyFile::get_uint64(const Glib::ustring& key) const { GError* gerror = nullptr; - const guint64 value = g_key_file_get_uint64(const_cast(gobj()), - nullptr, key.c_str(), &gerror); + const guint64 value = + g_key_file_get_uint64(const_cast(gobj()), nullptr, key.c_str(), &gerror); - if(gerror) + if (gerror) Glib::Error::throw_exception(gerror); return value; } -double KeyFile::get_double(const Glib::ustring& key) const +double +KeyFile::get_double(const Glib::ustring& key) const { GError* gerror = nullptr; - double retvalue = g_key_file_get_double(const_cast(gobj()), nullptr, key.c_str(), &(gerror)); + double retvalue = + g_key_file_get_double(const_cast(gobj()), nullptr, key.c_str(), &(gerror)); - if(gerror) + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } -void KeyFile::set_double(const Glib::ustring& key, double value) +void +KeyFile::set_double(const Glib::ustring& key, double value) { g_key_file_set_double(gobj(), nullptr, key.c_str(), value); } -# define GLIBMM_ERROR_ARG -# define GLIBMM_THROW(err) if (err) Glib::Error::throw_exception(err) +#define GLIBMM_ERROR_ARG +#define GLIBMM_THROW(err) \ + if (err) \ + Glib::Error::throw_exception(err) -Glib::ArrayHandle KeyFile::get_string_list(const Glib::ustring& group_name, - const Glib::ustring& key - GLIBMM_ERROR_ARG) const +Glib::ArrayHandle +KeyFile::get_string_list( + const Glib::ustring& group_name, const Glib::ustring& key GLIBMM_ERROR_ARG) const { - gsize length = 0; + gsize length = 0; GError* gerror = nullptr; - char** const array = g_key_file_get_string_list( - const_cast(gobj()), - Glib::c_str_or_nullptr(group_name), - key.c_str(), &length, &gerror); + char** const array = g_key_file_get_string_list(const_cast(gobj()), + Glib::c_str_or_nullptr(group_name), key.c_str(), &length, &gerror); GLIBMM_THROW(gerror); return Glib::ArrayHandle(array, length, Glib::OWNERSHIP_DEEP); } -Glib::ArrayHandle KeyFile::get_locale_string_list(const Glib::ustring& group_name, - const Glib::ustring& key, - const Glib::ustring& locale - GLIBMM_ERROR_ARG) const +Glib::ArrayHandle +KeyFile::get_locale_string_list(const Glib::ustring& group_name, const Glib::ustring& key, + const Glib::ustring& locale GLIBMM_ERROR_ARG) const { - gsize length = 0; + gsize length = 0; GError* gerror = nullptr; - char** const array = g_key_file_get_locale_string_list( - const_cast(gobj()), - Glib::c_str_or_nullptr(group_name), - key.c_str(), locale.c_str(), &length, &gerror); + char** const array = g_key_file_get_locale_string_list(const_cast(gobj()), + Glib::c_str_or_nullptr(group_name), key.c_str(), locale.c_str(), &length, &gerror); GLIBMM_THROW(gerror); return Glib::ArrayHandle(array, length, Glib::OWNERSHIP_DEEP); } -Glib::ArrayHandle KeyFile::get_boolean_list(const Glib::ustring& group_name, - const Glib::ustring& key - GLIBMM_ERROR_ARG) const +Glib::ArrayHandle +KeyFile::get_boolean_list( + const Glib::ustring& group_name, const Glib::ustring& key GLIBMM_ERROR_ARG) const { - gsize length = 0; + gsize length = 0; GError* gerror = nullptr; - gboolean *const array = g_key_file_get_boolean_list( - const_cast(gobj()), - Glib::c_str_or_nullptr(group_name), - key.c_str(), &length, &gerror); + gboolean* const array = g_key_file_get_boolean_list(const_cast(gobj()), + Glib::c_str_or_nullptr(group_name), key.c_str(), &length, &gerror); GLIBMM_THROW(gerror); return Glib::ArrayHandle(array, length, Glib::OWNERSHIP_SHALLOW); } -Glib::ArrayHandle KeyFile::get_integer_list(const Glib::ustring& group_name, - const Glib::ustring& key - GLIBMM_ERROR_ARG) const +Glib::ArrayHandle +KeyFile::get_integer_list( + const Glib::ustring& group_name, const Glib::ustring& key GLIBMM_ERROR_ARG) const { - gsize length = 0; + gsize length = 0; GError* gerror = nullptr; - int *const array = g_key_file_get_integer_list( - const_cast(gobj()), - Glib::c_str_or_nullptr(group_name), - key.c_str(), &length, &gerror); + int* const array = g_key_file_get_integer_list(const_cast(gobj()), + Glib::c_str_or_nullptr(group_name), key.c_str(), &length, &gerror); GLIBMM_THROW(gerror); return Glib::ArrayHandle(array, length, Glib::OWNERSHIP_SHALLOW); } -Glib::ArrayHandle KeyFile::get_double_list(const Glib::ustring& group_name, - const Glib::ustring& key - GLIBMM_ERROR_ARG) const +Glib::ArrayHandle +KeyFile::get_double_list( + const Glib::ustring& group_name, const Glib::ustring& key GLIBMM_ERROR_ARG) const { - gsize length = 0; + gsize length = 0; GError* gerror = nullptr; - double *const array = g_key_file_get_double_list(const_cast(gobj()), - group_name.c_str(), key.c_str(), - &length, &gerror); + double* const array = g_key_file_get_double_list( + const_cast(gobj()), group_name.c_str(), key.c_str(), &length, &gerror); GLIBMM_THROW(gerror); return Glib::ArrayHandle(array, length, Glib::OWNERSHIP_SHALLOW); } -void KeyFile::set_string_list(const Glib::ustring& group_name, const Glib::ustring& key, - const Glib::ArrayHandle& list) +void +KeyFile::set_string_list(const Glib::ustring& group_name, const Glib::ustring& key, + const Glib::ArrayHandle& list) { - g_key_file_set_string_list(gobj(), Glib::c_str_or_nullptr(group_name), - key.c_str(), list.data(), list.size()); + g_key_file_set_string_list( + gobj(), Glib::c_str_or_nullptr(group_name), key.c_str(), list.data(), list.size()); } -void KeyFile::set_locale_string_list(const Glib::ustring& group_name, - const Glib::ustring& key, const Glib::ustring& locale, - const Glib::ArrayHandle& list) +void +KeyFile::set_locale_string_list(const Glib::ustring& group_name, const Glib::ustring& key, + const Glib::ustring& locale, const Glib::ArrayHandle& list) { - g_key_file_set_locale_string_list(gobj(), Glib::c_str_or_nullptr(group_name), - key.c_str(), locale.c_str(), list.data(), list.size()); + g_key_file_set_locale_string_list(gobj(), Glib::c_str_or_nullptr(group_name), key.c_str(), + locale.c_str(), list.data(), list.size()); } -void KeyFile::set_integer_list(const Glib::ustring& group_name, const Glib::ustring& key, - const Glib::ArrayHandle& list) +void +KeyFile::set_integer_list( + const Glib::ustring& group_name, const Glib::ustring& key, const Glib::ArrayHandle& list) { - g_key_file_set_integer_list(gobj(), Glib::c_str_or_nullptr(group_name), - key.c_str(), const_cast(list.data()), list.size()); + g_key_file_set_integer_list(gobj(), Glib::c_str_or_nullptr(group_name), key.c_str(), + const_cast(list.data()), list.size()); } -void KeyFile::set_double_list(const Glib::ustring& group_name, const Glib::ustring& key, - const Glib::ArrayHandle& list) +void +KeyFile::set_double_list( + const Glib::ustring& group_name, const Glib::ustring& key, const Glib::ArrayHandle& list) { - g_key_file_set_double_list(gobj(), group_name.c_str(), key.c_str(), - const_cast(list.data()), list.size()); + g_key_file_set_double_list( + gobj(), group_name.c_str(), key.c_str(), const_cast(list.data()), list.size()); } -void KeyFile::set_boolean_list(const Glib::ustring& group_name, const Glib::ustring& key, - const Glib::ArrayHandle& list) +void +KeyFile::set_boolean_list( + const Glib::ustring& group_name, const Glib::ustring& key, const Glib::ArrayHandle& list) { - g_key_file_set_boolean_list(gobj(), Glib::c_str_or_nullptr(group_name), - key.c_str(), const_cast(list.data()), list.size()); + g_key_file_set_boolean_list(gobj(), Glib::c_str_or_nullptr(group_name), key.c_str(), + const_cast(list.data()), list.size()); } -Glib::ustring KeyFile::get_comment() const +Glib::ustring +KeyFile::get_comment() const { GError* gerror = nullptr; - char *const str = g_key_file_get_comment(const_cast(gobj()), nullptr, nullptr, &gerror); + char* const str = + g_key_file_get_comment(const_cast(gobj()), nullptr, nullptr, &gerror); GLIBMM_THROW(gerror); return Glib::convert_return_gchar_ptr_to_ustring(str); } -Glib::ustring KeyFile::get_comment(const Glib::ustring& group_name GLIBMM_ERROR_ARG) const +Glib::ustring +KeyFile::get_comment(const Glib::ustring& group_name GLIBMM_ERROR_ARG) const { GError* gerror = nullptr; - char *const str = g_key_file_get_comment(const_cast(gobj()), - Glib::c_str_or_nullptr(group_name), - nullptr, &gerror); + char* const str = g_key_file_get_comment( + const_cast(gobj()), Glib::c_str_or_nullptr(group_name), nullptr, &gerror); GLIBMM_THROW(gerror); return Glib::convert_return_gchar_ptr_to_ustring(str); } -void KeyFile::set_comment(const Glib::ustring& comment GLIBMM_ERROR_ARG) +void +KeyFile::set_comment(const Glib::ustring& comment GLIBMM_ERROR_ARG) { GError* gerror = nullptr; g_key_file_set_comment(gobj(), nullptr, nullptr, comment.c_str(), &gerror); @@ -390,12 +393,12 @@ void KeyFile::set_comment(const Glib::ustring& comment GLIBMM_ERROR_ARG) GLIBMM_THROW(gerror); } -void KeyFile::set_comment(const Glib::ustring& group_name, const Glib::ustring& comment - GLIBMM_ERROR_ARG) +void +KeyFile::set_comment(const Glib::ustring& group_name, const Glib::ustring& comment GLIBMM_ERROR_ARG) { GError* gerror = nullptr; - g_key_file_set_comment(gobj(), Glib::c_str_or_nullptr(group_name), - nullptr, comment.c_str(), &gerror); + g_key_file_set_comment( + gobj(), Glib::c_str_or_nullptr(group_name), nullptr, comment.c_str(), &gerror); GLIBMM_THROW(gerror); } diff --git a/glib/src/markup.ccg b/glib/src/markup.ccg index f04b2fbf..4e2bf54e 100644 --- a/glib/src/markup.ccg +++ b/glib/src/markup.ccg @@ -20,28 +20,27 @@ #include #include - namespace Glib { namespace Markup { -Glib::ustring escape_text(const Glib::ustring& text) +Glib::ustring +escape_text(const Glib::ustring& text) { const auto buf = make_unique_ptr_gfree(g_markup_escape_text(text.data(), text.bytes())); return Glib::ustring(buf.get()); } - /**** Glib::Markup::AttributeKeyLess ***************************************/ -bool AttributeKeyLess::operator()(const Glib::ustring& lhs, const Glib::ustring& rhs) const +bool +AttributeKeyLess::operator()(const Glib::ustring& lhs, const Glib::ustring& rhs) const { return (lhs.raw() < rhs.raw()); } - /**** Glib::Markup::ParserCallbacks ****************************************/ class ParserCallbacks @@ -49,51 +48,29 @@ class ParserCallbacks public: static const GMarkupParser vfunc_table; - static void start_element(GMarkupParseContext* context, - const char* element_name, - const char** attribute_names, - const char** attribute_values, - void* user_data, - GError** error); - - static void end_element(GMarkupParseContext* context, - const char* element_name, - void* user_data, - GError** error); - - static void text(GMarkupParseContext* context, - const char* text, - gsize text_len, - void* user_data, - GError** error); - - static void passthrough(GMarkupParseContext* context, - const char* passthrough_text, - gsize text_len, - void* user_data, - GError** error); - - static void error(GMarkupParseContext* context, - GError* error, - void* user_data); -}; + static void start_element(GMarkupParseContext* context, const char* element_name, + const char** attribute_names, const char** attribute_values, void* user_data, GError** error); + static void end_element( + GMarkupParseContext* context, const char* element_name, void* user_data, GError** error); -const GMarkupParser ParserCallbacks::vfunc_table = -{ - &ParserCallbacks::start_element, - &ParserCallbacks::end_element, - &ParserCallbacks::text, - &ParserCallbacks::passthrough, - &ParserCallbacks::error, + static void text(GMarkupParseContext* context, const char* text, gsize text_len, void* user_data, + GError** error); + + static void passthrough(GMarkupParseContext* context, const char* passthrough_text, + gsize text_len, void* user_data, GError** error); + + static void error(GMarkupParseContext* context, GError* error, void* user_data); }; -void ParserCallbacks::start_element(GMarkupParseContext* context, - const char* element_name, - const char** attribute_names, - const char** attribute_values, - void* user_data, - GError** error) +const GMarkupParser ParserCallbacks::vfunc_table = { + &ParserCallbacks::start_element, &ParserCallbacks::end_element, &ParserCallbacks::text, + &ParserCallbacks::passthrough, &ParserCallbacks::error, +}; + +void +ParserCallbacks::start_element(GMarkupParseContext* context, const char* element_name, + const char** attribute_names, const char** attribute_values, void* user_data, GError** error) { ParseContext& cpp_context = *static_cast(user_data); g_return_if_fail(context == cpp_context.gobj()); @@ -102,12 +79,12 @@ void ParserCallbacks::start_element(GMarkupParseContext* context, { Parser::AttributeMap attributes; - if(attribute_names && attribute_values) + if (attribute_names && attribute_values) { - const char *const * pname = attribute_names; - const char *const * pvalue = attribute_values; + const char* const* pname = attribute_names; + const char* const* pvalue = attribute_values; - for(; *pname && *pvalue; ++pname, ++pvalue) + for (; *pname && *pvalue; ++pname, ++pvalue) attributes.insert(Parser::AttributeMap::value_type(*pname, *pvalue)); g_return_if_fail(*pname == nullptr && *pvalue == nullptr); @@ -115,20 +92,19 @@ void ParserCallbacks::start_element(GMarkupParseContext* context, cpp_context.get_parser()->on_start_element(cpp_context, element_name, attributes); } - catch(MarkupError& err) + catch (MarkupError& err) { err.propagate(error); } - catch(...) + catch (...) { Glib::exception_handlers_invoke(); } } -void ParserCallbacks::end_element(GMarkupParseContext* context, - const char* element_name, - void* user_data, - GError** error) +void +ParserCallbacks::end_element( + GMarkupParseContext* context, const char* element_name, void* user_data, GError** error) { ParseContext& cpp_context = *static_cast(user_data); g_return_if_fail(context == cpp_context.gobj()); @@ -137,21 +113,19 @@ void ParserCallbacks::end_element(GMarkupParseContext* context, { cpp_context.get_parser()->on_end_element(cpp_context, element_name); } - catch(MarkupError& err) + catch (MarkupError& err) { err.propagate(error); } - catch(...) + catch (...) { Glib::exception_handlers_invoke(); } } -void ParserCallbacks::text(GMarkupParseContext* context, - const char* text, - gsize text_len, - void* user_data, - GError** error) +void +ParserCallbacks::text( + GMarkupParseContext* context, const char* text, gsize text_len, void* user_data, GError** error) { ParseContext& cpp_context = *static_cast(user_data); g_return_if_fail(context == cpp_context.gobj()); @@ -160,21 +134,19 @@ void ParserCallbacks::text(GMarkupParseContext* context, { cpp_context.get_parser()->on_text(cpp_context, Glib::ustring(text, text + text_len)); } - catch(MarkupError& err) + catch (MarkupError& err) { err.propagate(error); } - catch(...) + catch (...) { Glib::exception_handlers_invoke(); } } -void ParserCallbacks::passthrough(GMarkupParseContext* context, - const char* passthrough_text, - gsize text_len, - void* user_data, - GError** error) +void +ParserCallbacks::passthrough(GMarkupParseContext* context, const char* passthrough_text, + gsize text_len, void* user_data, GError** error) { ParseContext& cpp_context = *static_cast(user_data); g_return_if_fail(context == cpp_context.gobj()); @@ -182,21 +154,20 @@ void ParserCallbacks::passthrough(GMarkupParseContext* context, try { cpp_context.get_parser()->on_passthrough( - cpp_context, Glib::ustring(passthrough_text, passthrough_text + text_len)); + cpp_context, Glib::ustring(passthrough_text, passthrough_text + text_len)); } - catch(MarkupError& err) + catch (MarkupError& err) { err.propagate(error); } - catch(...) + catch (...) { Glib::exception_handlers_invoke(); } } -void ParserCallbacks::error(GMarkupParseContext* context, - GError* error, - void* user_data) +void +ParserCallbacks::error(GMarkupParseContext* context, GError* error, void* user_data) { ParseContext& cpp_context = *static_cast(user_data); @@ -207,65 +178,75 @@ void ParserCallbacks::error(GMarkupParseContext* context, { cpp_context.get_parser()->on_error(cpp_context, MarkupError(g_error_copy(error))); } - catch(...) + catch (...) { Glib::exception_handlers_invoke(); } } - /**** Glib::Markup::Parser *************************************************/ Parser::Parser() -{} +{ +} -Parser::Parser(Parser&& other) noexcept -: sigc::trackable(std::move(other)) +Parser::Parser(Parser&& other) noexcept : sigc::trackable(std::move(other)) { } -Parser& Parser::operator=(Parser&& other) noexcept +Parser& +Parser::operator=(Parser&& other) noexcept { sigc::trackable::operator=(std::move(other)); return *this; } Parser::~Parser() -{} - -void Parser::on_start_element(ParseContext&, const Glib::ustring&, const Parser::AttributeMap&) -{} +{ +} -void Parser::on_end_element(ParseContext&, const Glib::ustring&) -{} +void +Parser::on_start_element(ParseContext&, const Glib::ustring&, const Parser::AttributeMap&) +{ +} -void Parser::on_text(ParseContext&, const Glib::ustring&) -{} +void +Parser::on_end_element(ParseContext&, const Glib::ustring&) +{ +} -void Parser::on_passthrough(ParseContext&, const Glib::ustring&) -{} +void +Parser::on_text(ParseContext&, const Glib::ustring&) +{ +} -void Parser::on_error(ParseContext&, const MarkupError&) -{} +void +Parser::on_passthrough(ParseContext&, const Glib::ustring&) +{ +} +void +Parser::on_error(ParseContext&, const MarkupError&) +{ +} /**** Glib::Markup::ParseContext *******************************************/ ParseContext::ParseContext(Parser& parser, ParseFlags flags) -: - parser_ (&parser), - gobject_ (g_markup_parse_context_new(&ParserCallbacks::vfunc_table, (GMarkupParseFlags) flags, - this, &ParseContext::destroy_notify_callback)) -{} - -ParseContext::ParseContext(ParseContext&& other) noexcept -: sigc::trackable(std::move(other)), - parser_(std::move(other.parser_)), - gobject_(std::move(other.gobject_)) +: parser_(&parser), + gobject_(g_markup_parse_context_new(&ParserCallbacks::vfunc_table, (GMarkupParseFlags)flags, this, + &ParseContext::destroy_notify_callback)) { } -ParseContext& ParseContext::operator=(ParseContext&& other) noexcept +ParseContext::ParseContext(ParseContext&& other) noexcept : sigc::trackable(std::move(other)), + parser_(std::move(other.parser_)), + gobject_(std::move(other.gobject_)) +{ +} + +ParseContext& +ParseContext::operator=(ParseContext&& other) noexcept { sigc::trackable::operator=(std::move(other)); @@ -284,47 +265,53 @@ ParseContext::~ParseContext() g_markup_parse_context_free(gobject_); } -void ParseContext::parse(const Glib::ustring& text) +void +ParseContext::parse(const Glib::ustring& text) { GError* error = nullptr; g_markup_parse_context_parse(gobject_, text.data(), text.bytes(), &error); - if(error) + if (error) Glib::Error::throw_exception(error); } -void ParseContext::parse(const char* text_begin, const char* text_end) +void +ParseContext::parse(const char* text_begin, const char* text_end) { GError* error = nullptr; g_markup_parse_context_parse(gobject_, text_begin, text_end - text_begin, &error); - if(error) + if (error) Glib::Error::throw_exception(error); } -void ParseContext::end_parse() +void +ParseContext::end_parse() { GError* error = nullptr; g_markup_parse_context_end_parse(gobject_, &error); - if(error) + if (error) Glib::Error::throw_exception(error); } -Glib::ustring ParseContext::get_element() const +Glib::ustring +ParseContext::get_element() const { - const char *const element_name = g_markup_parse_context_get_element(gobject_); + const char* const element_name = g_markup_parse_context_get_element(gobject_); return convert_const_gchar_ptr_to_ustring(element_name); } -int ParseContext::get_line_number() const +int +ParseContext::get_line_number() const { int line_number = 0; g_markup_parse_context_get_position(gobject_, &line_number, nullptr); return line_number; } -int ParseContext::get_char_number() const +int +ParseContext::get_char_number() const { int char_number = 0; g_markup_parse_context_get_position(gobject_, nullptr, &char_number); @@ -332,9 +319,10 @@ int ParseContext::get_char_number() const } // static -void ParseContext::destroy_notify_callback(void* data) +void +ParseContext::destroy_notify_callback(void* data) { - ParseContext *const self = static_cast(data); + ParseContext* const self = static_cast(data); // Detect premature destruction. g_return_if_fail(self->parser_ == nullptr); @@ -343,4 +331,3 @@ void ParseContext::destroy_notify_callback(void* data) } // namespace Markup } // namespace Glib - diff --git a/glib/src/miscutils.ccg b/glib/src/miscutils.ccg index c0600a6c..a6754c31 100644 --- a/glib/src/miscutils.ccg +++ b/glib/src/miscutils.ccg @@ -22,255 +22,282 @@ #include #include - namespace Glib { -Glib::ustring get_application_name() +Glib::ustring +get_application_name() { - return convert_const_gchar_ptr_to_ustring (g_get_application_name()); + return convert_const_gchar_ptr_to_ustring(g_get_application_name()); } -void set_application_name(const Glib::ustring& application_name) +void +set_application_name(const Glib::ustring& application_name) { g_set_application_name(application_name.c_str()); } -std::string get_prgname() +std::string +get_prgname() { return convert_const_gchar_ptr_to_stdstring(g_get_prgname()); } -void set_prgname(const std::string& prgname) +void +set_prgname(const std::string& prgname) { g_set_prgname(prgname.c_str()); } -std::string getenv(const std::string& variable, bool& found) +std::string +getenv(const std::string& variable, bool& found) { - const char *const value = g_getenv(variable.c_str()); + const char* const value = g_getenv(variable.c_str()); found = (value != nullptr); return convert_const_gchar_ptr_to_stdstring(value); } -std::string getenv(const std::string& variable) +std::string +getenv(const std::string& variable) { return convert_const_gchar_ptr_to_stdstring(g_getenv(variable.c_str())); } -bool setenv(const std::string& variable, const std::string& value, bool overwrite) +bool +setenv(const std::string& variable, const std::string& value, bool overwrite) { return g_setenv(variable.c_str(), value.c_str(), overwrite); } -void unsetenv(const std::string& variable) +void +unsetenv(const std::string& variable) { g_unsetenv(variable.c_str()); } -Glib::ArrayHandle listenv() +Glib::ArrayHandle +listenv() { - char **value = g_listenv(); - char **end = value; - while(*end){ + char** value = g_listenv(); + char** end = value; + while (*end) + { ++end; } - return Glib::ArrayHandle(value, end-value, Glib::OWNERSHIP_DEEP); + return Glib::ArrayHandle(value, end - value, Glib::OWNERSHIP_DEEP); } -std::string get_user_name() +std::string +get_user_name() { return convert_const_gchar_ptr_to_stdstring(g_get_user_name()); } -std::string get_real_name() +std::string +get_real_name() { return convert_const_gchar_ptr_to_stdstring(g_get_real_name()); } -std::string get_home_dir() +std::string +get_home_dir() { return convert_const_gchar_ptr_to_stdstring(g_get_home_dir()); } -std::string get_tmp_dir() +std::string +get_tmp_dir() { return convert_const_gchar_ptr_to_stdstring(g_get_tmp_dir()); } -std::string get_current_dir() +std::string +get_current_dir() { return convert_return_gchar_ptr_to_stdstring(g_get_current_dir()); } #ifndef GLIBMM_DISABLE_DEPRECATED -std::string get_user_special_dir(GUserDirectory directory) +std::string +get_user_special_dir(GUserDirectory directory) { return convert_const_gchar_ptr_to_stdstring(g_get_user_special_dir(directory)); } #endif // GLIBMM_DISABLE_DEPRECATED -std::string get_user_special_dir(UserDirectory directory) +std::string +get_user_special_dir(UserDirectory directory) { return convert_const_gchar_ptr_to_stdstring(g_get_user_special_dir((GUserDirectory)directory)); } -std::string get_user_data_dir() +std::string +get_user_data_dir() { return convert_const_gchar_ptr_to_stdstring(g_get_user_data_dir()); } -std::string get_user_config_dir() +std::string +get_user_config_dir() { return convert_const_gchar_ptr_to_stdstring(g_get_user_config_dir()); } -std::vector get_system_data_dirs() +std::vector +get_system_data_dirs() { - //TODO: Use a utility function: + // TODO: Use a utility function: std::vector result; - const char* const * cresult = g_get_system_data_dirs(); - if(!cresult) + const char* const* cresult = g_get_system_data_dirs(); + if (!cresult) return result; - for(const gchar* const * iter = cresult; *iter != nullptr; ++iter) + for (const gchar* const* iter = cresult; *iter != nullptr; ++iter) { - result.emplace_back( - convert_const_gchar_ptr_to_stdstring(*iter)); + result.emplace_back(convert_const_gchar_ptr_to_stdstring(*iter)); } return result; } -std::vector get_system_config_dirs() +std::vector +get_system_config_dirs() { - //TODO: Use a utility function: + // TODO: Use a utility function: std::vector result; - const char* const * cresult = g_get_system_config_dirs(); - if(!cresult) + const char* const* cresult = g_get_system_config_dirs(); + if (!cresult) return result; - for(const gchar* const * iter = cresult; *iter != nullptr; ++iter) + for (const gchar* const* iter = cresult; *iter != nullptr; ++iter) { - result.emplace_back( - convert_const_gchar_ptr_to_stdstring(*iter)); + result.emplace_back(convert_const_gchar_ptr_to_stdstring(*iter)); } return result; } -std::string get_user_cache_dir() +std::string +get_user_cache_dir() { return convert_const_gchar_ptr_to_stdstring(g_get_user_cache_dir()); } -bool path_is_absolute(const std::string& filename) +bool +path_is_absolute(const std::string& filename) { return (g_path_is_absolute(filename.c_str()) != 0); } -std::string path_skip_root(const std::string& filename) +std::string +path_skip_root(const std::string& filename) { // g_path_skip_root() returns a pointer _into_ the argument string, // or NULL if there was no root component. return convert_const_gchar_ptr_to_stdstring(g_path_skip_root(filename.c_str())); } -std::string path_get_basename(const std::string& filename) +std::string +path_get_basename(const std::string& filename) { return convert_return_gchar_ptr_to_stdstring(g_path_get_basename(filename.c_str())); } -std::string path_get_dirname(const std::string& filename) +std::string +path_get_dirname(const std::string& filename) { return convert_return_gchar_ptr_to_stdstring(g_path_get_dirname(filename.c_str())); } -std::string build_filename(const Glib::ArrayHandle& elements) +std::string +build_filename(const Glib::ArrayHandle& elements) { - return convert_return_gchar_ptr_to_stdstring(g_build_filenamev(const_cast(elements.data()))); + return convert_return_gchar_ptr_to_stdstring( + g_build_filenamev(const_cast(elements.data()))); } -std::string build_filename(const std::string& elem1, const std::string& elem2) +std::string +build_filename(const std::string& elem1, const std::string& elem2) { - return convert_return_gchar_ptr_to_stdstring(g_build_filename(elem1.c_str(), - elem2.c_str(), nullptr)); + return convert_return_gchar_ptr_to_stdstring( + g_build_filename(elem1.c_str(), elem2.c_str(), nullptr)); } -std::string build_filename(const std::string& elem1, const std::string& elem2, - const std::string& elem3) +std::string +build_filename(const std::string& elem1, const std::string& elem2, const std::string& elem3) { - return convert_return_gchar_ptr_to_stdstring(g_build_filename(elem1.c_str(), - elem2.c_str(), elem3.c_str(), nullptr)); + return convert_return_gchar_ptr_to_stdstring( + g_build_filename(elem1.c_str(), elem2.c_str(), elem3.c_str(), nullptr)); } -std::string build_filename(const std::string& elem1, const std::string& elem2, - const std::string& elem3, const std::string& elem4) +std::string +build_filename(const std::string& elem1, const std::string& elem2, const std::string& elem3, + const std::string& elem4) { - return convert_return_gchar_ptr_to_stdstring(g_build_filename(elem1.c_str(), - elem2.c_str(), elem3.c_str(), elem4.c_str(), nullptr)); + return convert_return_gchar_ptr_to_stdstring( + g_build_filename(elem1.c_str(), elem2.c_str(), elem3.c_str(), elem4.c_str(), nullptr)); } -std::string build_filename(const std::string& elem1, const std::string& elem2, - const std::string& elem3, const std::string& elem4, - const std::string& elem5) +std::string +build_filename(const std::string& elem1, const std::string& elem2, const std::string& elem3, + const std::string& elem4, const std::string& elem5) { - return convert_return_gchar_ptr_to_stdstring(g_build_filename(elem1.c_str(), - elem2.c_str(), elem3.c_str(), elem4.c_str(), elem5.c_str(), - nullptr)); + return convert_return_gchar_ptr_to_stdstring(g_build_filename( + elem1.c_str(), elem2.c_str(), elem3.c_str(), elem4.c_str(), elem5.c_str(), nullptr)); } -std::string build_filename(const std::string& elem1, const std::string& elem2, - const std::string& elem3, const std::string& elem4, - const std::string& elem5, const std::string& elem6) +std::string +build_filename(const std::string& elem1, const std::string& elem2, const std::string& elem3, + const std::string& elem4, const std::string& elem5, const std::string& elem6) { - return convert_return_gchar_ptr_to_stdstring(g_build_filename(elem1.c_str(), - elem2.c_str(), elem3.c_str(), elem4.c_str(), elem5.c_str(), elem6.c_str(), - nullptr)); + return convert_return_gchar_ptr_to_stdstring(g_build_filename(elem1.c_str(), elem2.c_str(), + elem3.c_str(), elem4.c_str(), elem5.c_str(), elem6.c_str(), nullptr)); } -std::string build_filename(const std::string& elem1, const std::string& elem2, - const std::string& elem3, const std::string& elem4, - const std::string& elem5, const std::string& elem6, - const std::string& elem7) +std::string +build_filename(const std::string& elem1, const std::string& elem2, const std::string& elem3, + const std::string& elem4, const std::string& elem5, const std::string& elem6, + const std::string& elem7) { - return convert_return_gchar_ptr_to_stdstring(g_build_filename(elem1.c_str(), - elem2.c_str(), elem3.c_str(), elem4.c_str(), elem5.c_str(), elem6.c_str(), - elem7.c_str(), nullptr)); + return convert_return_gchar_ptr_to_stdstring(g_build_filename(elem1.c_str(), elem2.c_str(), + elem3.c_str(), elem4.c_str(), elem5.c_str(), elem6.c_str(), elem7.c_str(), nullptr)); } -std::string build_filename(const std::string& elem1, const std::string& elem2, - const std::string& elem3, const std::string& elem4, - const std::string& elem5, const std::string& elem6, - const std::string& elem7, const std::string& elem8) +std::string +build_filename(const std::string& elem1, const std::string& elem2, const std::string& elem3, + const std::string& elem4, const std::string& elem5, const std::string& elem6, + const std::string& elem7, const std::string& elem8) { - return convert_return_gchar_ptr_to_stdstring(g_build_filename(elem1.c_str(), - elem2.c_str(), elem3.c_str(), elem4.c_str(), elem5.c_str(), elem6.c_str(), - elem7.c_str(), elem8.c_str(), nullptr)); + return convert_return_gchar_ptr_to_stdstring( + g_build_filename(elem1.c_str(), elem2.c_str(), elem3.c_str(), elem4.c_str(), elem5.c_str(), + elem6.c_str(), elem7.c_str(), elem8.c_str(), nullptr)); } -std::string build_filename(const std::string& elem1, const std::string& elem2, - const std::string& elem3, const std::string& elem4, - const std::string& elem5, const std::string& elem6, - const std::string& elem7, const std::string& elem8, - const std::string& elem9) +std::string +build_filename(const std::string& elem1, const std::string& elem2, const std::string& elem3, + const std::string& elem4, const std::string& elem5, const std::string& elem6, + const std::string& elem7, const std::string& elem8, const std::string& elem9) { - return convert_return_gchar_ptr_to_stdstring(g_build_filename(elem1.c_str(), - elem2.c_str(), elem3.c_str(), elem4.c_str(), elem5.c_str(), elem6.c_str(), - elem7.c_str(), elem8.c_str(), elem9.c_str(), nullptr)); + return convert_return_gchar_ptr_to_stdstring( + g_build_filename(elem1.c_str(), elem2.c_str(), elem3.c_str(), elem4.c_str(), elem5.c_str(), + elem6.c_str(), elem7.c_str(), elem8.c_str(), elem9.c_str(), nullptr)); } -std::string build_path(const std::string& separator, const Glib::ArrayHandle& elements) +std::string +build_path(const std::string& separator, const Glib::ArrayHandle& elements) { - return convert_return_gchar_ptr_to_stdstring(g_build_pathv(separator.c_str(), const_cast(elements.data()))); + return convert_return_gchar_ptr_to_stdstring( + g_build_pathv(separator.c_str(), const_cast(elements.data()))); } -std::string find_program_in_path(const std::string& program) +std::string +find_program_in_path(const std::string& program) { return convert_return_gchar_ptr_to_stdstring(g_find_program_in_path(program.c_str())); } -Glib::ustring format_size(guint64 size, FormatSizeFlags flags) +Glib::ustring +format_size(guint64 size, FormatSizeFlags flags) { return convert_return_gchar_ptr_to_ustring(g_format_size_full(size, (GFormatSizeFlags)flags)); } diff --git a/glib/src/module.ccg b/glib/src/module.ccg index bcce3e48..2cf23fd0 100644 --- a/glib/src/module.ccg +++ b/glib/src/module.ccg @@ -22,19 +22,19 @@ namespace Glib { Module::Module(const std::string& file_name, ModuleFlags flags) -: - gobject_ (g_module_open(file_name.c_str(), (GModuleFlags) flags)) -{} +: gobject_(g_module_open(file_name.c_str(), (GModuleFlags)flags)) +{ +} -Module::Module(Module&& other) noexcept -: gobject_(std::move(other.gobject_)) +Module::Module(Module&& other) noexcept : gobject_(std::move(other.gobject_)) { other.gobject_ = nullptr; } -Module& Module::operator=(Module&& other) noexcept +Module& +Module::operator=(Module&& other) noexcept { - if(gobject_) + if (gobject_) g_module_close(gobject_); gobject_ = std::move(other.gobject_); @@ -45,7 +45,7 @@ Module& Module::operator=(Module&& other) noexcept Module::~Module() { - if(gobject_) + if (gobject_) g_module_close(gobject_); } @@ -55,4 +55,3 @@ Module::operator bool() const } } // namespace Glib - diff --git a/glib/src/optioncontext.ccg b/glib/src/optioncontext.ccg index f38c54d8..ed05faa2 100644 --- a/glib/src/optioncontext.ccg +++ b/glib/src/optioncontext.ccg @@ -22,55 +22,56 @@ namespace Glib { - namespace OptionContextPrivate +namespace OptionContextPrivate +{ +static const gchar* +SignalProxy_translate_gtk_callback(const gchar* str, gpointer data) +{ + Glib::ustring translated_str; + Glib::OptionContext::SlotTranslate* the_slot = + static_cast(data); + + try { - static const gchar* SignalProxy_translate_gtk_callback (const gchar* str, gpointer data) - { - Glib::ustring translated_str; - Glib::OptionContext::SlotTranslate* the_slot = - static_cast(data); - - try - { - translated_str = (*the_slot)(str); - } - catch(...) - { - Glib::exception_handlers_invoke(); - } - return translated_str.c_str (); - } - - static void SignalProxy_translate_gtk_callback_destroy (gpointer data) - { - delete static_cast(data); - } - - } //namespace OptionContextPrivate + translated_str = (*the_slot)(str); + } + catch (...) + { + Glib::exception_handlers_invoke(); + } + return translated_str.c_str(); +} + +static void +SignalProxy_translate_gtk_callback_destroy(gpointer data) +{ + delete static_cast(data); +} + +} // namespace OptionContextPrivate OptionContext::OptionContext(const Glib::ustring& parameter_string) -: gobject_( g_option_context_new(parameter_string.c_str()) ), - has_ownership_(true) +: gobject_(g_option_context_new(parameter_string.c_str())), has_ownership_(true) { } OptionContext::OptionContext(GOptionContext* castitem, bool take_ownership) -: gobject_(castitem), - has_ownership_(take_ownership) +: gobject_(castitem), has_ownership_(take_ownership) { } OptionContext::OptionContext(OptionContext&& other) noexcept -: gobject_(std::move(other.gobject_)), - has_ownership_(std::move(other.has_ownership_)) + : gobject_(std::move(other.gobject_)), + has_ownership_(std::move(other.has_ownership_)) { other.gobject_ = nullptr; other.has_ownership_ = false; } -OptionContext& OptionContext::operator=(OptionContext&& other) noexcept +OptionContext& +OptionContext::operator=(OptionContext&& other) noexcept { - if(has_ownership_) + if (has_ownership_) g_option_context_free(gobj()); gobject_ = std::move(other.gobject_); @@ -84,25 +85,26 @@ OptionContext& OptionContext::operator=(OptionContext&& other) noexcept OptionContext::~OptionContext() { - if(has_ownership_) + if (has_ownership_) g_option_context_free(gobj()); gobject_ = nullptr; } -void OptionContext::add_group(OptionGroup& group) +void +OptionContext::add_group(OptionGroup& group) { - //Strangely, GObjectContext actually takes ownership of the GOptionGroup, deleting it later. + // Strangely, GObjectContext actually takes ownership of the GOptionGroup, deleting it later. g_option_context_add_group(gobj(), (group).gobj_give_ownership()); } -void OptionContext::set_main_group(OptionGroup& group) +void +OptionContext::set_main_group(OptionGroup& group) { - //Strangely, GObjectContext actually takes ownership of the GOptionGroup, deleting it later. + // Strangely, GObjectContext actually takes ownership of the GOptionGroup, deleting it later. g_option_context_set_main_group(gobj(), (group).gobj_give_ownership()); } - /* OptionGroup OptionContext::get_main_group() const { @@ -113,18 +115,21 @@ OptionGroup OptionContext::get_main_group() const */ -void OptionContext::set_translate_func (const SlotTranslate& slot) +void +OptionContext::set_translate_func(const SlotTranslate& slot) { - //Create a copy of the slot. A pointer to this will be passed through the callback's data parameter. - //It will be deleted when SignalProxy_translate_gtk_callback_destroy() is called. + // Create a copy of the slot. A pointer to this will be passed through the callback's data + // parameter. + // It will be deleted when SignalProxy_translate_gtk_callback_destroy() is called. auto slot_copy = new SlotTranslate(slot); - g_option_context_set_translate_func( - gobj(), &OptionContextPrivate::SignalProxy_translate_gtk_callback, slot_copy, - &OptionContextPrivate::SignalProxy_translate_gtk_callback_destroy); + g_option_context_set_translate_func(gobj(), + &OptionContextPrivate::SignalProxy_translate_gtk_callback, slot_copy, + &OptionContextPrivate::SignalProxy_translate_gtk_callback_destroy); } -Glib::ustring OptionContext::get_help(bool main_help) const +Glib::ustring +OptionContext::get_help(bool main_help) const { return Glib::convert_return_gchar_ptr_to_ustring(g_option_context_get_help( const_cast(gobj()), static_cast(main_help), nullptr)); diff --git a/glib/src/optionentry.ccg b/glib/src/optionentry.ccg index 49810c4d..0a807a51 100644 --- a/glib/src/optionentry.ccg +++ b/glib/src/optionentry.ccg @@ -31,9 +31,10 @@ OptionEntry::~OptionEntry() release_gobject(); } -void OptionEntry::release_gobject() noexcept +void +OptionEntry::release_gobject() noexcept { - if(!gobject_) + if (!gobject_) return; g_free(const_cast(gobject_->long_name)); @@ -49,27 +50,30 @@ OptionEntry::OptionEntry(const OptionEntry& src) operator=(src); } -OptionEntry& OptionEntry::operator=(const OptionEntry& src) +OptionEntry& +OptionEntry::operator=(const OptionEntry& src) { - if(this != &src) + if (this != &src) { - if(gobject_->long_name) + if (gobject_->long_name) g_free(const_cast(gobject_->long_name)); gobject_->long_name = g_strdup(src.gobject_->long_name); - gobject_->short_name = src.gobject_->short_name; //It's just one char. + gobject_->short_name = src.gobject_->short_name; // It's just one char. gobject_->flags = src.gobject_->flags; gobject_->arg = src.gobject_->arg; - gobject_->arg_data = src.gobject_->arg_data; //Shared, because it's not owned by any instance of this class anyway. + gobject_->arg_data = + src.gobject_ + ->arg_data; // Shared, because it's not owned by any instance of this class anyway. - if(gobject_->description) + if (gobject_->description) g_free(const_cast(gobject_->description)); gobject_->description = g_strdup(src.gobject_->description); - if(gobject_->arg_description) + if (gobject_->arg_description) g_free(const_cast(gobject_->arg_description)); gobject_->arg_description = g_strdup(src.gobject_->arg_description); @@ -78,13 +82,13 @@ OptionEntry& OptionEntry::operator=(const OptionEntry& src) return *this; } -OptionEntry::OptionEntry(OptionEntry&& other) noexcept -: gobject_(std::move(other.gobject_)) +OptionEntry::OptionEntry(OptionEntry&& other) noexcept : gobject_(std::move(other.gobject_)) { other.gobject_ = nullptr; } -OptionEntry& OptionEntry::operator=(OptionEntry&& other) noexcept +OptionEntry& +OptionEntry::operator=(OptionEntry&& other) noexcept { release_gobject(); @@ -94,23 +98,26 @@ OptionEntry& OptionEntry::operator=(OptionEntry&& other) noexcept return *this; } -void OptionEntry::set_long_name(const Glib::ustring& value) +void +OptionEntry::set_long_name(const Glib::ustring& value) { - if(gobject_->long_name) + if (gobject_->long_name) { g_free((gchar*)(gobject_->long_name)); gobject_->long_name = nullptr; } - //Note that we do not use nullptr for an empty string, - //because G_OPTION_REMAINING is actually a "", so it actually has a distinct meaning: - //TODO: Wrap G_OPTION_REMAINING in C++ somehow, maybe as an explicit set_long_name(void) or set_is_remaining()? murrayc. + // Note that we do not use nullptr for an empty string, + // because G_OPTION_REMAINING is actually a "", so it actually has a distinct meaning: + // TODO: Wrap G_OPTION_REMAINING in C++ somehow, maybe as an explicit set_long_name(void) or + // set_is_remaining()? murrayc. gobj()->long_name = (value).c_str() ? g_strdup((value).c_str()) : nullptr; } -void OptionEntry::set_description(const Glib::ustring& value) +void +OptionEntry::set_description(const Glib::ustring& value) { - if(gobject_->description) + if (gobject_->description) { g_free((gchar*)(gobject_->description)); gobject_->description = nullptr; @@ -119,9 +126,10 @@ void OptionEntry::set_description(const Glib::ustring& value) gobj()->description = (value).empty() ? nullptr : g_strdup((value).c_str()); } -void OptionEntry::set_arg_description(const Glib::ustring& value) +void +OptionEntry::set_arg_description(const Glib::ustring& value) { - if(gobject_->arg_description) + if (gobject_->arg_description) { g_free((gchar*)(gobject_->arg_description)); gobject_->arg_description = nullptr; @@ -130,6 +138,4 @@ void OptionEntry::set_arg_description(const Glib::ustring& value) gobj()->arg_description = (value).empty() ? nullptr : g_strdup((value).c_str()); } - } // namespace Glib - diff --git a/glib/src/optiongroup.ccg b/glib/src/optiongroup.ccg index 56236e4d..20f3ae15 100644 --- a/glib/src/optiongroup.ccg +++ b/glib/src/optiongroup.ccg @@ -26,30 +26,29 @@ namespace Glib { -namespace //anonymous +namespace // anonymous { -//A pointer to an OptionArgCallback instance is stored in CppOptionEntry::cpparg_ -//when a callback function shall parse the command option's value. +// A pointer to an OptionArgCallback instance is stored in CppOptionEntry::cpparg_ +// when a callback function shall parse the command option's value. class OptionArgCallback { public: explicit OptionArgCallback(const OptionGroup::SlotOptionArgString& slot) : slot_string_(new OptionGroup::SlotOptionArgString(slot)), slot_filename_(nullptr) - { } + { + } explicit OptionArgCallback(const OptionGroup::SlotOptionArgFilename& slot) : slot_string_(nullptr), slot_filename_(new OptionGroup::SlotOptionArgFilename(slot)) - { } + { + } - bool is_filename_option() const - { return slot_filename_ != nullptr; } + bool is_filename_option() const { return slot_filename_ != nullptr; } - const OptionGroup::SlotOptionArgString* get_slot_string() const - { return slot_string_; } + const OptionGroup::SlotOptionArgString* get_slot_string() const { return slot_string_; } - const OptionGroup::SlotOptionArgFilename* get_slot_filename() const - { return slot_filename_; } + const OptionGroup::SlotOptionArgFilename* get_slot_filename() const { return slot_filename_; } ~OptionArgCallback() { @@ -58,28 +57,29 @@ public: } private: - //One of these slot pointers is 0 and the other one points to a slot. + // One of these slot pointers is 0 and the other one points to a slot. OptionGroup::SlotOptionArgString* slot_string_; OptionGroup::SlotOptionArgFilename* slot_filename_; - //Not copyable + // Not copyable OptionArgCallback(const OptionArgCallback&); OptionArgCallback& operator=(const OptionArgCallback&); }; -extern "C" -{ +extern "C" { -static gboolean g_callback_pre_parse(GOptionContext* context, - GOptionGroup* /* group */, gpointer data, GError** error) +static gboolean +g_callback_pre_parse( + GOptionContext* context, GOptionGroup* /* group */, gpointer data, GError** error) { OptionContext cppContext(context, false /* take_ownership */); auto option_group = static_cast(data); - if(!option_group) + if (!option_group) { OptionError(OptionError::FAILED, "Glib::OptionGroup: g_callback_pre_parse(): " - "No OptionGroup pointer available").propagate(error); + "No OptionGroup pointer available") + .propagate(error); return false; } @@ -87,19 +87,20 @@ static gboolean g_callback_pre_parse(GOptionContext* context, { return option_group->on_pre_parse(cppContext, *option_group); } - catch(Glib::Error& err) + catch (Glib::Error& err) { err.propagate(error); } - catch(...) + catch (...) { Glib::exception_handlers_invoke(); } return false; } -static void g_callback_error(GOptionContext* context, - GOptionGroup* /* group */, gpointer data, GError** /* TODO error */) +static void +g_callback_error( + GOptionContext* context, GOptionGroup* /* group */, gpointer data, GError** /* TODO error */) { // TODO GError** error is input data containing information on an error that // has occurred before this function is called. When API can be broken, @@ -109,22 +110,21 @@ static void g_callback_error(GOptionContext* context, OptionContext cppContext(context, false /* take_ownership */); auto option_group = static_cast(data); - if(option_group) + if (option_group) return option_group->on_error(cppContext, *option_group); } -const gchar* OptionGroup_Translate_glibmm_callback(const gchar* string, - gpointer data) +const gchar* +OptionGroup_Translate_glibmm_callback(const gchar* string, gpointer data) { - Glib::OptionGroup::SlotTranslate* the_slot = - static_cast(data); + Glib::OptionGroup::SlotTranslate* the_slot = static_cast(data); try { // The C docs says that the char* belongs to Glib. return g_strdup((*the_slot)(Glib::ustring(string)).c_str()); } - catch(...) + catch (...) { Glib::exception_handlers_invoke(); } @@ -132,32 +132,35 @@ const gchar* OptionGroup_Translate_glibmm_callback(const gchar* string, return nullptr; } -static void OptionGroup_Translate_glibmm_callback_destroy(void* data) +static void +OptionGroup_Translate_glibmm_callback_destroy(void* data) { delete static_cast(data); } } /* extern "C" */ -} //anonymous namespace +} // anonymous namespace -//static -gboolean OptionGroup::post_parse_callback(GOptionContext* context, - GOptionGroup* /* group */, gpointer data, GError** error) +// static +gboolean +OptionGroup::post_parse_callback( + GOptionContext* context, GOptionGroup* /* group */, gpointer data, GError** error) { OptionContext cppContext(context, false /* take_ownership */); OptionGroup* option_group = static_cast(data); - if(!option_group) + if (!option_group) { OptionError(OptionError::FAILED, "Glib::OptionGroup::post_parse_callback(): " - "No OptionGroup pointer available").propagate(error); + "No OptionGroup pointer available") + .propagate(error); return false; } - //The C args have now been given values by g_option_context_parse(). - //Convert C values to C++ values: - for(auto& the_pair : option_group->map_entries_) + // The C args have now been given values by g_option_context_parse(). + // Convert C values to C++ values: + for (auto& the_pair : option_group->map_entries_) { auto& cpp_entry = the_pair.second; cpp_entry.convert_c_to_cpp(); @@ -167,57 +170,61 @@ gboolean OptionGroup::post_parse_callback(GOptionContext* context, { return option_group->on_post_parse(cppContext, *option_group); } - catch(Glib::Error& err) + catch (Glib::Error& err) { err.propagate(error); } - catch(...) + catch (...) { Glib::exception_handlers_invoke(); } return false; } -//static -gboolean OptionGroup::option_arg_callback(const gchar* option_name, const gchar* value, - gpointer data, GError** error) +// static +gboolean +OptionGroup::option_arg_callback( + const gchar* option_name, const gchar* value, gpointer data, GError** error) { const Glib::ustring cpp_option_name(option_name); const OptionGroup* const option_group = static_cast(data); - if(!option_group) + if (!option_group) { OptionError(OptionError::FAILED, "Glib::OptionGroup::option_arg_callback(): " - "No OptionGroup pointer available for option " + cpp_option_name).propagate(error); + "No OptionGroup pointer available for option " + + cpp_option_name) + .propagate(error); return false; } - //option_name is either a single dash followed by a single letter (for a - //short name) or two dashes followed by a long option name. + // option_name is either a single dash followed by a single letter (for a + // short name) or two dashes followed by a long option name. OptionGroup::type_map_entries::const_iterator iterFind = option_group->map_entries_.end(); - if(option_name[1] == '-') + if (option_name[1] == '-') { - //Long option name. - const auto long_option_name = Glib::ustring(option_name+2); + // Long option name. + const auto long_option_name = Glib::ustring(option_name + 2); iterFind = option_group->map_entries_.find(long_option_name); } else { - //Short option name. + // Short option name. const auto short_option_name = option_name[1]; - for(iterFind = option_group->map_entries_.begin(); - iterFind != option_group->map_entries_.end(); ++iterFind) + for (iterFind = option_group->map_entries_.begin(); + iterFind != option_group->map_entries_.end(); ++iterFind) { const auto& cppOptionEntry = iterFind->second; - if (cppOptionEntry.entry_ && - cppOptionEntry.entry_->get_short_name() == short_option_name) + if (cppOptionEntry.entry_ && cppOptionEntry.entry_->get_short_name() == short_option_name) break; } } - if(iterFind == option_group->map_entries_.end()) + if (iterFind == option_group->map_entries_.end()) { OptionError(OptionError::UNKNOWN_OPTION, "Glib::OptionGroup::option_arg_callback(): " - "Unknown option " + cpp_option_name).propagate(error); + "Unknown option " + + cpp_option_name) + .propagate(error); return false; } @@ -225,7 +232,9 @@ gboolean OptionGroup::option_arg_callback(const gchar* option_name, const gchar* if (cppOptionEntry.carg_type_ != G_OPTION_ARG_CALLBACK) { OptionError(OptionError::FAILED, "Glib::OptionGroup::option_arg_callback() " - "called for non-callback option " + cpp_option_name).propagate(error); + "called for non-callback option " + + cpp_option_name) + .propagate(error); return false; } @@ -247,50 +256,50 @@ gboolean OptionGroup::option_arg_callback(const gchar* option_name, const gchar* return (*the_slot)(cpp_option_name, cpp_value, has_value); } } - catch(Glib::Error& err) + catch (Glib::Error& err) { err.propagate(error); } - catch(...) + catch (...) { Glib::exception_handlers_invoke(); } return false; } -OptionGroup::OptionGroup(const Glib::ustring& name, const Glib::ustring& description, const Glib::ustring& help_description) -: gobject_( g_option_group_new(name.c_str(), description.c_str(), help_description.c_str(), - this /* user_data */, nullptr /* destroy_func */) ), +OptionGroup::OptionGroup(const Glib::ustring& name, const Glib::ustring& description, + const Glib::ustring& help_description) +: gobject_(g_option_group_new(name.c_str(), description.c_str(), help_description.c_str(), + this /* user_data */, nullptr /* destroy_func */)), has_ownership_(true) { - //g_callback_pre_parse(), post_parse_callback(), g_callback_error(), and - //option_arg_callback() depend on user_data being this. The first three - //functions get a GOptionGroup*, but it would not be correct to use it for - //creating a new OptionGroup. They must call their virtual functions in the - //original OptionGroup instance. + // g_callback_pre_parse(), post_parse_callback(), g_callback_error(), and + // option_arg_callback() depend on user_data being this. The first three + // functions get a GOptionGroup*, but it would not be correct to use it for + // creating a new OptionGroup. They must call their virtual functions in the + // original OptionGroup instance. - //Connect callbacks, so that derived classes can override the virtual methods: + // Connect callbacks, so that derived classes can override the virtual methods: g_option_group_set_parse_hooks(gobj(), &g_callback_pre_parse, &post_parse_callback); g_option_group_set_error_hook(gobj(), &g_callback_error); } -OptionGroup::OptionGroup(GOptionGroup* castitem) -: gobject_(castitem), - has_ownership_(true) +OptionGroup::OptionGroup(GOptionGroup* castitem) : gobject_(castitem), has_ownership_(true) { - //Always takes ownership - never takes copy. + // Always takes ownership - never takes copy. } OptionGroup::OptionGroup(OptionGroup&& other) noexcept -: map_entries_(std::move(other.map_entries_)), - gobject_(std::move(other.gobject_)), - has_ownership_(std::move(other.has_ownership_)) + : map_entries_(std::move(other.map_entries_)), + gobject_(std::move(other.gobject_)), + has_ownership_(std::move(other.has_ownership_)) { other.gobject_ = nullptr; other.has_ownership_ = false; } -OptionGroup& OptionGroup::operator=(OptionGroup&& other) noexcept +OptionGroup& +OptionGroup::operator=(OptionGroup&& other) noexcept { release_gobject(); @@ -304,16 +313,17 @@ OptionGroup& OptionGroup::operator=(OptionGroup&& other) noexcept return *this; } -void OptionGroup::release_gobject() noexcept +void +OptionGroup::release_gobject() noexcept { - //Free any C types that were allocated during add_entry(): - for(auto& the_pair : map_entries_) + // Free any C types that were allocated during add_entry(): + for (auto& the_pair : map_entries_) { auto& cpp_entry = the_pair.second; cpp_entry.release_c_arg(); } - if(has_ownership_ && gobject_) + if (has_ownership_ && gobject_) { g_option_group_unref(gobj()); gobject_ = nullptr; @@ -325,52 +335,63 @@ OptionGroup::~OptionGroup() release_gobject(); } -void OptionGroup::add_entry(const OptionEntry& entry) +void +OptionGroup::add_entry(const OptionEntry& entry) { - //It does not copy the entry, so it needs to live as long as the group. + // It does not copy the entry, so it needs to live as long as the group. - //g_option_group_add_entries takes an array, with the last item in the array having a null long_name. - //Hopefully this will be properly documented eventually - see bug # + // g_option_group_add_entries takes an array, with the last item in the array having a null + // long_name. + // Hopefully this will be properly documented eventually - see bug # - //Create a temporary array, just so we can give the correct thing to g_option_group_add_entries: + // Create a temporary array, just so we can give the correct thing to g_option_group_add_entries: GOptionEntry array[2]; - array[0] = *(entry.gobj()); //Copy contents. + array[0] = *(entry.gobj()); // Copy contents. std::memset(&array[1], 0, sizeof(GOptionEntry)); g_option_group_add_entries(gobj(), array); } -void OptionGroup::add_entry(const OptionEntry& entry, bool& arg) +void +OptionGroup::add_entry(const OptionEntry& entry, bool& arg) { - add_entry_with_wrapper(entry, G_OPTION_ARG_NONE /* Actually a boolean on/off, depending on whether the argument name was given, without argument parameters. */, &arg); + add_entry_with_wrapper(entry, + G_OPTION_ARG_NONE /* Actually a boolean on/off, depending on whether the argument name was given, without argument parameters. */, + &arg); } -void OptionGroup::add_entry(const OptionEntry& entry, int& arg) +void +OptionGroup::add_entry(const OptionEntry& entry, int& arg) { add_entry_with_wrapper(entry, G_OPTION_ARG_INT, &arg); } -void OptionGroup::add_entry(const OptionEntry& entry, double& arg) +void +OptionGroup::add_entry(const OptionEntry& entry, double& arg) { add_entry_with_wrapper(entry, G_OPTION_ARG_DOUBLE, &arg); } -void OptionGroup::add_entry(const OptionEntry& entry, Glib::ustring& arg) +void +OptionGroup::add_entry(const OptionEntry& entry, Glib::ustring& arg) { add_entry_with_wrapper(entry, G_OPTION_ARG_STRING, &arg); } -void OptionGroup::add_entry(const OptionEntry& entry, vecustrings& arg) +void +OptionGroup::add_entry(const OptionEntry& entry, vecustrings& arg) { add_entry_with_wrapper(entry, G_OPTION_ARG_STRING_ARRAY, &arg); } -void OptionGroup::add_entry_filename(const OptionEntry& entry, std::string& arg) +void +OptionGroup::add_entry_filename(const OptionEntry& entry, std::string& arg) { add_entry_with_wrapper(entry, G_OPTION_ARG_FILENAME, &arg); } -void OptionGroup::add_entry_filename(const OptionEntry& entry, vecstrings& arg) +void +OptionGroup::add_entry_filename(const OptionEntry& entry, vecstrings& arg) { add_entry_with_wrapper(entry, G_OPTION_ARG_FILENAME_ARRAY, &arg); } @@ -387,28 +408,31 @@ void OptionGroup::add_entry_filename(const OptionEntry& entry, vecstrings& arg) // with G_OPTION_FLAG_FILENAME. We do this automatiically in set_c_arg_default(). // Other option flags are set by OptionEntry::set_flags(). -void OptionGroup::add_entry(const OptionEntry& entry, const SlotOptionArgString& slot) +void +OptionGroup::add_entry(const OptionEntry& entry, const SlotOptionArgString& slot) { - //The OptionArgCallback is deleted in release_c_arg(). + // The OptionArgCallback is deleted in release_c_arg(). add_entry_with_wrapper(entry, G_OPTION_ARG_CALLBACK, new OptionArgCallback(slot)); } -void OptionGroup::add_entry_filename(const OptionEntry& entry, const SlotOptionArgFilename& slot) +void +OptionGroup::add_entry_filename(const OptionEntry& entry, const SlotOptionArgFilename& slot) { - //The OptionArgCallback is deleted in release_c_arg(). + // The OptionArgCallback is deleted in release_c_arg(). add_entry_with_wrapper(entry, G_OPTION_ARG_CALLBACK, new OptionArgCallback(slot)); } -void OptionGroup::add_entry_with_wrapper(const OptionEntry& entry, GOptionArg arg_type, void* cpp_arg) +void +OptionGroup::add_entry_with_wrapper(const OptionEntry& entry, GOptionArg arg_type, void* cpp_arg) { const auto name = entry.get_long_name(); type_map_entries::iterator iterFind = map_entries_.find(name); - if (iterFind == map_entries_.end()) //If we have not added this entry already + if (iterFind == map_entries_.end()) // If we have not added this entry already { CppOptionEntry cppEntry; - //g_option_group_add_entry() does not take its own copy, so we must keep the instance alive. + // g_option_group_add_entry() does not take its own copy, so we must keep the instance alive. cppEntry.entry_ = new OptionEntry(entry); - //cppEntry.entry_ is deleted in release_c_arg(), via the destructor. + // cppEntry.entry_ is deleted in release_c_arg(), via the destructor. // Several options can refer to the same C++ variable, // typically a pair of --enable-x / --disable-x options. @@ -418,13 +442,11 @@ void OptionGroup::add_entry_with_wrapper(const OptionEntry& entry, GOptionArg ar void* carg = nullptr; if (arg_type != G_OPTION_ARG_CALLBACK) { - for (type_map_entries::iterator iter = map_entries_.begin(); - iter != map_entries_.end(); ++iter) + for (type_map_entries::iterator iter = map_entries_.begin(); iter != map_entries_.end(); + ++iter) { const auto& cpp_entry = iter->second; - if (cpp_entry.cpparg_ == cpp_arg && - cpp_entry.carg_type_ == arg_type && - cpp_entry.carg_) + if (cpp_entry.cpparg_ == cpp_arg && cpp_entry.carg_type_ == arg_type && cpp_entry.carg_) { is_duplicate = true; carg = cpp_entry.carg_; @@ -442,386 +464,394 @@ void OptionGroup::add_entry_with_wrapper(const OptionEntry& entry, GOptionArg ar } cppEntry.cpparg_ = cpp_arg; - //Give the information to the C API: + // Give the information to the C API: cppEntry.entry_->gobj()->arg = arg_type; cppEntry.entry_->gobj()->arg_data = carg; - //Remember the C++/C mapping so that we can use it later: + // Remember the C++/C mapping so that we can use it later: map_entries_[name] = cppEntry; add_entry(*(cppEntry.entry_)); } else if (arg_type == G_OPTION_ARG_CALLBACK) { - //Delete the OptionArgCallback instance that was allocated by add_entry() - //or add_entry_filename(). + // Delete the OptionArgCallback instance that was allocated by add_entry() + // or add_entry_filename(). auto option_arg = static_cast(cpp_arg); delete option_arg; } } - -bool OptionGroup::on_pre_parse(OptionContext& /* context */, OptionGroup& /* group */) +bool +OptionGroup::on_pre_parse(OptionContext& /* context */, OptionGroup& /* group */) { return true; } -bool OptionGroup::on_post_parse(OptionContext& /* context */, OptionGroup& /* group */) +bool +OptionGroup::on_post_parse(OptionContext& /* context */, OptionGroup& /* group */) { return true; } -void OptionGroup::on_error(OptionContext& /* context */, OptionGroup& /* group */) +void +OptionGroup::on_error(OptionContext& /* context */, OptionGroup& /* group */) { } -void OptionGroup::set_translate_func(const SlotTranslate& slot) +void +OptionGroup::set_translate_func(const SlotTranslate& slot) { // Create a copy of the slot. A pointer to this will be passed through the // callback's data parameter. It will be deleted when // OptionGroup_Translate_glibmm_callback_destroy() is called. auto slot_copy = new SlotTranslate(slot); - g_option_group_set_translate_func(gobj(), - &OptionGroup_Translate_glibmm_callback, slot_copy, + g_option_group_set_translate_func(gobj(), &OptionGroup_Translate_glibmm_callback, slot_copy, &OptionGroup_Translate_glibmm_callback_destroy); } - OptionGroup::CppOptionEntry::CppOptionEntry() : carg_type_(G_OPTION_ARG_NONE), carg_(nullptr), cpparg_(nullptr), entry_(nullptr) -{} +{ +} -void OptionGroup::CppOptionEntry::allocate_c_arg() +void +OptionGroup::CppOptionEntry::allocate_c_arg() { - //Create an instance of the appropriate C type. - //This will be destroyed in the OptionGroup destructor. + // Create an instance of the appropriate C type. + // This will be destroyed in the OptionGroup destructor. // - //We must also call set_c_arg_default() to give these C types the specified - //defaults based on the C++-typed arguments. - switch(carg_type_) + // We must also call set_c_arg_default() to give these C types the specified + // defaults based on the C++-typed arguments. + switch (carg_type_) { - case G_OPTION_ARG_STRING: //The char* will be for UTF8 a string. - case G_OPTION_ARG_FILENAME: //The char* will be for a string in the current locale's encoding. - { - char** typed_arg = new char*; - //The C code will allocate a char* and put it here, for us to g_free() later. - *typed_arg = nullptr; - carg_ = typed_arg; + case G_OPTION_ARG_STRING: // The char* will be for UTF8 a string. + case G_OPTION_ARG_FILENAME: // The char* will be for a string in the current locale's encoding. + { + char** typed_arg = new char*; + // The C code will allocate a char* and put it here, for us to g_free() later. + *typed_arg = nullptr; + carg_ = typed_arg; - break; - } - case G_OPTION_ARG_INT: - { - int* typed_arg = new int; - *typed_arg = 0; - carg_ = typed_arg; + break; + } + case G_OPTION_ARG_INT: + { + int* typed_arg = new int; + *typed_arg = 0; + carg_ = typed_arg; - break; - } - case G_OPTION_ARG_DOUBLE: - { - double* typed_arg = new double; - *typed_arg = 0.0; - carg_ = typed_arg; + break; + } + case G_OPTION_ARG_DOUBLE: + { + double* typed_arg = new double; + *typed_arg = 0.0; + carg_ = typed_arg; - break; - } - case G_OPTION_ARG_STRING_ARRAY: - case G_OPTION_ARG_FILENAME_ARRAY: - { - char*** typed_arg = new char**; - //The C code will allocate a char** and put it here, for us to g_strfreev() later. - *typed_arg = nullptr; - carg_ = typed_arg; + break; + } + case G_OPTION_ARG_STRING_ARRAY: + case G_OPTION_ARG_FILENAME_ARRAY: + { + char*** typed_arg = new char**; + // The C code will allocate a char** and put it here, for us to g_strfreev() later. + *typed_arg = nullptr; + carg_ = typed_arg; - break; - } - case G_OPTION_ARG_NONE: // Actually a boolean. - { - gboolean* typed_arg = new gboolean; - *typed_arg = false; - carg_ = typed_arg; + break; + } + case G_OPTION_ARG_NONE: // Actually a boolean. + { + gboolean* typed_arg = new gboolean; + *typed_arg = false; + carg_ = typed_arg; - break; - } - case G_OPTION_ARG_CALLBACK: - { - //The C arg pointer is a function pointer, cast to void*. - union { - void* dp; - GOptionArgFunc fp; - } u; - u.fp = &OptionGroup::option_arg_callback; - carg_ = u.dp; - - // With all compiler warnings turned on and a high optimization level - // it's difficult to cast a function pointer to a void*. See bug 589197. - // A few results with g++ 4.4.5 with the flags -pedantic -O2 -Werror: - // - // carg_ = reinterpret_cast(&OptionGroup::option_arg_callback); - // error: ISO C++ forbids casting between pointer-to-function and pointer-to-object - // - // *reinterpret_cast(&carg_) = &OptionGroup::option_arg_callback; - // *(OptionArgFunc*)&carg_ = &OptionGroup::option_arg_callback; - // error: dereferencing type-punned pointer will break strict-aliasing rules - // - // If any compiler dislikes the union, the following code is worth testing: - // carg_ = reinterpret_cast( - // reinterpret_cast(&OptionGroup::option_arg_callback)); + break; + } + case G_OPTION_ARG_CALLBACK: + { + // The C arg pointer is a function pointer, cast to void*. + union { + void* dp; + GOptionArgFunc fp; + } u; + u.fp = &OptionGroup::option_arg_callback; + carg_ = u.dp; + + // With all compiler warnings turned on and a high optimization level + // it's difficult to cast a function pointer to a void*. See bug 589197. + // A few results with g++ 4.4.5 with the flags -pedantic -O2 -Werror: + // + // carg_ = reinterpret_cast(&OptionGroup::option_arg_callback); + // error: ISO C++ forbids casting between pointer-to-function and pointer-to-object + // + // *reinterpret_cast(&carg_) = &OptionGroup::option_arg_callback; + // *(OptionArgFunc*)&carg_ = &OptionGroup::option_arg_callback; + // error: dereferencing type-punned pointer will break strict-aliasing rules + // + // If any compiler dislikes the union, the following code is worth testing: + // carg_ = reinterpret_cast( + // reinterpret_cast(&OptionGroup::option_arg_callback)); + + break; + } + default: + { + break; + } + } +} - break; +void +OptionGroup::CppOptionEntry::set_c_arg_default(void* cpp_arg) +{ + switch (carg_type_) + { + case G_OPTION_ARG_INT: + { + *static_cast(carg_) = *static_cast(cpp_arg); + break; + } + case G_OPTION_ARG_DOUBLE: + { + *static_cast(carg_) = *static_cast(cpp_arg); + break; + } + case G_OPTION_ARG_NONE: + { + *static_cast(carg_) = *static_cast(cpp_arg); + break; + } + case G_OPTION_ARG_STRING: + case G_OPTION_ARG_FILENAME: + case G_OPTION_ARG_STRING_ARRAY: + case G_OPTION_ARG_FILENAME_ARRAY: + { + // No need to set default values for string-valued options. + // If *carg_ is still 0, when convert_c_to_cpp() is called, just don't + // touch *cpparg_. Besides, setting default values in *carg_ can result + // in memory leaks, because glib would not free the strings before + // the char*'s are overwritten with pointers to newly allocated copies + // of the command option arguments. + break; + } + case G_OPTION_ARG_CALLBACK: + { + // No value to set here. The arg pointer is a function pointer. + + // Set or clear FLAG_FILENAME in *entry_. + const OptionArgCallback* const option_arg = static_cast(cpp_arg); + if (option_arg->is_filename_option()) + { + entry_->set_flags(entry_->get_flags() | OptionEntry::FLAG_FILENAME); } - default: + else { - break; + entry_->set_flags(entry_->get_flags() & ~OptionEntry::FLAG_FILENAME); } + break; + } + default: + { + break; + } } } -void OptionGroup::CppOptionEntry::set_c_arg_default(void* cpp_arg) +void +OptionGroup::CppOptionEntry::release_c_arg() { - switch(carg_type_) + // Delete the instances that we created in allocate_c_arg(). + // Notice that we delete the type that we created, but not the value to which it points. + if (carg_) { - case G_OPTION_ARG_INT: + switch (carg_type_) { - *static_cast(carg_) = *static_cast(cpp_arg); + case G_OPTION_ARG_STRING: + case G_OPTION_ARG_FILENAME: + { + char** typed_arg = static_cast(carg_); + g_free(*typed_arg); // Free the char* string at typed_arg, if allocated by the C code. + delete typed_arg; // Delete the char** that we allocated in allocate_c_arg(). + break; } - case G_OPTION_ARG_DOUBLE: + case G_OPTION_ARG_INT: { - *static_cast(carg_) = *static_cast(cpp_arg); + int* typed_arg = static_cast(carg_); + delete typed_arg; + break; } - case G_OPTION_ARG_NONE: + case G_OPTION_ARG_DOUBLE: { - *static_cast(carg_) = *static_cast(cpp_arg); + double* typed_arg = static_cast(carg_); + delete typed_arg; + break; } - case G_OPTION_ARG_STRING: - case G_OPTION_ARG_FILENAME: case G_OPTION_ARG_STRING_ARRAY: case G_OPTION_ARG_FILENAME_ARRAY: { - // No need to set default values for string-valued options. - // If *carg_ is still 0, when convert_c_to_cpp() is called, just don't - // touch *cpparg_. Besides, setting default values in *carg_ can result - // in memory leaks, because glib would not free the strings before - // the char*'s are overwritten with pointers to newly allocated copies - // of the command option arguments. + char*** typed_arg = static_cast(carg_); + g_strfreev(*typed_arg); // Free the array of strings and the array at typed_arg, if allocated + // by the C code. + delete typed_arg; // Delete the char*** that we allocated in allocate_c_arg(). + + break; + } + case G_OPTION_ARG_NONE: // Actually a boolean. + { + gboolean* typed_arg = static_cast(carg_); + delete typed_arg; + break; } case G_OPTION_ARG_CALLBACK: { - //No value to set here. The arg pointer is a function pointer. + // Delete the OptionArgCallback instance that was allocated by add_entry() + // or add_entry_filename(). + auto option_arg = static_cast(cpparg_); + delete option_arg; + cpparg_ = nullptr; - //Set or clear FLAG_FILENAME in *entry_. - const OptionArgCallback* const option_arg = static_cast(cpp_arg); - if (option_arg->is_filename_option()) - { - entry_->set_flags(entry_->get_flags() | OptionEntry::FLAG_FILENAME); - } - else - { - entry_->set_flags(entry_->get_flags() & ~OptionEntry::FLAG_FILENAME); - } break; } default: { break; } - } -} - -void OptionGroup::CppOptionEntry::release_c_arg() -{ - //Delete the instances that we created in allocate_c_arg(). - //Notice that we delete the type that we created, but not the value to which it points. - if(carg_) - { - switch(carg_type_) - { - case G_OPTION_ARG_STRING: - case G_OPTION_ARG_FILENAME: - { - char** typed_arg = static_cast(carg_); - g_free(*typed_arg); //Free the char* string at typed_arg, if allocated by the C code. - delete typed_arg; //Delete the char** that we allocated in allocate_c_arg(). - - break; - } - case G_OPTION_ARG_INT: - { - int* typed_arg = static_cast(carg_); - delete typed_arg; - - break; - } - case G_OPTION_ARG_DOUBLE: - { - double* typed_arg = static_cast(carg_); - delete typed_arg; - - break; - } - case G_OPTION_ARG_STRING_ARRAY: - case G_OPTION_ARG_FILENAME_ARRAY: - { - char*** typed_arg = static_cast(carg_); - g_strfreev(*typed_arg); //Free the array of strings and the array at typed_arg, if allocated by the C code. - delete typed_arg; //Delete the char*** that we allocated in allocate_c_arg(). - - break; - } - case G_OPTION_ARG_NONE: // Actually a boolean. - { - gboolean* typed_arg = static_cast(carg_); - delete typed_arg; - - break; - } - case G_OPTION_ARG_CALLBACK: - { - //Delete the OptionArgCallback instance that was allocated by add_entry() - //or add_entry_filename(). - auto option_arg = static_cast(cpparg_); - delete option_arg; - cpparg_ = nullptr; - - break; - } - default: - { - break; - } } carg_ = nullptr; } - if(entry_) + if (entry_) delete entry_; } -void OptionGroup::CppOptionEntry::convert_c_to_cpp() +void +OptionGroup::CppOptionEntry::convert_c_to_cpp() { if (!carg_) return; - switch(carg_type_) + switch (carg_type_) { - case G_OPTION_ARG_STRING: - { - char** typed_arg = static_cast(carg_); - auto typed_cpp_arg = static_cast(cpparg_); - if(typed_arg && *typed_arg && typed_cpp_arg) - { - *typed_cpp_arg = *typed_arg; - } - break; - } - case G_OPTION_ARG_FILENAME: + case G_OPTION_ARG_STRING: + { + char** typed_arg = static_cast(carg_); + auto typed_cpp_arg = static_cast(cpparg_); + if (typed_arg && *typed_arg && typed_cpp_arg) { - char** typed_arg = static_cast(carg_); - auto typed_cpp_arg = static_cast(cpparg_); - if(typed_arg && *typed_arg && typed_cpp_arg) - { - *typed_cpp_arg = *typed_arg; - } - break; + *typed_cpp_arg = *typed_arg; } - case G_OPTION_ARG_INT: + break; + } + case G_OPTION_ARG_FILENAME: + { + char** typed_arg = static_cast(carg_); + auto typed_cpp_arg = static_cast(cpparg_); + if (typed_arg && *typed_arg && typed_cpp_arg) { - *((int*)cpparg_) = *(static_cast(carg_)); - break; + *typed_cpp_arg = *typed_arg; } - case G_OPTION_ARG_DOUBLE: - { - *((double*)cpparg_) = *(static_cast(carg_)); - break; - } - case G_OPTION_ARG_STRING_ARRAY: + break; + } + case G_OPTION_ARG_INT: + { + *((int*)cpparg_) = *(static_cast(carg_)); + break; + } + case G_OPTION_ARG_DOUBLE: + { + *((double*)cpparg_) = *(static_cast(carg_)); + break; + } + case G_OPTION_ARG_STRING_ARRAY: + { + char*** typed_arg = static_cast(carg_); + auto typed_cpp_arg = static_cast(cpparg_); + if (typed_arg && *typed_arg && typed_cpp_arg) { - char*** typed_arg = static_cast(carg_); - auto typed_cpp_arg = static_cast(cpparg_); - if(typed_arg && *typed_arg && typed_cpp_arg) + typed_cpp_arg->clear(); + + // The C array is null-terminated. + // Glib::StringArrayHandle array_handle(*typed_arg, Glib::OWNERSHIP_NONE); + + // The SUN Forte compiler complains about this: + // "optiongroup.cc", line 354: Error: Cannot assign Glib::ArrayHandle> to std::vector without + // "std::vector::operator=(const std::vector&)";. + // + //(*typed_cpp_arg) = array_handle; + // + // And the Tru64 compiler does not even like us to instantiate the StringArrayHandle: + // + // cxx: Error: ../../glib/glibmm/containerhandle_shared.h, line 149: the operand + // of a pointer dynamic_cast must be a pointer to a complete class type + // return dynamic_cast(Glib::wrap_auto(cobj, false /* take_copy */)); + + // for(Glib::StringArrayHandle::iterator iter = array_handle.begin(); iter != + // array_handle.end(); ++iter) + //{ + // typed_cpp_arg->emplace_back(*iter); + //} + + // So we do this: + + char** char_array_next = *typed_arg; + while (*char_array_next) { - typed_cpp_arg->clear(); - - //The C array is null-terminated. - //Glib::StringArrayHandle array_handle(*typed_arg, Glib::OWNERSHIP_NONE); - - //The SUN Forte compiler complains about this: - // "optiongroup.cc", line 354: Error: Cannot assign Glib::ArrayHandle> to std::vector without - // "std::vector::operator=(const std::vector&)";. - // - //(*typed_cpp_arg) = array_handle; - // - //And the Tru64 compiler does not even like us to instantiate the StringArrayHandle: - // - // cxx: Error: ../../glib/glibmm/containerhandle_shared.h, line 149: the operand - // of a pointer dynamic_cast must be a pointer to a complete class type - // return dynamic_cast(Glib::wrap_auto(cobj, false /* take_copy */)); - - //for(Glib::StringArrayHandle::iterator iter = array_handle.begin(); iter != array_handle.end(); ++iter) - //{ - // typed_cpp_arg->emplace_back(*iter); - //} - - //So we do this: - - char** char_array_next = *typed_arg; - while(*char_array_next) - { - typed_cpp_arg->emplace_back(*char_array_next); - ++char_array_next; - } + typed_cpp_arg->emplace_back(*char_array_next); + ++char_array_next; } - break; } - case G_OPTION_ARG_FILENAME_ARRAY: + break; + } + case G_OPTION_ARG_FILENAME_ARRAY: + { + char*** typed_arg = static_cast(carg_); + auto typed_cpp_arg = static_cast(cpparg_); + if (typed_arg && *typed_arg && typed_cpp_arg) { - char*** typed_arg = static_cast(carg_); - auto typed_cpp_arg = static_cast(cpparg_); - if(typed_arg && *typed_arg && typed_cpp_arg) - { - typed_cpp_arg->clear(); + typed_cpp_arg->clear(); - //See comments above about the SUN Forte and Tru64 compilers. + // See comments above about the SUN Forte and Tru64 compilers. - char** char_array_next = *typed_arg; - while(*char_array_next) - { - typed_cpp_arg->emplace_back(*char_array_next); - ++char_array_next; - } + char** char_array_next = *typed_arg; + while (*char_array_next) + { + typed_cpp_arg->emplace_back(*char_array_next); + ++char_array_next; } - break; - } - case G_OPTION_ARG_NONE: // Actually a boolean. - { - *(static_cast(cpparg_)) = *(static_cast(carg_)); - break; - } - case G_OPTION_ARG_CALLBACK: - { - //Nothing to convert here. That's a task for the callback function - //(the SlotOptionArgString or SlotOptionArgFilename). - break; - } - default: - { - break; } + break; + } + case G_OPTION_ARG_NONE: // Actually a boolean. + { + *(static_cast(cpparg_)) = *(static_cast(carg_)); + break; + } + case G_OPTION_ARG_CALLBACK: + { + // Nothing to convert here. That's a task for the callback function + //(the SlotOptionArgString or SlotOptionArgFilename). + break; + } + default: + { + break; + } } } -GOptionGroup* OptionGroup::gobj_give_ownership() +GOptionGroup* +OptionGroup::gobj_give_ownership() { has_ownership_ = false; return gobj(); } } // namespace Glib - diff --git a/glib/src/regex.ccg b/glib/src/regex.ccg index bdfd2619..a4185393 100644 --- a/glib/src/regex.ccg +++ b/glib/src/regex.ccg @@ -20,246 +20,242 @@ namespace Glib { -Glib::RefPtr Regex::create(const Glib::ustring& pattern, - RegexCompileFlags compile_options, - RegexMatchFlags match_options) +Glib::RefPtr +Regex::create( + const Glib::ustring& pattern, RegexCompileFlags compile_options, RegexMatchFlags match_options) { GError* gerror = nullptr; - auto regex = g_regex_new(pattern.c_str(), (GRegexCompileFlags)compile_options, - (GRegexMatchFlags)match_options, &gerror); + auto regex = g_regex_new( + pattern.c_str(), (GRegexCompileFlags)compile_options, (GRegexMatchFlags)match_options, &gerror); - if(gerror) + if (gerror) Glib::Error::throw_exception(gerror); return Glib::wrap(regex); } // static -Glib::ustring Regex::escape_string(const Glib::ustring& string) +Glib::ustring +Regex::escape_string(const Glib::ustring& string) { - const auto buf = make_unique_ptr_gfree(g_regex_escape_string(string.raw().c_str(), - string.raw().size())); + const auto buf = + make_unique_ptr_gfree(g_regex_escape_string(string.raw().c_str(), string.raw().size())); return Glib::ustring(buf.get()); } -bool Regex::match( - const Glib::ustring& string, - Glib::MatchInfo& match_info, - RegexMatchFlags match_options -) +bool +Regex::match( + const Glib::ustring& string, Glib::MatchInfo& match_info, RegexMatchFlags match_options) { GMatchInfo* ginfo = nullptr; - bool const result = static_cast(g_regex_match(gobj(), string.c_str(), - static_cast(match_options), &ginfo)); + bool const result = static_cast( + g_regex_match(gobj(), string.c_str(), static_cast(match_options), &ginfo)); match_info.set_gobject(ginfo); return result; } -bool Regex::match(const Glib::ustring& string, RegexMatchFlags match_options) +bool +Regex::match(const Glib::ustring& string, RegexMatchFlags match_options) { return g_regex_match(gobj(), string.c_str(), (GRegexMatchFlags)(match_options), nullptr); } -bool Regex::match( - const Glib::ustring& string, - int start_position, - Glib::MatchInfo& match_info, - RegexMatchFlags match_options -) +bool +Regex::match(const Glib::ustring& string, int start_position, Glib::MatchInfo& match_info, + RegexMatchFlags match_options) { GError* gerror = nullptr; GMatchInfo* ginfo = nullptr; - bool const result = static_cast(g_regex_match_full(gobj(), - string.c_str(), -1, start_position, - static_cast(match_options), &ginfo, &gerror)); + bool const result = static_cast(g_regex_match_full(gobj(), string.c_str(), -1, + start_position, static_cast(match_options), &ginfo, &gerror)); - if(gerror) + if (gerror) ::Glib::Error::throw_exception(gerror); match_info.set_gobject(ginfo); return result; } -bool Regex::match( - const Glib::ustring& string, - gssize string_len, - int start_position, - Glib::MatchInfo& match_info, - RegexMatchFlags match_options -) +bool +Regex::match(const Glib::ustring& string, gssize string_len, int start_position, + Glib::MatchInfo& match_info, RegexMatchFlags match_options) { GError* gerror = nullptr; GMatchInfo* ginfo = nullptr; - bool const result = static_cast(g_regex_match_full(gobj(), - string.c_str(), string_len, start_position, - static_cast(match_options), &ginfo, &gerror)); + bool const result = static_cast(g_regex_match_full(gobj(), string.c_str(), string_len, + start_position, static_cast(match_options), &ginfo, &gerror)); - if(gerror) + if (gerror) ::Glib::Error::throw_exception(gerror); match_info.set_gobject(ginfo); return result; } -bool Regex::match(const Glib::ustring& string, int start_position, RegexMatchFlags match_options) +bool +Regex::match(const Glib::ustring& string, int start_position, RegexMatchFlags match_options) { GError* gerror = nullptr; - bool retvalue = g_regex_match_full(gobj(), string.c_str(), -1, start_position, ((GRegexMatchFlags)(match_options)), nullptr, &(gerror)); - if(gerror) + bool retvalue = g_regex_match_full(gobj(), string.c_str(), -1, start_position, + ((GRegexMatchFlags)(match_options)), nullptr, &(gerror)); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } -bool Regex::match(const Glib::ustring& string, gssize string_len, int start_position, RegexMatchFlags match_options) +bool +Regex::match( + const Glib::ustring& string, gssize string_len, int start_position, RegexMatchFlags match_options) { GError* gerror = nullptr; - bool retvalue = g_regex_match_full(gobj(), string.c_str(), string_len, start_position, ((GRegexMatchFlags)(match_options)), nullptr, &(gerror)); - if(gerror) + bool retvalue = g_regex_match_full(gobj(), string.c_str(), string_len, start_position, + ((GRegexMatchFlags)(match_options)), nullptr, &(gerror)); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } -bool Regex::match_all( - const Glib::ustring& string, - Glib::MatchInfo& match_info, - RegexMatchFlags match_options -) +bool +Regex::match_all( + const Glib::ustring& string, Glib::MatchInfo& match_info, RegexMatchFlags match_options) { GMatchInfo* ginfo = nullptr; - bool const result = static_cast(g_regex_match_all(gobj(), - string.c_str(), static_cast(match_options), - &ginfo)); + bool const result = static_cast(g_regex_match_all( + gobj(), string.c_str(), static_cast(match_options), &ginfo)); match_info.set_gobject(ginfo); return result; } -bool Regex::match_all(const Glib::ustring& string, RegexMatchFlags match_options) +bool +Regex::match_all(const Glib::ustring& string, RegexMatchFlags match_options) { return g_regex_match_all(gobj(), string.c_str(), ((GRegexMatchFlags)(match_options)), nullptr); } -bool Regex::match_all( - const Glib::ustring& string, - int start_position, - Glib::MatchInfo& match_info, - RegexMatchFlags match_options -) +bool +Regex::match_all(const Glib::ustring& string, int start_position, Glib::MatchInfo& match_info, + RegexMatchFlags match_options) { GError* gerror = nullptr; GMatchInfo* ginfo = nullptr; - bool const retvalue = static_cast(g_regex_match_all_full(gobj(), - string.c_str(), -1, start_position, - static_cast(match_options), &ginfo, &gerror)); + bool const retvalue = static_cast(g_regex_match_all_full(gobj(), string.c_str(), -1, + start_position, static_cast(match_options), &ginfo, &gerror)); - if(gerror) + if (gerror) ::Glib::Error::throw_exception(gerror); match_info.set_gobject(ginfo); return retvalue; } -bool Regex::match_all( - const Glib::ustring& string, - gssize string_len, - int start_position, - Glib::MatchInfo& match_info, - RegexMatchFlags match_options -) +bool +Regex::match_all(const Glib::ustring& string, gssize string_len, int start_position, + Glib::MatchInfo& match_info, RegexMatchFlags match_options) { GError* gerror = nullptr; GMatchInfo* ginfo = nullptr; - bool const retvalue = static_cast(g_regex_match_all_full(gobj(), - string.c_str(), string_len, start_position, - static_cast(match_options), &ginfo, &gerror)); + bool const retvalue = static_cast(g_regex_match_all_full(gobj(), string.c_str(), string_len, + start_position, static_cast(match_options), &ginfo, &gerror)); - if(gerror) + if (gerror) ::Glib::Error::throw_exception(gerror); match_info.set_gobject(ginfo); return retvalue; } -bool Regex::match_all(const Glib::ustring& string, int start_position, RegexMatchFlags match_options) +bool +Regex::match_all(const Glib::ustring& string, int start_position, RegexMatchFlags match_options) { GError* gerror = nullptr; - bool retvalue = g_regex_match_all_full(gobj(), string.c_str(), -1, start_position, ((GRegexMatchFlags)(match_options)), nullptr, &(gerror)); - if(gerror) + bool retvalue = g_regex_match_all_full(gobj(), string.c_str(), -1, start_position, + ((GRegexMatchFlags)(match_options)), nullptr, &(gerror)); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } -bool Regex::match_all(const Glib::ustring& string, gssize string_len, int start_position, RegexMatchFlags match_options) +bool +Regex::match_all( + const Glib::ustring& string, gssize string_len, int start_position, RegexMatchFlags match_options) { GError* gerror = nullptr; - bool retvalue = g_regex_match_all_full(gobj(), string.c_str(), string_len, start_position, ((GRegexMatchFlags)(match_options)), nullptr, &(gerror)); - if(gerror) + bool retvalue = g_regex_match_all_full(gobj(), string.c_str(), string_len, start_position, + ((GRegexMatchFlags)(match_options)), nullptr, &(gerror)); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } -Glib::ustring Regex::replace(const Glib::ustring& string, int start_position, const Glib::ustring& replacement, RegexMatchFlags match_options) +Glib::ustring +Regex::replace(const Glib::ustring& string, int start_position, const Glib::ustring& replacement, + RegexMatchFlags match_options) { GError* gerror = nullptr; - auto retvalue = Glib::convert_return_gchar_ptr_to_ustring(g_regex_replace(gobj(), string.c_str(), -1, start_position, replacement.c_str(), ((GRegexMatchFlags)(match_options)), &(gerror))); - if(gerror) + auto retvalue = Glib::convert_return_gchar_ptr_to_ustring(g_regex_replace(gobj(), string.c_str(), + -1, start_position, replacement.c_str(), ((GRegexMatchFlags)(match_options)), &(gerror))); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } - -Glib::ustring Regex::replace_literal(const Glib::ustring& string, int start_position, const Glib::ustring& replacement, RegexMatchFlags match_options) +Glib::ustring +Regex::replace_literal(const Glib::ustring& string, int start_position, + const Glib::ustring& replacement, RegexMatchFlags match_options) { GError* gerror = nullptr; - auto retvalue = Glib::convert_return_gchar_ptr_to_ustring(g_regex_replace_literal(gobj(), string.c_str(), -1, start_position, replacement.c_str(), ((GRegexMatchFlags)(match_options)), &(gerror))); - if(gerror) + auto retvalue = + Glib::convert_return_gchar_ptr_to_ustring(g_regex_replace_literal(gobj(), string.c_str(), -1, + start_position, replacement.c_str(), ((GRegexMatchFlags)(match_options)), &(gerror))); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } -Glib::StringArrayHandle Regex::split(const Glib::ustring& string, int start_position, RegexMatchFlags match_options, int max_tokens) const +Glib::StringArrayHandle +Regex::split(const Glib::ustring& string, int start_position, RegexMatchFlags match_options, + int max_tokens) const { GError* gerror = nullptr; - auto retvalue = Glib::StringArrayHandle(g_regex_split_full(const_cast(gobj()), string.c_str(), -1, start_position, ((GRegexMatchFlags)(match_options)), max_tokens, &(gerror)), Glib::OWNERSHIP_DEEP); - if(gerror) + auto retvalue = Glib::StringArrayHandle( + g_regex_split_full(const_cast(gobj()), string.c_str(), -1, start_position, + ((GRegexMatchFlags)(match_options)), max_tokens, &(gerror)), + Glib::OWNERSHIP_DEEP); + if (gerror) ::Glib::Error::throw_exception(gerror); return retvalue; } - -MatchInfo::MatchInfo() -: gobject_(nullptr), - take_ownership(false) +MatchInfo::MatchInfo() : gobject_(nullptr), take_ownership(false) { } MatchInfo::MatchInfo(GMatchInfo* castitem, bool take_the_ownership) -: gobject_(castitem), - take_ownership(take_the_ownership) +: gobject_(castitem), take_ownership(take_the_ownership) { } - -MatchInfo::MatchInfo(MatchInfo&& other) noexcept -: gobject_(std::move(other.gobject_)), - take_ownership(std::move(other.take_ownership)) +MatchInfo::MatchInfo(MatchInfo&& other) noexcept : gobject_(std::move(other.gobject_)), + take_ownership(std::move(other.take_ownership)) { other.gobject_ = nullptr; other.take_ownership = false; } -MatchInfo& MatchInfo::operator=(MatchInfo&& other) noexcept +MatchInfo& +MatchInfo::operator=(MatchInfo&& other) noexcept { - if(take_ownership && gobject_) + if (take_ownership && gobject_) g_match_info_free(gobject_); gobject_ = std::move(other.gobject_); @@ -271,9 +267,10 @@ MatchInfo& MatchInfo::operator=(MatchInfo&& other) noexcept return *this; } -void MatchInfo::set_gobject(GMatchInfo* castitem, bool take_the_ownership) +void +MatchInfo::set_gobject(GMatchInfo* castitem, bool take_the_ownership) { - if(gobject_ && this->take_ownership) + if (gobject_ && this->take_ownership) g_match_info_free(gobject_); gobject_ = castitem; @@ -282,7 +279,7 @@ void MatchInfo::set_gobject(GMatchInfo* castitem, bool take_the_ownership) MatchInfo::~MatchInfo() { - if(take_ownership && gobject_) + if (take_ownership && gobject_) g_match_info_free(gobject_); } diff --git a/glib/src/shell.ccg b/glib/src/shell.ccg index 84b9a512..aaa34379 100644 --- a/glib/src/shell.ccg +++ b/glib/src/shell.ccg @@ -17,42 +17,43 @@ #include - namespace Glib { /**** shell utility functions **********************************************/ -Glib::ArrayHandle shell_parse_argv(const std::string& command_line) +Glib::ArrayHandle +shell_parse_argv(const std::string& command_line) { - char** argv = nullptr; - int argc = 0; + char** argv = nullptr; + int argc = 0; GError* error = nullptr; g_shell_parse_argv(command_line.c_str(), &argc, &argv, &error); - if(error) + if (error) Glib::Error::throw_exception(error); return Glib::ArrayHandle(argv, argc, Glib::OWNERSHIP_DEEP); } -std::string shell_quote(const std::string& unquoted_string) +std::string +shell_quote(const std::string& unquoted_string) { const auto buf = make_unique_ptr_gfree(g_shell_quote(unquoted_string.c_str())); return std::string(buf.get()); } -std::string shell_unquote(const std::string& quoted_string) +std::string +shell_unquote(const std::string& quoted_string) { GError* error = nullptr; - char *const buf = g_shell_unquote(quoted_string.c_str(), &error); + char* const buf = g_shell_unquote(quoted_string.c_str(), &error); - if(error) + if (error) Glib::Error::throw_exception(error); return std::string(make_unique_ptr_gfree(buf).get()); } } // namespace Glib - diff --git a/glib/src/spawn.ccg b/glib/src/spawn.ccg index 7369f5f1..867e413f 100644 --- a/glib/src/spawn.ccg +++ b/glib/src/spawn.ccg @@ -19,198 +19,153 @@ #include #include - namespace { -extern "C" -{ +extern "C" { /* Helper callback to invoke the actual sigc++ slot. * We don't need to worry about (un)referencing, since the * child process gets its own copy of the parent's memory anyway. */ -static void child_setup_callback(void* user_data) +static void +child_setup_callback(void* user_data) { try { (*reinterpret_cast(user_data))(); } - catch(...) + catch (...) { Glib::exception_handlers_invoke(); } } -static void copy_output_buf(std::string* dest, const char* buf) +static void +copy_output_buf(std::string* dest, const char* buf) { - if(dest) + if (dest) { - if(buf) + if (buf) *dest = buf; else dest->erase(); } } -} //extern "C" - -} //anonymous namespace +} // extern "C" +} // anonymous namespace namespace Glib { /**** process spawning functions *******************************************/ -void spawn_async_with_pipes(const std::string& working_directory, - const Glib::ArrayHandle& argv, - const Glib::ArrayHandle& envp, - SpawnFlags flags, - const SlotSpawnChildSetup& child_setup, - Pid* child_pid, - int* standard_input, - int* standard_output, - int* standard_error) +void +spawn_async_with_pipes(const std::string& working_directory, + const Glib::ArrayHandle& argv, const Glib::ArrayHandle& envp, + SpawnFlags flags, const SlotSpawnChildSetup& child_setup, Pid* child_pid, int* standard_input, + int* standard_output, int* standard_error) { const bool setup_slot = !child_setup.empty(); auto child_setup_ = child_setup; GError* gerror = nullptr; - g_spawn_async_with_pipes( - Glib::c_str_or_nullptr(working_directory), - const_cast(argv.data()), - const_cast(envp.data()), - static_cast(unsigned(flags)), - (setup_slot) ? &child_setup_callback : nullptr, - (setup_slot) ? &child_setup_ : nullptr, - child_pid, - standard_input, standard_output, standard_error, - &gerror); - - if(gerror) + g_spawn_async_with_pipes(Glib::c_str_or_nullptr(working_directory), + const_cast(argv.data()), const_cast(envp.data()), + static_cast(unsigned(flags)), (setup_slot) ? &child_setup_callback : nullptr, + (setup_slot) ? &child_setup_ : nullptr, child_pid, standard_input, standard_output, + standard_error, &gerror); + + if (gerror) Glib::Error::throw_exception(gerror); } -void spawn_async_with_pipes(const std::string& working_directory, - const Glib::ArrayHandle& argv, - SpawnFlags flags, - const SlotSpawnChildSetup& child_setup, - Pid* child_pid, - int* standard_input, - int* standard_output, - int* standard_error) +void +spawn_async_with_pipes(const std::string& working_directory, + const Glib::ArrayHandle& argv, SpawnFlags flags, + const SlotSpawnChildSetup& child_setup, Pid* child_pid, int* standard_input, int* standard_output, + int* standard_error) { const bool setup_slot = !child_setup.empty(); auto child_setup_ = child_setup; GError* gerror = nullptr; - g_spawn_async_with_pipes( - Glib::c_str_or_nullptr(working_directory), - const_cast(argv.data()), nullptr, - static_cast(unsigned(flags)), - (setup_slot) ? &child_setup_callback : nullptr, - (setup_slot) ? &child_setup_ : nullptr, - child_pid, - standard_input, standard_output, standard_error, - &gerror); - - if(gerror) + g_spawn_async_with_pipes(Glib::c_str_or_nullptr(working_directory), + const_cast(argv.data()), nullptr, static_cast(unsigned(flags)), + (setup_slot) ? &child_setup_callback : nullptr, (setup_slot) ? &child_setup_ : nullptr, + child_pid, standard_input, standard_output, standard_error, &gerror); + + if (gerror) Glib::Error::throw_exception(gerror); } -void spawn_async(const std::string& working_directory, - const Glib::ArrayHandle& argv, - const Glib::ArrayHandle& envp, - SpawnFlags flags, - const SlotSpawnChildSetup& child_setup, - Pid* child_pid) +void +spawn_async(const std::string& working_directory, const Glib::ArrayHandle& argv, + const Glib::ArrayHandle& envp, SpawnFlags flags, + const SlotSpawnChildSetup& child_setup, Pid* child_pid) { const bool setup_slot = !child_setup.empty(); auto child_setup_ = child_setup; GError* gerror = nullptr; - g_spawn_async( - Glib::c_str_or_nullptr(working_directory), - const_cast(argv.data()), - const_cast(envp.data()), - static_cast(unsigned(flags)), - (setup_slot) ? &child_setup_callback : nullptr, - (setup_slot) ? &child_setup_ : nullptr, - child_pid, - &gerror); - - if(gerror) + g_spawn_async(Glib::c_str_or_nullptr(working_directory), const_cast(argv.data()), + const_cast(envp.data()), static_cast(unsigned(flags)), + (setup_slot) ? &child_setup_callback : nullptr, (setup_slot) ? &child_setup_ : nullptr, + child_pid, &gerror); + + if (gerror) Glib::Error::throw_exception(gerror); } -void spawn_async(const std::string& working_directory, - const Glib::ArrayHandle& argv, - SpawnFlags flags, - const SlotSpawnChildSetup& child_setup, - Pid* child_pid) +void +spawn_async(const std::string& working_directory, const Glib::ArrayHandle& argv, + SpawnFlags flags, const SlotSpawnChildSetup& child_setup, Pid* child_pid) { const bool setup_slot = !child_setup.empty(); auto child_setup_ = child_setup; GError* gerror = nullptr; - g_spawn_async( - Glib::c_str_or_nullptr(working_directory), - const_cast(argv.data()), nullptr, - static_cast(unsigned(flags)), - (setup_slot) ? &child_setup_callback : nullptr, - (setup_slot) ? &child_setup_ : nullptr, - child_pid, - &gerror); + g_spawn_async(Glib::c_str_or_nullptr(working_directory), const_cast(argv.data()), nullptr, + static_cast(unsigned(flags)), (setup_slot) ? &child_setup_callback : nullptr, + (setup_slot) ? &child_setup_ : nullptr, child_pid, &gerror); - if(gerror) + if (gerror) Glib::Error::throw_exception(gerror); } -void spawn_sync(const std::string& working_directory, - const Glib::ArrayHandle& argv, - const Glib::ArrayHandle& envp, - SpawnFlags flags, - const SlotSpawnChildSetup& child_setup, - std::string* standard_output, - std::string* standard_error, - int* exit_status) +void +spawn_sync(const std::string& working_directory, const Glib::ArrayHandle& argv, + const Glib::ArrayHandle& envp, SpawnFlags flags, + const SlotSpawnChildSetup& child_setup, std::string* standard_output, std::string* standard_error, + int* exit_status) { const bool setup_slot = !child_setup.empty(); auto child_setup_ = child_setup; - GError* gerror = nullptr; char* pch_buf_standard_output = nullptr; char* pch_buf_standard_error = nullptr; - g_spawn_sync( - Glib::c_str_or_nullptr(working_directory), - const_cast(argv.data()), - const_cast(envp.data()), - static_cast(unsigned(flags)), - (setup_slot) ? &child_setup_callback : nullptr, - (setup_slot) ? &child_setup_ : nullptr, - (standard_output) ? &pch_buf_standard_output : nullptr, - (standard_error) ? &pch_buf_standard_error : nullptr, - exit_status, - &gerror); + g_spawn_sync(Glib::c_str_or_nullptr(working_directory), const_cast(argv.data()), + const_cast(envp.data()), static_cast(unsigned(flags)), + (setup_slot) ? &child_setup_callback : nullptr, (setup_slot) ? &child_setup_ : nullptr, + (standard_output) ? &pch_buf_standard_output : nullptr, + (standard_error) ? &pch_buf_standard_error : nullptr, exit_status, &gerror); auto buf_standard_output = make_unique_ptr_gfree(pch_buf_standard_output); auto buf_standard_error = make_unique_ptr_gfree(pch_buf_standard_error); - if(gerror) + if (gerror) Glib::Error::throw_exception(gerror); copy_output_buf(standard_output, buf_standard_output.get()); copy_output_buf(standard_error, buf_standard_error.get()); } -void spawn_sync(const std::string& working_directory, - const Glib::ArrayHandle& argv, - SpawnFlags flags, - const SlotSpawnChildSetup& child_setup, - std::string* standard_output, - std::string* standard_error, - int* exit_status) +void +spawn_sync(const std::string& working_directory, const Glib::ArrayHandle& argv, + SpawnFlags flags, const SlotSpawnChildSetup& child_setup, std::string* standard_output, + std::string* standard_error, int* exit_status) { const bool setup_slot = !child_setup.empty(); auto child_setup_ = child_setup; @@ -219,64 +174,55 @@ void spawn_sync(const std::string& working_directory, char* pch_buf_standard_error = nullptr; GError* gerror = nullptr; - g_spawn_sync( - Glib::c_str_or_nullptr(working_directory), - const_cast(argv.data()), nullptr, - static_cast(unsigned(flags)), - (setup_slot) ? &child_setup_callback : nullptr, - (setup_slot) ? &child_setup_ : nullptr, - (standard_output) ? &pch_buf_standard_output : nullptr, - (standard_error) ? &pch_buf_standard_error : nullptr, - exit_status, - &gerror); + g_spawn_sync(Glib::c_str_or_nullptr(working_directory), const_cast(argv.data()), nullptr, + static_cast(unsigned(flags)), (setup_slot) ? &child_setup_callback : nullptr, + (setup_slot) ? &child_setup_ : nullptr, (standard_output) ? &pch_buf_standard_output : nullptr, + (standard_error) ? &pch_buf_standard_error : nullptr, exit_status, &gerror); auto buf_standard_output = make_unique_ptr_gfree(pch_buf_standard_output); auto buf_standard_error = make_unique_ptr_gfree(pch_buf_standard_error); - if(gerror) + if (gerror) Glib::Error::throw_exception(gerror); copy_output_buf(standard_output, buf_standard_output.get()); copy_output_buf(standard_error, buf_standard_error.get()); } -void spawn_command_line_async(const std::string& command_line) +void +spawn_command_line_async(const std::string& command_line) { GError* gerror = nullptr; g_spawn_command_line_async(command_line.c_str(), &gerror); - if(gerror) + if (gerror) Glib::Error::throw_exception(gerror); } -void spawn_command_line_sync(const std::string& command_line, - std::string* standard_output, - std::string* standard_error, - int* exit_status) +void +spawn_command_line_sync(const std::string& command_line, std::string* standard_output, + std::string* standard_error, int* exit_status) { char* pch_buf_standard_output = nullptr; char* pch_buf_standard_error = nullptr; GError* gerror = nullptr; - g_spawn_command_line_sync( - command_line.c_str(), - (standard_output) ? &pch_buf_standard_output : nullptr, - (standard_error) ? &pch_buf_standard_error : nullptr, - exit_status, - &gerror); + g_spawn_command_line_sync(command_line.c_str(), + (standard_output) ? &pch_buf_standard_output : nullptr, + (standard_error) ? &pch_buf_standard_error : nullptr, exit_status, &gerror); auto buf_standard_output = make_unique_ptr_gfree(pch_buf_standard_output); auto buf_standard_error = make_unique_ptr_gfree(pch_buf_standard_error); - if(gerror) + if (gerror) Glib::Error::throw_exception(gerror); copy_output_buf(standard_output, buf_standard_output.get()); copy_output_buf(standard_error, buf_standard_error.get()); } -void spawn_close_pid(Pid pid) +void +spawn_close_pid(Pid pid) { g_spawn_close_pid(pid); } } // namespace Glib - diff --git a/glib/src/thread.ccg b/glib/src/thread.ccg index af4695fc..3d6d7955 100644 --- a/glib/src/thread.ccg +++ b/glib/src/thread.ccg @@ -21,10 +21,10 @@ namespace { -extern "C" -{ +extern "C" { -static void* call_thread_entry_slot(void* data) +static void* +call_thread_entry_slot(void* data) { const auto slot = reinterpret_cast(data); @@ -33,12 +33,12 @@ static void* call_thread_entry_slot(void* data) // Recreate the specific slot, and drop the reference obtained by create(). (*static_cast*>(slot))(); } - catch(Glib::Thread::Exit&) + catch (Glib::Thread::Exit&) { // Just exit from the thread. The Thread::Exit exception // is our sane C++ replacement of g_thread_exit(). } - catch(...) + catch (...) { Glib::exception_handlers_invoke(); } @@ -47,11 +47,10 @@ static void* call_thread_entry_slot(void* data) return nullptr; } -} //extern "C" +} // extern "C" } // anonymous namespace - namespace Glib { @@ -59,7 +58,8 @@ namespace Glib // and no longer needs to be called. We are keeping it just to avoid // breaking ABI, though hopefully nobody is using it anyway. // TODO: Remove this when we can break ABI. -void thread_init_impl() +void +thread_init_impl() { // Make sure the exception map is initialized before creating any thread. Glib::Error::register_init(); @@ -68,17 +68,17 @@ void thread_init_impl() /**** Glib::Thread *********************************************************/ // static -Thread* Thread::create(const sigc::slot& slot, bool /* joinable */) +Thread* +Thread::create(const sigc::slot& slot, bool /* joinable */) { // Make a copy of slot on the heap const auto slot_copy = new sigc::slot(slot); GError* error = nullptr; - const auto thread = g_thread_try_new(nullptr, - &call_thread_entry_slot, slot_copy, &error); + const auto thread = g_thread_try_new(nullptr, &call_thread_entry_slot, slot_copy, &error); - if(error) + if (error) { delete slot_copy; // Glib::Error::throw_exception() will probably wrap G_THREAD_ERROR in a @@ -93,19 +93,19 @@ Thread* Thread::create(const sigc::slot& slot, bool /* joinable */) } // static -Thread* Thread::create(const sigc::slot& slot, unsigned long stack_size, - bool joinable, bool bound, ThreadPriority priority) +Thread* +Thread::create(const sigc::slot& slot, unsigned long stack_size, bool joinable, bool bound, + ThreadPriority priority) { // Make a copy of slot on the heap const auto slot_copy = new sigc::slot(slot); GError* error = nullptr; - const auto thread = g_thread_create_full( - &call_thread_entry_slot, slot_copy, stack_size, joinable, - bound, (GThreadPriority) priority, &error); + const auto thread = g_thread_create_full(&call_thread_entry_slot, slot_copy, stack_size, joinable, + bound, (GThreadPriority)priority, &error); - if(error) + if (error) { delete slot_copy; // Glib::Error::throw_exception() will probably wrap G_THREAD_ERROR in a @@ -120,74 +120,85 @@ Thread* Thread::create(const sigc::slot& slot, unsigned long stack_size, } // static -Thread* Thread::self() +Thread* +Thread::self() { return reinterpret_cast(g_thread_self()); } -void Thread::join() +void +Thread::join() { g_thread_join(&gobject_); } -bool Thread::joinable() const +bool +Thread::joinable() const { - return true; //An appropriate result now that this is deprecated because all threads are now joinable. + return true; // An appropriate result now that this is deprecated because all threads are now + // joinable. } -void Thread::set_priority(ThreadPriority priority) +void +Thread::set_priority(ThreadPriority priority) { - g_thread_set_priority(&gobject_, (GThreadPriority) priority); + g_thread_set_priority(&gobject_, (GThreadPriority)priority); } -ThreadPriority Thread::get_priority() const +ThreadPriority +Thread::get_priority() const { - return THREAD_PRIORITY_NORMAL; //An appropriate result now that this is deprecated because the priority concept has been removed. + return THREAD_PRIORITY_NORMAL; // An appropriate result now that this is deprecated because the + // priority concept has been removed. } -void thread_init(GThreadFunctions* /* vtable */) +void +thread_init(GThreadFunctions* /* vtable */) { - //g_thread_init() is deprecated and now does nothing, - //so we do not even call it. That avoids a need to link to gthread-2.0, - //which contains the empty g_thread_init() implementation. - //g_thread_init(vtable); + // g_thread_init() is deprecated and now does nothing, + // so we do not even call it. That avoids a need to link to gthread-2.0, + // which contains the empty g_thread_init() implementation. + // g_thread_init(vtable); Glib::thread_init_impl(); } -bool thread_supported() +bool +thread_supported() { - //MSVC++ needs the != 0 to avoid an int -> bool cast warning. + // MSVC++ needs the != 0 to avoid an int -> bool cast warning. return (g_thread_supported() != 0); } - // static -void Thread::yield() +void +Thread::yield() { g_thread_yield(); } - -Thread* wrap(GThread* gobject) +Thread* +wrap(GThread* gobject) { return reinterpret_cast(gobject); } - /**** Glib::StaticMutex ****************************************************/ -void StaticMutex::lock() +void +StaticMutex::lock() { g_static_mutex_lock(&gobject_); } -bool StaticMutex::trylock() +bool +StaticMutex::trylock() { return g_static_mutex_trylock(&gobject_); } -void StaticMutex::unlock() +void +StaticMutex::unlock() { g_static_mutex_unlock(&gobject_); } @@ -216,58 +227,64 @@ StaticMutex::operator Mutex&() return reinterpret_cast(runtime_mutex); } - /**** Glib::Mutex **********************************************************/ Mutex::Mutex() -: - gobject_ (g_mutex_new()) //TODO: Use a statically-allocated GMutext instead, with g_mutex_init(). -{} +: gobject_(g_mutex_new()) // TODO: Use a statically-allocated GMutext instead, with g_mutex_init(). +{ +} Mutex::~Mutex() { g_mutex_free(gobject_); } -void Mutex::lock() +void +Mutex::lock() { g_mutex_lock(gobject_); } -bool Mutex::trylock() +bool +Mutex::trylock() { return g_mutex_trylock(gobject_); } -void Mutex::unlock() +void +Mutex::unlock() { g_mutex_unlock(gobject_); } - /**** Glib::StaticRecMutex *************************************************/ -void StaticRecMutex::lock() +void +StaticRecMutex::lock() { g_static_rec_mutex_lock(&gobject_); } -bool StaticRecMutex::trylock() +bool +StaticRecMutex::trylock() { return g_static_rec_mutex_trylock(&gobject_); } -void StaticRecMutex::unlock() +void +StaticRecMutex::unlock() { g_static_rec_mutex_unlock(&gobject_); } -void StaticRecMutex::lock_full(unsigned int depth) +void +StaticRecMutex::lock_full(unsigned int depth) { g_static_rec_mutex_lock_full(&gobject_, depth); } -unsigned int StaticRecMutex::unlock_full() +unsigned int +StaticRecMutex::unlock_full() { return g_static_rec_mutex_unlock_full(&gobject_); } @@ -277,7 +294,6 @@ StaticRecMutex::operator RecMutex&() return static_cast(*this); } - /**** Glib::RecMutex *******************************************************/ RecMutex::RecMutex() @@ -290,35 +306,40 @@ RecMutex::~RecMutex() g_static_rec_mutex_free(&gobject_); } - /**** Glib::StaticRWLock ***************************************************/ -void StaticRWLock::reader_lock() +void +StaticRWLock::reader_lock() { g_static_rw_lock_reader_lock(&gobject_); } -bool StaticRWLock::reader_trylock() +bool +StaticRWLock::reader_trylock() { return g_static_rw_lock_reader_trylock(&gobject_); } -void StaticRWLock::reader_unlock() +void +StaticRWLock::reader_unlock() { g_static_rw_lock_reader_unlock(&gobject_); } -void StaticRWLock::writer_lock() +void +StaticRWLock::writer_lock() { g_static_rw_lock_writer_lock(&gobject_); } -bool StaticRWLock::writer_trylock() +bool +StaticRWLock::writer_trylock() { return g_static_rw_lock_writer_trylock(&gobject_); } -void StaticRWLock::writer_unlock() +void +StaticRWLock::writer_unlock() { g_static_rw_lock_writer_unlock(&gobject_); } @@ -328,7 +349,6 @@ StaticRWLock::operator RWLock&() return static_cast(*this); } - /**** Glib::RWLock *********************************************************/ RWLock::RWLock() @@ -339,9 +359,9 @@ RWLock::RWLock() // of the mutex and the condition variables now, to mimic the behaviour // of a (hypothetical) GRWLock. - if(g_static_mutex_get_mutex(&gobject_.mutex)) + if (g_static_mutex_get_mutex(&gobject_.mutex)) { - gobject_.read_cond = g_cond_new(); + gobject_.read_cond = g_cond_new(); gobject_.write_cond = g_cond_new(); } } @@ -351,51 +371,57 @@ RWLock::~RWLock() g_static_rw_lock_free(&gobject_); } - /**** Glib::Cond ***********************************************************/ -Cond::Cond() -: - gobject_ (g_cond_new()) -{} +Cond::Cond() : gobject_(g_cond_new()) +{ +} Cond::~Cond() { g_cond_free(gobject_); } -void Cond::signal() +void +Cond::signal() { g_cond_signal(gobject_); } -void Cond::broadcast() +void +Cond::broadcast() { g_cond_broadcast(gobject_); } -void Cond::wait(Mutex& mutex) +void +Cond::wait(Mutex& mutex) { g_cond_wait(gobject_, mutex.gobj()); } -bool Cond::timed_wait(Mutex& mutex, const Glib::TimeVal& abs_time) +bool +Cond::timed_wait(Mutex& mutex, const Glib::TimeVal& abs_time) { return g_cond_timed_wait(gobject_, mutex.gobj(), const_cast(&abs_time)); } -void* StaticPrivate_get_helper(GStaticPrivate *private_key) { +void* +StaticPrivate_get_helper(GStaticPrivate* private_key) +{ return g_static_private_get(private_key); } -void StaticPrivate_set_helper(GStaticPrivate *private_key, gpointer data, GDestroyNotify notify) { +void +StaticPrivate_set_helper(GStaticPrivate* private_key, gpointer data, GDestroyNotify notify) +{ return g_static_private_set(private_key, data, notify); } -GPrivate* GPrivate_new_helper(GDestroyNotify notify) { +GPrivate* +GPrivate_new_helper(GDestroyNotify notify) +{ return g_private_new(notify); } - } // namespace Glib - diff --git a/glib/src/threads.ccg b/glib/src/threads.ccg index 5830fae5..274b5a1e 100644 --- a/glib/src/threads.ccg +++ b/glib/src/threads.ccg @@ -35,10 +35,10 @@ namespace { -extern "C" -{ +extern "C" { -static void* call_thread_entry_slot(void* data) +static void* +call_thread_entry_slot(void* data) { const auto slot = reinterpret_cast(data); @@ -61,11 +61,10 @@ static void* call_thread_entry_slot(void* data) return nullptr; } -} //extern "C" +} // extern "C" } // anonymous namespace - namespace Glib { @@ -75,14 +74,15 @@ namespace Threads /**** Glib::Threads::Thread ************************************************/ // static -Thread* Thread::create(const sigc::slot& slot, const std::string& name) +Thread* +Thread::create(const sigc::slot& slot, const std::string& name) { // Make a copy of slot on the heap. const auto slot_copy = new sigc::slot(slot); GError* error = nullptr; - auto thread = g_thread_try_new(name.empty() ? nullptr : name.c_str(), - &call_thread_entry_slot, slot_copy, &error); + auto thread = g_thread_try_new( + name.empty() ? nullptr : name.c_str(), &call_thread_entry_slot, slot_copy, &error); if (error) { @@ -97,44 +97,50 @@ Thread* Thread::create(const sigc::slot& slot, const std::string& name) } // static -Thread* Thread::create(const sigc::slot& slot) +Thread* +Thread::create(const sigc::slot& slot) { return create(slot, std::string()); } // static -Thread* Thread::self() +Thread* +Thread::self() { return reinterpret_cast(g_thread_self()); } -void Thread::join() +void +Thread::join() { g_thread_join(reinterpret_cast(this)); } // static -void Thread::yield() +void +Thread::yield() { g_thread_yield(); } -GThread* Thread::gobj() +GThread* +Thread::gobj() { return reinterpret_cast(this); } -const GThread* Thread::gobj() const +const GThread* +Thread::gobj() const { return reinterpret_cast(this); } -Thread* wrap(GThread* gobject) +Thread* +wrap(GThread* gobject) { return reinterpret_cast(gobject); } - /**** Glib::Threads::Mutex *************************************************/ Mutex::Mutex() @@ -147,22 +153,26 @@ Mutex::~Mutex() g_mutex_clear(&gobject_); } -void Mutex::lock() +void +Mutex::lock() { g_mutex_lock(&gobject_); } -bool Mutex::trylock() +bool +Mutex::trylock() { return g_mutex_trylock(&gobject_); } -void Mutex::unlock() +void +Mutex::unlock() { g_mutex_unlock(&gobject_); } -Mutex* wrap(GMutex* gobject) +Mutex* +wrap(GMutex* gobject) { return reinterpret_cast(gobject); } @@ -179,54 +189,64 @@ RecMutex::~RecMutex() g_rec_mutex_clear(&gobject_); } -void RecMutex::lock() +void +RecMutex::lock() { g_rec_mutex_lock(&gobject_); } -bool RecMutex::trylock() +bool +RecMutex::trylock() { return g_rec_mutex_trylock(&gobject_); } -void RecMutex::unlock() +void +RecMutex::unlock() { g_rec_mutex_unlock(&gobject_); } -RecMutex* wrap(GRecMutex* gobject) +RecMutex* +wrap(GRecMutex* gobject) { return reinterpret_cast(gobject); } /**** Glib::Threads::RWLock ************************************************/ -void RWLock::reader_lock() +void +RWLock::reader_lock() { g_rw_lock_reader_lock(&gobject_); } -bool RWLock::reader_trylock() +bool +RWLock::reader_trylock() { return g_rw_lock_reader_trylock(&gobject_); } -void RWLock::reader_unlock() +void +RWLock::reader_unlock() { g_rw_lock_reader_unlock(&gobject_); } -void RWLock::writer_lock() +void +RWLock::writer_lock() { g_rw_lock_writer_lock(&gobject_); } -bool RWLock::writer_trylock() +bool +RWLock::writer_trylock() { return g_rw_lock_writer_trylock(&gobject_); } -void RWLock::writer_unlock() +void +RWLock::writer_unlock() { g_rw_lock_writer_unlock(&gobject_); } @@ -241,7 +261,6 @@ RWLock::~RWLock() g_rw_lock_clear(&gobject_); } - /**** Glib::Threads::Cond **************************************************/ Cond::Cond() @@ -254,22 +273,26 @@ Cond::~Cond() g_cond_clear(&gobject_); } -void Cond::signal() +void +Cond::signal() { g_cond_signal(&gobject_); } -void Cond::broadcast() +void +Cond::broadcast() { g_cond_broadcast(&gobject_); } -void Cond::wait(Mutex& mutex) +void +Cond::wait(Mutex& mutex) { g_cond_wait(&gobject_, mutex.gobj()); } -bool Cond::wait_until(Mutex& mutex, gint64 end_time) +bool +Cond::wait_until(Mutex& mutex, gint64 end_time) { return g_cond_wait_until(&gobject_, mutex.gobj(), end_time); } @@ -277,4 +300,3 @@ bool Cond::wait_until(Mutex& mutex, gint64 end_time) } // namespace Threads } // namespace Glib - diff --git a/glib/src/timezone.ccg b/glib/src/timezone.ccg index 79957c1e..ad11205c 100644 --- a/glib/src/timezone.ccg +++ b/glib/src/timezone.ccg @@ -20,4 +20,4 @@ namespace Glib { -}// namespace Glib +} // namespace Glib diff --git a/glib/src/unicode.ccg b/glib/src/unicode.ccg index 28b07948..be4c2b5f 100644 --- a/glib/src/unicode.ccg +++ b/glib/src/unicode.ccg @@ -16,4 +16,3 @@ */ #include - diff --git a/glib/src/uriutils.ccg b/glib/src/uriutils.ccg index aeba8c42..c34848bb 100644 --- a/glib/src/uriutils.ccg +++ b/glib/src/uriutils.ccg @@ -21,22 +21,26 @@ namespace Glib { -std::string uri_unescape_string(const std::string& escaped_string, const std::string& illegal_characters) +std::string +uri_unescape_string(const std::string& escaped_string, const std::string& illegal_characters) { gchar* cresult = g_uri_unescape_string(escaped_string.c_str(), illegal_characters.c_str()); return Glib::convert_return_gchar_ptr_to_stdstring(cresult); } -std::string uri_parse_scheme(const std::string& uri) +std::string +uri_parse_scheme(const std::string& uri) { - return Glib::convert_return_gchar_ptr_to_stdstring( g_uri_parse_scheme(uri.c_str()) ); + return Glib::convert_return_gchar_ptr_to_stdstring(g_uri_parse_scheme(uri.c_str())); } -std::string uri_escape_string(const std::string& unescaped, const std::string& reserved_chars_allowed, bool allow_utf8) +std::string +uri_escape_string( + const std::string& unescaped, const std::string& reserved_chars_allowed, bool allow_utf8) { - gchar* cresult = g_uri_escape_string(unescaped.c_str(), reserved_chars_allowed.c_str(), allow_utf8); + gchar* cresult = + g_uri_escape_string(unescaped.c_str(), reserved_chars_allowed.c_str(), allow_utf8); return Glib::convert_return_gchar_ptr_to_stdstring(cresult); } } // namespace Glib - diff --git a/glib/src/valuearray.ccg b/glib/src/valuearray.ccg index 8b82aeda..e50323ff 100644 --- a/glib/src/valuearray.ccg +++ b/glib/src/valuearray.ccg @@ -17,18 +17,17 @@ #include -static int ValueArray_Compare_glibmm_callback(gconstpointer a, - gconstpointer b, gpointer user_data) +static int +ValueArray_Compare_glibmm_callback(gconstpointer a, gconstpointer b, gpointer user_data) { - Glib::ValueArray::SlotCompare* the_slot = - static_cast(user_data); + Glib::ValueArray::SlotCompare* the_slot = static_cast(user_data); try { - return (*the_slot)(*reinterpret_cast(a), - *reinterpret_cast(b)); + return (*the_slot)( + *reinterpret_cast(a), *reinterpret_cast(b)); } - catch(...) + catch (...) { Glib::exception_handlers_invoke(); } @@ -40,17 +39,19 @@ namespace Glib { ValueArray::ValueArray() : gobject_(g_value_array_new(0)) -{} +{ +} -ValueArray::ValueArray(guint n_preallocated) : - gobject_(g_value_array_new(n_preallocated)) -{} +ValueArray::ValueArray(guint n_preallocated) : gobject_(g_value_array_new(n_preallocated)) +{ +} -bool ValueArray::get_nth(guint index, Glib::ValueBase& value) +bool +ValueArray::get_nth(guint index, Glib::ValueBase& value) { const auto g_value = g_value_array_get_nth(gobj(), index); - if(g_value) + if (g_value) { value.init(g_value); return true; @@ -59,35 +60,39 @@ bool ValueArray::get_nth(guint index, Glib::ValueBase& value) return false; } -Glib::ValueArray& ValueArray::append(const Glib::ValueBase& value) +Glib::ValueArray& +ValueArray::append(const Glib::ValueBase& value) { g_value_array_append(gobj(), value.gobj()); return *this; } -Glib::ValueArray& ValueArray::prepend(const Glib::ValueBase& value) +Glib::ValueArray& +ValueArray::prepend(const Glib::ValueBase& value) { g_value_array_prepend(gobj(), value.gobj()); return *this; } -Glib::ValueArray& ValueArray::insert(guint index, const Glib::ValueBase& value) +Glib::ValueArray& +ValueArray::insert(guint index, const Glib::ValueBase& value) { g_value_array_insert(gobj(), index, value.gobj()); return *this; } -Glib::ValueArray& ValueArray::remove(guint index) +Glib::ValueArray& +ValueArray::remove(guint index) { g_value_array_remove(gobj(), index); return *this; } -Glib::ValueArray& ValueArray::sort(const SlotCompare& compare_func) +Glib::ValueArray& +ValueArray::sort(const SlotCompare& compare_func) { SlotCompare slot_copy(compare_func); - g_value_array_sort_with_data(gobj(), &ValueArray_Compare_glibmm_callback, - &slot_copy); + g_value_array_sort_with_data(gobj(), &ValueArray_Compare_glibmm_callback, &slot_copy); return *this; } diff --git a/glib/src/variant.ccg b/glib/src/variant.ccg index aba6902b..3093dfa2 100644 --- a/glib/src/variant.ccg +++ b/glib/src/variant.ccg @@ -29,34 +29,36 @@ VariantBase::VariantBase(GVariant* castitem, bool make_a_copy /* = false */) { if (g_variant_is_floating(castitem)) { - g_variant_ref_sink (castitem); + g_variant_ref_sink(castitem); } if (make_a_copy) { - g_variant_ref (castitem); + g_variant_ref(castitem); } } gobject_ = castitem; } -void VariantBase::get_normal_form(VariantBase& result) const +void +VariantBase::get_normal_form(VariantBase& result) const { - GVariant* const g_value = - g_variant_get_normal_form(const_cast(gobj())); + GVariant* const g_value = g_variant_get_normal_form(const_cast(gobj())); - //The C function never returns NULL, according to its documenation, - //so we don't need a bool return value. + // The C function never returns NULL, according to its documenation, + // so we don't need a bool return value. result.init(g_value); // g_value is already referenced. } -void VariantBase::byteswap(VariantBase& result) const +void +VariantBase::byteswap(VariantBase& result) const { GVariant* const g_value = g_variant_byteswap(const_cast(gobj())); result.init(g_value); // g_value is already referenced. } -bool VariantBase::is_castable_to(const VariantType& supertype) const +bool +VariantBase::is_castable_to(const VariantType& supertype) const { const std::string subtype_string = get_type_string(); const std::string supertype_string = supertype.get_string(); @@ -93,7 +95,7 @@ bool VariantBase::is_castable_to(const VariantType& supertype) const case 'a': if (!(supertype_string[supertype_index] == 'y' && - (subtype_char == 's' || subtype_char == 'o' || subtype_char == 'g'))) + (subtype_char == 's' || subtype_char == 'o' || subtype_char == 'g'))) return false; supertype_index++; break; @@ -110,9 +112,7 @@ bool VariantBase::is_castable_to(const VariantType& supertype) const return true; } - -VariantStringBase::VariantStringBase() -: VariantBase() +VariantStringBase::VariantStringBase() : VariantBase() { } @@ -121,9 +121,9 @@ VariantStringBase::VariantStringBase(GVariant* castitem, bool take_a_reference) { } -//static -void VariantStringBase::create_object_path(VariantStringBase& output, - const std::string& object_path) +// static +void +VariantStringBase::create_object_path(VariantStringBase& output, const std::string& object_path) { GVariant* result = nullptr; result = g_variant_new_object_path(object_path.c_str()); @@ -131,9 +131,9 @@ void VariantStringBase::create_object_path(VariantStringBase& output, output.init(result); } -//static -void VariantStringBase::create_signature(VariantStringBase& output, - const std::string& signature) +// static +void +VariantStringBase::create_signature(VariantStringBase& output, const std::string& signature) { GVariant* result = nullptr; result = g_variant_new_signature(signature.c_str()); @@ -141,9 +141,7 @@ void VariantStringBase::create_signature(VariantStringBase& output, output.init(result); } - -VariantContainerBase::VariantContainerBase() -: VariantBase() +VariantContainerBase::VariantContainerBase() : VariantBase() { } @@ -152,25 +150,25 @@ VariantContainerBase::VariantContainerBase(GVariant* castitem, bool take_a_refer { } -//static +// static VariantContainerBase VariantContainerBase::create_tuple(const std::vector& children) { typedef GVariant* var_ptr; var_ptr* const var_array = new var_ptr[children.size()]; - for(std::vector::size_type i = 0; i < children.size(); i++) + for (std::vector::size_type i = 0; i < children.size(); i++) { var_array[i] = const_cast(children[i].gobj()); } - VariantContainerBase result = VariantContainerBase(g_variant_new_tuple( - var_array, children.size())); + VariantContainerBase result = + VariantContainerBase(g_variant_new_tuple(var_array, children.size())); delete[] var_array; return result; } -//static +// static VariantContainerBase VariantContainerBase::create_tuple(const VariantBase& child) { @@ -179,53 +177,51 @@ VariantContainerBase::create_tuple(const VariantBase& child) return create_tuple(vec); } -//static +// static VariantContainerBase -VariantContainerBase::create_maybe(const VariantType& child_type, - const VariantBase& child) +VariantContainerBase::create_maybe(const VariantType& child_type, const VariantBase& child) { - GVariant* g_variant = g_variant_new_maybe(child_type.gobj(), - const_cast(child.gobj())); + GVariant* g_variant = g_variant_new_maybe(child_type.gobj(), const_cast(child.gobj())); VariantContainerBase result = VariantContainerBase(g_variant); return result; } -void VariantContainerBase::get_child(VariantBase& child, gsize index) const +void +VariantContainerBase::get_child(VariantBase& child, gsize index) const { - if(index >= g_variant_n_children(gobject_)) - throw std::out_of_range( - "VariantContainerBase::get_child(): Index out of bounds."); + if (index >= g_variant_n_children(gobject_)) + throw std::out_of_range("VariantContainerBase::get_child(): Index out of bounds."); GVariant* const gvariant = g_variant_get_child_value(gobject_, index); child.init(gvariant); } // VariantContainerBase has no method variant_type() -template<> -VariantContainerBase VariantBase::cast_dynamic(const VariantBase& v) -throw(std::bad_cast) +template <> +VariantContainerBase +VariantBase::cast_dynamic(const VariantBase& v) throw(std::bad_cast) { - if(!v.gobj()) + if (!v.gobj()) { return VariantContainerBase(); } - if(v.get_type().is_container()) + if (v.get_type().is_container()) { return VariantContainerBase(const_cast(v.gobj()), true); } else { - //std::cerr << "vtype=" << v.get_type_string() << std::endl; + // std::cerr << "vtype=" << v.get_type_string() << std::endl; throw std::bad_cast(); } } -bool VariantContainerBase::get_maybe(VariantBase& maybe) const +bool +VariantContainerBase::get_maybe(VariantBase& maybe) const { - GVariant* const g_value = - g_variant_get_maybe(const_cast(gobj())); + GVariant* const g_value = g_variant_get_maybe(const_cast(gobj())); - if(g_value) + if (g_value) { maybe.init(g_value); // g_value is already referenced. return true; @@ -234,7 +230,8 @@ bool VariantContainerBase::get_maybe(VariantBase& maybe) const return false; } -VariantIter VariantContainerBase::get_iter(const VariantType& container_variant_type) const +VariantIter +VariantContainerBase::get_iter(const VariantType& container_variant_type) const { // Get the GVariantIter. // If the underlying GVariant can be cast to the type of the container, @@ -243,8 +240,8 @@ VariantIter VariantContainerBase::get_iter(const VariantType& container_variant_ // otherwise let g_variant_get() report what's wrong with the type. GVariantIter* g_iter = nullptr; g_variant_get(const_cast(gobj()), - is_castable_to(container_variant_type) ? - get_type_string().c_str() : container_variant_type.get_string().c_str(), + is_castable_to(container_variant_type) ? get_type_string().c_str() + : container_variant_type.get_string().c_str(), &g_iter); return VariantIter(g_iter); @@ -257,20 +254,20 @@ VariantBase::operator const void*() const return gobj() ? GINT_TO_POINTER(1) : nullptr; } -void VariantBase::init(const GVariant* cobject, bool take_a_reference) +void +VariantBase::init(const GVariant* cobject, bool take_a_reference) { - if(gobject_) + if (gobject_) g_variant_unref(gobject_); gobject_ = const_cast(cobject); - if(take_a_reference) + if (take_a_reference) g_variant_ref(gobject_); } /*--------------------Variant---------------------*/ -Variant::Variant() -: VariantContainerBase() +Variant::Variant() : VariantContainerBase() { } @@ -280,18 +277,21 @@ Variant::Variant(GVariant* castitem, bool take_a_reference) } // static -const VariantType& Variant::variant_type() +const VariantType& +Variant::variant_type() { return VARIANT_TYPE_VARIANT; } -Variant Variant::create(const VariantBase& data) +Variant +Variant::create(const VariantBase& data) { auto result = Variant(g_variant_new_variant(const_cast(data.gobj()))); return result; } -void Variant::get(VariantBase& variant) const +void +Variant::get(VariantBase& variant) const { GVariant* const gvariant = g_variant_get_variant(gobject_); variant.init(gvariant); @@ -299,8 +299,7 @@ void Variant::get(VariantBase& variant) const /*--------------------Variant---------------------*/ -Variant::Variant() -: VariantStringBase() +Variant::Variant() : VariantStringBase() { } @@ -310,7 +309,8 @@ Variant::Variant(GVariant* castitem, bool take_a_reference) } // static -const VariantType& Variant::variant_type() +const VariantType& +Variant::variant_type() { return VARIANT_TYPE_STRING; } @@ -318,45 +318,43 @@ const VariantType& Variant::variant_type() Variant Variant::create(const Glib::ustring& data) { - auto result = - Variant(g_variant_new_string(data.c_str())); + auto result = Variant(g_variant_new_string(data.c_str())); return result; } -Glib::ustring Variant::get() const +Glib::ustring +Variant::get() const { return convert_const_gchar_ptr_to_ustring(g_variant_get_string(gobject_, nullptr)); } // Variant makes sense for multiple types. // See http://library.gnome.org/devel/glib/unstable/glib-GVariant.html#g-variant-get-string -template<> -Variant VariantBase::cast_dynamic< Variant >(const VariantBase& v) -throw(std::bad_cast) +template <> +Variant +VariantBase::cast_dynamic>(const VariantBase& v) throw(std::bad_cast) { - if(!v.gobj()) + if (!v.gobj()) { return Variant(); } const VariantType vtype = v.get_type(); - if( vtype.equal(VARIANT_TYPE_STRING) || - vtype.equal(VARIANT_TYPE_OBJECT_PATH) || - vtype.equal(VARIANT_TYPE_SIGNATURE) ) + if (vtype.equal(VARIANT_TYPE_STRING) || vtype.equal(VARIANT_TYPE_OBJECT_PATH) || + vtype.equal(VARIANT_TYPE_SIGNATURE)) { return Variant(const_cast(v.gobj()), true); } else { - //std::cerr << "vtype=" << v.get_type_string() << std::endl; + // std::cerr << "vtype=" << v.get_type_string() << std::endl; throw std::bad_cast(); } } /*--------------------Variant---------------------*/ -Variant::Variant() -: VariantStringBase() +Variant::Variant() : VariantStringBase() { } @@ -366,7 +364,8 @@ Variant::Variant(GVariant* castitem, bool take_a_reference) } // static -const VariantType& Variant::variant_type() +const VariantType& +Variant::variant_type() { return VARIANT_TYPE_BYTESTRING; } @@ -374,45 +373,43 @@ const VariantType& Variant::variant_type() Variant Variant::create(const std::string& data) { - auto result = - Variant(g_variant_new_bytestring(data.c_str())); + auto result = Variant(g_variant_new_bytestring(data.c_str())); return result; } // Variant makes sense for multiple types. // See http://library.gnome.org/devel/glib/unstable/glib-GVariant.html#g-variant-get-string -template<> -Variant VariantBase::cast_dynamic< Variant >(const VariantBase& v) -throw(std::bad_cast) +template <> +Variant +VariantBase::cast_dynamic>(const VariantBase& v) throw(std::bad_cast) { - if(!v.gobj()) + if (!v.gobj()) { return Variant(); } const VariantType vtype = v.get_type(); - if( vtype.equal(VARIANT_TYPE_STRING) || - vtype.equal(VARIANT_TYPE_BYTESTRING) || - vtype.equal(VARIANT_TYPE_OBJECT_PATH) || - vtype.equal(VARIANT_TYPE_SIGNATURE) ) + if (vtype.equal(VARIANT_TYPE_STRING) || vtype.equal(VARIANT_TYPE_BYTESTRING) || + vtype.equal(VARIANT_TYPE_OBJECT_PATH) || vtype.equal(VARIANT_TYPE_SIGNATURE)) { return Variant(const_cast(v.gobj()), true); } else { - //std::cerr << "vtype=" << v.get_type_string() << std::endl; + // std::cerr << "vtype=" << v.get_type_string() << std::endl; throw std::bad_cast(); } } -std::string Variant::get() const +std::string +Variant::get() const { const VariantType vtype = get_type(); const char* pch = nullptr; - if(vtype.equal(VARIANT_TYPE_BYTESTRING)) + if (vtype.equal(VARIANT_TYPE_BYTESTRING)) pch = g_variant_get_bytestring(gobject_); - else //g_variant_get_string() can handle strings, object paths, and signatures. + else // g_variant_get_string() can handle strings, object paths, and signatures. pch = g_variant_get_string(gobject_, nullptr); return convert_const_gchar_ptr_to_stdstring(pch); @@ -422,8 +419,7 @@ std::string Variant::get() const typedef std::vector type_vec_ustring; -Variant::Variant() -: VariantContainerBase() +Variant::Variant() : VariantContainerBase() { } @@ -433,7 +429,8 @@ Variant::Variant(GVariant* castitem, bool take_a_reference) } // static -const VariantType& Variant::variant_type() +const VariantType& +Variant::variant_type() { return VARIANT_TYPE_STRING_ARRAY; } @@ -451,35 +448,34 @@ Variant::create(const type_vec_ustring& data) GVariantBuilder* builder = g_variant_builder_new(array_variant_type.gobj()); // Add the elements of the vector into the builder. - for(const auto& str : data) + for (const auto& str : data) { - g_variant_builder_add(builder, - element_variant_type.get_string().c_str(), str.c_str()); + g_variant_builder_add(builder, element_variant_type.get_string().c_str(), str.c_str()); } // Create the variant using the builder. auto result = - Variant(g_variant_new( - array_variant_type.get_string().c_str(), builder)); + Variant(g_variant_new(array_variant_type.get_string().c_str(), builder)); g_variant_builder_unref(builder); return result; } -Glib::ustring Variant::get_child(gsize index) const +Glib::ustring +Variant::get_child(gsize index) const { if (index >= g_variant_n_children(const_cast(gobj()))) throw std::out_of_range( "Variant< std::vector >::get_child(): Index out of bounds."); - GVariant* gvariant = - g_variant_get_child_value(const_cast(gobj()), index); + GVariant* gvariant = g_variant_get_child_value(const_cast(gobj()), index); return Glib::Variant(gvariant).get(); } -type_vec_ustring Variant::get() const +type_vec_ustring +Variant::get() const { // g_variant_get_strv() can be used only if the type is VARIANT_TYPE_STRING_ARRAY, // but the Variant can alternatively hold an array of object paths or DBus type signatures. @@ -489,8 +485,7 @@ type_vec_ustring Variant::get() const for (gsize i = 0; i < n_children; i++) { - GVariant* gvariant = - g_variant_get_child_value(const_cast(gobj()), i); + GVariant* gvariant = g_variant_get_child_value(const_cast(gobj()), i); result.emplace_back(Glib::Variant(gvariant).get()); } @@ -498,7 +493,8 @@ type_vec_ustring Variant::get() const return result; } -VariantIter Variant::get_iter() const +VariantIter +Variant::get_iter() const { return VariantContainerBase::get_iter(variant_type()); } @@ -507,8 +503,7 @@ VariantIter Variant::get_iter() const typedef std::vector type_vec_string; -Variant::Variant() -: VariantContainerBase() +Variant::Variant() : VariantContainerBase() { } @@ -518,7 +513,8 @@ Variant::Variant(GVariant* castitem, bool take_a_reference) } // static -const VariantType& Variant::variant_type() +const VariantType& +Variant::variant_type() { return VARIANT_TYPE_BYTESTRING_ARRAY; } @@ -530,7 +526,7 @@ Variant::create(const type_vec_string& data) char** str_array = g_new(char*, data.size() + 1); // Add the elements of the vector into the string array. - for(type_vec_string::size_type i = 0; i < data.size(); i++) + for (type_vec_string::size_type i = 0; i < data.size(); i++) { str_array[i] = g_strdup(data[i].c_str()); } @@ -540,9 +536,7 @@ Variant::create(const type_vec_string& data) // Create the variant using g_variant_new_bytestring_array() (passing the // newly constructed array. - auto result = - Variant(g_variant_new_bytestring_array(str_array, - data.size())); + auto result = Variant(g_variant_new_bytestring_array(str_array, data.size())); g_strfreev(str_array); return result; @@ -555,7 +549,7 @@ Variant::create_from_object_paths(const type_vec_string& data) char** str_array = g_new(char*, data.size() + 1); // Add the elements of the vector into the string array. - for(type_vec_string::size_type i = 0; i < data.size(); i++) + for (type_vec_string::size_type i = 0; i < data.size(); i++) { str_array[i] = g_strdup(data[i].c_str()); } @@ -565,37 +559,37 @@ Variant::create_from_object_paths(const type_vec_string& data) // Create the variant using g_variant_new_objv() (passing the // newly constructed array. - auto result = - Variant(g_variant_new_objv(str_array, data.size())); + auto result = Variant(g_variant_new_objv(str_array, data.size())); g_strfreev(str_array); return result; } -std::string Variant::get_child(gsize index) const +std::string +Variant::get_child(gsize index) const { if (index >= g_variant_n_children(const_cast(gobj()))) throw std::out_of_range( "Variant< std::vector >::get_child(): Index out of bounds."); - GVariant* gvariant = - g_variant_get_child_value(const_cast(gobj()), index); + GVariant* gvariant = g_variant_get_child_value(const_cast(gobj()), index); return Glib::Variant(gvariant).get(); } -type_vec_string Variant::get() const +type_vec_string +Variant::get() const { // g_variant_get_bytestring_array() can be used only if the type is VARIANT_TYPE_BYTESTRING_ARRAY, - // but the Variant can alternatively hold an array of strings, object paths or DBus type signatures. + // but the Variant can alternatively hold an array of strings, object paths or DBus type + // signatures. type_vec_string result; gsize n_children = g_variant_n_children(const_cast(gobj())); for (gsize i = 0; i < n_children; i++) { - GVariant* gvariant = - g_variant_get_child_value(const_cast(gobj()), i); + GVariant* gvariant = g_variant_get_child_value(const_cast(gobj()), i); result.emplace_back(Glib::Variant(gvariant).get()); } @@ -603,7 +597,8 @@ type_vec_string Variant::get() const return result; } -VariantIter Variant::get_iter() const +VariantIter +Variant::get_iter() const { return VariantContainerBase::get_iter(variant_type()); } diff --git a/glib/src/variantdict.ccg b/glib/src/variantdict.ccg index ddc061dd..6e069a30 100644 --- a/glib/src/variantdict.ccg +++ b/glib/src/variantdict.ccg @@ -21,19 +21,17 @@ namespace Glib { -bool VariantDict::lookup_value_variant(const Glib::ustring& key, const VariantType& expected_type, VariantBase& value) const +bool +VariantDict::lookup_value_variant( + const Glib::ustring& key, const VariantType& expected_type, VariantBase& value) const { - GVariant* const g_value = - g_variant_dict_lookup_value(const_cast(gobj()), - key.c_str(), - expected_type.gobj()); - if(!g_value) - return false; + GVariant* const g_value = g_variant_dict_lookup_value( + const_cast(gobj()), key.c_str(), expected_type.gobj()); + if (!g_value) + return false; value.init(g_value); // g_value is already referenced. return true; } -} //namespace Glib - - +} // namespace Glib diff --git a/glib/src/variantiter.ccg b/glib/src/variantiter.ccg index 6c20ac9d..ca83053a 100644 --- a/glib/src/variantiter.ccg +++ b/glib/src/variantiter.ccg @@ -26,12 +26,12 @@ VariantIter::VariantIter(const VariantBase& variant) { } -bool VariantIter::next_value(VariantBase& value) +bool +VariantIter::next_value(VariantBase& value) { - GVariant* const g_value = - g_variant_iter_next_value(gobj()); + GVariant* const g_value = g_variant_iter_next_value(gobj()); - if(g_value) + if (g_value) { value.init(g_value); // g_value is already referenced. return true; @@ -40,4 +40,4 @@ bool VariantIter::next_value(VariantBase& value) return false; } -} //namespace Glib +} // namespace Glib diff --git a/glib/src/varianttype.ccg b/glib/src/varianttype.ccg index d75306b3..4f43b569 100644 --- a/glib/src/varianttype.ccg +++ b/glib/src/varianttype.ccg @@ -24,7 +24,7 @@ namespace Glib VariantType::VariantType(const GVariantType* castitem) { - if(castitem) + if (castitem) gobject_ = g_variant_type_copy(castitem); else gobject_ = nullptr; @@ -35,14 +35,15 @@ VariantType::VariantType(const std::string& type_string) { } -VariantType& VariantType::operator=(const GVariantType* castitem) +VariantType& +VariantType::operator=(const GVariantType* castitem) { - if(gobject_) + if (gobject_) { - g_variant_type_free (gobject_); + g_variant_type_free(gobject_); } - if(castitem) + if (castitem) gobject_ = g_variant_type_copy(castitem); else gobject_ = nullptr; @@ -50,13 +51,13 @@ VariantType& VariantType::operator=(const GVariantType* castitem) return *this; } - -VariantType VariantType::create_tuple(const std::vector& items) +VariantType +VariantType::create_tuple(const std::vector& items) { typedef GVariantType* var_ptr; const auto var_array = new var_ptr[items.size()]; - for(std::vector::size_type i = 0; i < items.size(); i++) + for (std::vector::size_type i = 0; i < items.size(); i++) { var_array[i] = const_cast(items[i].gobj()); } @@ -116,9 +117,9 @@ const VariantType VARIANT_TYPE_BYTESTRING(G_VARIANT_TYPE_BYTESTRING); const VariantType VARIANT_TYPE_BYTESTRING_ARRAY(G_VARIANT_TYPE_BYTESTRING_ARRAY); -std::string VariantType::get_string() const +std::string +VariantType::get_string() const { return std::string(g_variant_type_peek_string(gobj()), g_variant_type_get_string_length(gobj())); } - } -- cgit v1.2.1