[glibmm] More use of nullptr instead of 0 or NULL.



commit d81579ee90d1b3939110ed0eae526617a5edf64a
Author: Murray Cumming <murrayc murrayc com>
Date:   Thu Nov 19 13:05:58 2015 +0100

    More use of nullptr instead of 0 or NULL.

 glib/glibmm/utility.h    |    2 +-
 glib/src/optiongroup.ccg |   12 +++++-----
 glib/src/regex.ccg       |   14 ++++++------
 glib/src/spawn.ccg       |   54 +++++++++++++++++++++++-----------------------
 glib/src/threads.ccg     |    2 +-
 glib/src/variant.ccg     |   10 ++++----
 6 files changed, 47 insertions(+), 47 deletions(-)
---
diff --git a/glib/glibmm/utility.h b/glib/glibmm/utility.h
index 3038dff..fcec8ec 100644
--- a/glib/glibmm/utility.h
+++ b/glib/glibmm/utility.h
@@ -67,7 +67,7 @@ private:
   ScopedPtr<T>& operator=(const ScopedPtr<T>&);
 
 public:
-  ScopedPtr()                 : ptr_ (0)   {}
+  ScopedPtr()                 : ptr_ (nullptr)   {}
   explicit ScopedPtr(T* ptr)  : ptr_ (ptr) {}
   ~ScopedPtr()  noexcept      { g_free(ptr_); }
   T*  get() const             { return ptr_;  }
diff --git a/glib/src/optiongroup.ccg b/glib/src/optiongroup.ccg
index 2ce9102..0dbba0d 100644
--- a/glib/src/optiongroup.ccg
+++ b/glib/src/optiongroup.ccg
@@ -35,11 +35,11 @@ class OptionArgCallback
 {
 public:
   explicit OptionArgCallback(const OptionGroup::SlotOptionArgString& slot)
-  : slot_string_(new OptionGroup::SlotOptionArgString(slot)), slot_filename_(0)
+  : slot_string_(new OptionGroup::SlotOptionArgString(slot)), slot_filename_(nullptr)
   { }
 
   explicit OptionArgCallback(const OptionGroup::SlotOptionArgFilename& slot)
-  : slot_string_(0), slot_filename_(new OptionGroup::SlotOptionArgFilename(slot))
+  : slot_string_(nullptr), slot_filename_(new OptionGroup::SlotOptionArgFilename(slot))
   { }
 
   bool is_filename_option() const
@@ -129,7 +129,7 @@ const gchar* OptionGroup_Translate_glibmm_callback(const gchar* string,
     Glib::exception_handlers_invoke();
   }
 
-  return 0;
+  return nullptr;
 }
 
 static void OptionGroup_Translate_glibmm_callback_destroy(void* data)
@@ -260,7 +260,7 @@ gboolean OptionGroup::option_arg_callback(const gchar* option_name, const gchar*
 
 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 */, 0 /* destroy_func */) ),
+            this /* user_data */, nullptr /* destroy_func */) ),
   has_ownership_(true)
 {
   //g_callback_pre_parse(), post_parse_callback(), g_callback_error(), and
@@ -488,7 +488,7 @@ void OptionGroup::set_translate_func(const SlotTranslate& slot)
 
 
 OptionGroup::CppOptionEntry::CppOptionEntry()
-: carg_type_(G_OPTION_ARG_NONE), carg_(0), cpparg_(0), entry_(0)
+: carg_type_(G_OPTION_ARG_NONE), carg_(nullptr), cpparg_(nullptr), entry_(nullptr)
 {}
 
 void OptionGroup::CppOptionEntry::allocate_c_arg()
@@ -531,7 +531,7 @@ void OptionGroup::CppOptionEntry::allocate_c_arg()
     {
       char*** typed_arg = new char**;
       //The C code will allocate a char** and put it here, for us to g_strfreev() later.
-      *typed_arg = 0;
+      *typed_arg = nullptr;
       carg_ = typed_arg;
 
       break;
diff --git a/glib/src/regex.ccg b/glib/src/regex.ccg
index 3b9e2b2..1ee7299 100644
--- a/glib/src/regex.ccg
+++ b/glib/src/regex.ccg
@@ -56,7 +56,7 @@ bool Regex::match(
 
 bool Regex::match(const Glib::ustring& string, RegexMatchFlags match_options)
 {
-  return g_regex_match(gobj(), string.c_str(), (GRegexMatchFlags)(match_options), 0);
+  return g_regex_match(gobj(), string.c_str(), (GRegexMatchFlags)(match_options), nullptr);
 }
 
 bool Regex::match(
@@ -105,7 +105,7 @@ bool Regex::match(
 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)), 0, &(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);
 
@@ -115,7 +115,7 @@ bool Regex::match(const Glib::ustring& string, int start_position, RegexMatchFla
 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)), 0, &(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);
 
@@ -138,7 +138,7 @@ bool Regex::match_all(
 
 bool Regex::match_all(const Glib::ustring& string, RegexMatchFlags match_options)
 {
-  return g_regex_match_all(gobj(), string.c_str(), ((GRegexMatchFlags)(match_options)), 0);
+  return g_regex_match_all(gobj(), string.c_str(), ((GRegexMatchFlags)(match_options)), nullptr);
 }
 
 bool Regex::match_all(
@@ -187,7 +187,7 @@ bool Regex::match_all(
 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)), 0, &(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);
 
@@ -197,7 +197,7 @@ bool Regex::match_all(const Glib::ustring& string, int start_position, RegexMatc
 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)), 0, &(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);
 
@@ -237,7 +237,7 @@ Glib::StringArrayHandle Regex::split(const Glib::ustring& string, int start_posi
 
 
 MatchInfo::MatchInfo()
-: gobject_(0),
+: gobject_(nullptr),
   take_ownership(false)
 {
 }
diff --git a/glib/src/spawn.ccg b/glib/src/spawn.ccg
index 5cfbdb7..703236e 100644
--- a/glib/src/spawn.ccg
+++ b/glib/src/spawn.ccg
@@ -78,12 +78,12 @@ void spawn_async_with_pipes(const std::string& working_directory,
   GError* gerror = nullptr;
 
   g_spawn_async_with_pipes(
-      (working_directory.empty()) ? 0 : working_directory.c_str(),
+      (working_directory.empty()) ? nullptr : working_directory.c_str(),
       const_cast<char**>(argv.data()),
       const_cast<char**>(envp.data()),
       static_cast<GSpawnFlags>(unsigned(flags)),
-      (setup_slot) ? &child_setup_callback : 0,
-      (setup_slot) ? &child_setup_         : 0,
+      (setup_slot) ? &child_setup_callback : nullptr,
+      (setup_slot) ? &child_setup_         : nullptr,
       child_pid,
       standard_input, standard_output, standard_error,
       &gerror);
@@ -106,11 +106,11 @@ void spawn_async_with_pipes(const std::string& working_directory,
   GError* gerror = nullptr;
 
   g_spawn_async_with_pipes(
-      (working_directory.empty()) ? 0 : working_directory.c_str(),
-      const_cast<char**>(argv.data()), 0,
+      (working_directory.empty()) ? nullptr : working_directory.c_str(),
+      const_cast<char**>(argv.data()), nullptr,
       static_cast<GSpawnFlags>(unsigned(flags)),
-      (setup_slot) ? &child_setup_callback : 0,
-      (setup_slot) ? &child_setup_         : 0,
+      (setup_slot) ? &child_setup_callback : nullptr,
+      (setup_slot) ? &child_setup_         : nullptr,
       child_pid,
       standard_input, standard_output, standard_error,
       &gerror);
@@ -131,12 +131,12 @@ void spawn_async(const std::string& working_directory,
   GError* gerror = nullptr;
 
   g_spawn_async(
-      (working_directory.empty()) ? 0 : working_directory.c_str(),
+      (working_directory.empty()) ? nullptr : working_directory.c_str(),
       const_cast<char**>(argv.data()),
       const_cast<char**>(envp.data()),
       static_cast<GSpawnFlags>(unsigned(flags)),
-      (setup_slot) ? &child_setup_callback : 0,
-      (setup_slot) ? &child_setup_         : 0,
+      (setup_slot) ? &child_setup_callback : nullptr,
+      (setup_slot) ? &child_setup_         : nullptr,
       child_pid,
       &gerror);
 
@@ -155,11 +155,11 @@ void spawn_async(const std::string& working_directory,
   GError* gerror = nullptr;
 
   g_spawn_async(
-      (working_directory.empty()) ? 0 : working_directory.c_str(),
-      const_cast<char**>(argv.data()), 0,
+      (working_directory.empty()) ? nullptr : working_directory.c_str(),
+      const_cast<char**>(argv.data()), nullptr,
       static_cast<GSpawnFlags>(unsigned(flags)),
-      (setup_slot) ? &child_setup_callback : 0,
-      (setup_slot) ? &child_setup_         : 0,
+      (setup_slot) ? &child_setup_callback : nullptr,
+      (setup_slot) ? &child_setup_         : nullptr,
       child_pid,
       &gerror);
 
@@ -184,14 +184,14 @@ void spawn_sync(const std::string& working_directory,
   GError* gerror = nullptr;
 
   g_spawn_sync(
-      (working_directory.empty()) ? 0 : working_directory.c_str(),
+      (working_directory.empty()) ? nullptr : working_directory.c_str(),
       const_cast<char**>(argv.data()),
       const_cast<char**>(envp.data()),
       static_cast<GSpawnFlags>(unsigned(flags)),
-      (setup_slot) ? &child_setup_callback : 0,
-      (setup_slot) ? &child_setup_         : 0,
-      (standard_output) ? buf_standard_output.addr() : 0,
-      (standard_error)  ? buf_standard_error.addr()  : 0,
+      (setup_slot) ? &child_setup_callback : nullptr,
+      (setup_slot) ? &child_setup_         : nullptr,
+      (standard_output) ? buf_standard_output.addr() : nullptr,
+      (standard_error)  ? buf_standard_error.addr()  : nullptr,
       exit_status,
       &gerror);
 
@@ -218,13 +218,13 @@ void spawn_sync(const std::string& working_directory,
   GError* gerror = nullptr;
 
   g_spawn_sync(
-      (working_directory.empty()) ? 0 : working_directory.c_str(),
-      const_cast<char**>(argv.data()), 0,
+      (working_directory.empty()) ? nullptr : working_directory.c_str(),
+      const_cast<char**>(argv.data()), nullptr,
       static_cast<GSpawnFlags>(unsigned(flags)),
-      (setup_slot) ? &child_setup_callback : 0,
-      (setup_slot) ? &child_setup_         : 0,
-      (standard_output) ? buf_standard_output.addr() : 0,
-      (standard_error)  ? buf_standard_error.addr()  : 0,
+      (setup_slot) ? &child_setup_callback : nullptr,
+      (setup_slot) ? &child_setup_         : nullptr,
+      (standard_output) ? buf_standard_output.addr() : nullptr,
+      (standard_error)  ? buf_standard_error.addr()  : nullptr,
       exit_status,
       &gerror);
 
@@ -255,8 +255,8 @@ void spawn_command_line_sync(const std::string& command_line,
 
   g_spawn_command_line_sync(
       command_line.c_str(),
-      (standard_output) ? buf_standard_output.addr() : 0,
-      (standard_error)  ? buf_standard_error.addr()  : 0,
+      (standard_output) ? buf_standard_output.addr() : nullptr,
+      (standard_error)  ? buf_standard_error.addr()  : nullptr,
       exit_status,
       &gerror);
 
diff --git a/glib/src/threads.ccg b/glib/src/threads.ccg
index e507b6d..cc3ba46 100644
--- a/glib/src/threads.ccg
+++ b/glib/src/threads.ccg
@@ -58,7 +58,7 @@ static void* call_thread_entry_slot(void* data)
   }
 
   delete slot;
-  return 0;
+  return nullptr;
 }
 
 } //extern "C"
diff --git a/glib/src/variant.ccg b/glib/src/variant.ccg
index 7ab9cb1..a99c17c 100644
--- a/glib/src/variant.ccg
+++ b/glib/src/variant.ccg
@@ -254,7 +254,7 @@ VariantIter VariantContainerBase::get_iter(const VariantType& container_variant_
 
 VariantBase::operator const void*() const
 {
-  return gobj() ? GINT_TO_POINTER(1) : 0;
+  return gobj() ? GINT_TO_POINTER(1) : nullptr;
 }
 
 void VariantBase::init(const GVariant* cobject, bool take_a_reference)
@@ -325,7 +325,7 @@ Variant<Glib::ustring>::create(const Glib::ustring& data)
 
 Glib::ustring Variant<Glib::ustring>::get() const
 {
-  return convert_const_gchar_ptr_to_ustring(g_variant_get_string(gobject_, 0));
+  return convert_const_gchar_ptr_to_ustring(g_variant_get_string(gobject_, nullptr));
 }
 
 // Variant<Glib::ustring> makes sense for multiple types.
@@ -413,7 +413,7 @@ std::string Variant<std::string>::get() const
   if(vtype.equal(VARIANT_TYPE_BYTESTRING))
     pch = g_variant_get_bytestring(gobject_);
   else //g_variant_get_string() can handle strings, object paths, and signatures.
-    pch = g_variant_get_string(gobject_, 0);
+    pch = g_variant_get_string(gobject_, nullptr);
 
   return convert_const_gchar_ptr_to_stdstring(pch);
 }
@@ -536,7 +536,7 @@ Variant<type_vec_string>::create(const type_vec_string& data)
   }
 
   // Terminate the string array.
-  str_array[data.size()] = NULL;
+  str_array[data.size()] = nullptr;
 
   // Create the variant using g_variant_new_bytestring_array() (passing the
   // newly constructed array.
@@ -561,7 +561,7 @@ Variant<type_vec_string>::create_from_object_paths(const type_vec_string& data)
   }
 
   // Terminate the string array.
-  str_array[data.size()] = NULL;
+  str_array[data.size()] = nullptr;
 
   // Create the variant using g_variant_new_objv() (passing the
   // newly constructed array.


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]