[glibmm] More use of nullptr instead of 0.
- From: Murray Cumming <murrayc src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [glibmm] More use of nullptr instead of 0.
- Date: Fri, 20 Nov 2015 09:37:56 +0000 (UTC)
commit 47d8024cdb18f29eb7def2bb843f0a1a07cef9dd
Author: Murray Cumming <murrayc murrayc com>
Date: Thu Nov 19 15:34:10 2015 +0100
More use of nullptr instead of 0.
gio/src/datainputstream.ccg | 6 ++--
glib/glibmm/class.cc | 10 ++++----
glib/glibmm/property.cc | 2 +-
glib/glibmm/value_custom.cc | 36 ++++++++++++++++----------------
glib/glibmm/wrap.cc | 16 +++++++-------
glib/src/iochannel.ccg | 8 +++---
glib/src/keyfile.ccg | 48 +++++++++++++++++++++---------------------
glib/src/optionentry.ccg | 4 +-
8 files changed, 65 insertions(+), 65 deletions(-)
---
diff --git a/gio/src/datainputstream.ccg b/gio/src/datainputstream.ccg
index ffc4d97..2209e48 100644
--- a/gio/src/datainputstream.ccg
+++ b/gio/src/datainputstream.ccg
@@ -47,7 +47,7 @@ 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
- 0,
+ nullptr,
&gerror);
if(gerror)
::Glib::Error::throw_exception(gerror);
@@ -120,7 +120,7 @@ bool DataInputStream::read_until(std::string& data, const std::string& stop_char
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
- 0,
+ nullptr,
&gerror);
if(gerror)
::Glib::Error::throw_exception(gerror);
@@ -194,7 +194,7 @@ bool DataInputStream::read_upto(std::string& data, const std::string& stop_chars
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
- 0,
+ nullptr,
&gerror);
if(gerror)
diff --git a/glib/glibmm/class.cc b/glib/glibmm/class.cc
index 217d02e..1f23a5f 100644
--- a/glib/glibmm/class.cc
+++ b/glib/glibmm/class.cc
@@ -58,14 +58,14 @@ void Class::register_derived_type(GType base_type, GTypeModule* module)
const GTypeInfo derived_info =
{
class_size,
- 0, // base_init
- 0, // base_finalize
+ nullptr, // base_init
+ nullptr, // base_finalize
class_init_func_, //Set by the caller ( *_Class::init() ).
- 0, // class_finalize
- 0, // class_data
+ nullptr, // class_finalize
+ nullptr, // class_data
instance_size,
0, // n_preallocs
- 0, // instance_init
+ nullptr, // instance_init
0, // value_table
};
diff --git a/glib/glibmm/property.cc b/glib/glibmm/property.cc
index c3ff33d..154bffb 100644
--- a/glib/glibmm/property.cc
+++ b/glib/glibmm/property.cc
@@ -226,7 +226,7 @@ PropertyBase::PropertyBase(Glib::Object& object, GType value_type)
:
object_ (&object),
value_ (),
- param_spec_ (0)
+ param_spec_ (nullptr)
{
value_.init(value_type);
}
diff --git a/glib/glibmm/value_custom.cc b/glib/glibmm/value_custom.cc
index 4636cb8..1c680f4 100644
--- a/glib/glibmm/value_custom.cc
+++ b/glib/glibmm/value_custom.cc
@@ -71,24 +71,24 @@ GType custom_boxed_type_register(const char* type_name,
init_func,
free_func,
copy_func,
- 0, // value_peek_pointer
- 0, // collect_format
- 0, // collect_value
- 0, // lcopy_format
- 0, // lcopy_value
+ nullptr, // value_peek_pointer
+ nullptr, // collect_format
+ nullptr, // collect_value
+ nullptr, // lcopy_format
+ nullptr, // lcopy_value
};
const GTypeInfo type_info =
{
0, // class_size
- 0, // base_init
- 0, // base_finalize
- 0, // class_init_func
- 0, // class_finalize
- 0, // class_data
+ nullptr, // base_init
+ nullptr, // base_finalize
+ nullptr, // class_init_func
+ nullptr, // class_finalize
+ nullptr, // class_data
0, // instance_size
0, // n_preallocs
- 0, // instance_init
+ nullptr, // instance_init
&value_table,
};
@@ -122,15 +122,15 @@ GType custom_pointer_type_register(const char* type_name)
const GTypeInfo type_info =
{
0, // class_size
- 0, // base_init
- 0, // base_finalize
- 0, // class_init_func
- 0, // class_finalize
- 0, // class_data
+ nullptr, // base_init
+ nullptr, // base_finalize
+ nullptr, // class_init_func
+ nullptr, // class_finalize
+ nullptr, // class_data
0, // instance_size
0, // n_preallocs
- 0, // instance_init
- 0, // value_table
+ nullptr, // instance_init
+ nullptr, // value_table
};
// We could probably use g_pointer_type_register_static(), but I want
diff --git a/glib/glibmm/wrap.cc b/glib/glibmm/wrap.cc
index 4b801a4..eebe888 100644
--- a/glib/glibmm/wrap.cc
+++ b/glib/glibmm/wrap.cc
@@ -95,13 +95,13 @@ void wrap_register(GType type, WrapNewFunction func)
static Glib::ObjectBase* wrap_create_new_wrapper(GObject* object)
{
- g_return_val_if_fail(wrap_func_table != nullptr, 0);
+ g_return_val_if_fail(wrap_func_table != nullptr, nullptr);
const bool gtkmm_wrapper_already_deleted = (bool)g_object_get_qdata((GObject*)object,
Glib::quark_cpp_wrapper_deleted_);
if(gtkmm_wrapper_already_deleted)
{
g_warning("Glib::wrap_create_new_wrapper: Attempted to create a 2nd C++ wrapper for a C instance whose
C++ wrapper has been deleted.");
- return 0;
+ return nullptr;
}
// Traverse upwards through the inheritance hierarchy
@@ -119,7 +119,7 @@ static Glib::ObjectBase* wrap_create_new_wrapper(GObject* object)
}
}
- return 0;
+ return nullptr;
}
static gboolean gtype_wraps_interface(GType implementer_type, GType interface_type)
@@ -140,13 +140,13 @@ static gboolean gtype_wraps_interface(GType implementer_type, GType interface_ty
Glib::ObjectBase* wrap_create_new_wrapper_for_interface(GObject* object, GType interface_gtype)
{
- g_return_val_if_fail(wrap_func_table != nullptr, 0);
+ g_return_val_if_fail(wrap_func_table != nullptr, nullptr);
const bool gtkmm_wrapper_already_deleted = (bool)g_object_get_qdata((GObject*)object,
Glib::quark_cpp_wrapper_deleted_);
if(gtkmm_wrapper_already_deleted)
{
g_warning("Glib::wrap_create_new_wrapper: Attempted to create a 2nd C++ wrapper for a C instance whose
C++ wrapper has been deleted.");
- return 0;
+ return nullptr;
}
// Traverse upwards through the inheritance hierarchy
@@ -167,7 +167,7 @@ Glib::ObjectBase* wrap_create_new_wrapper_for_interface(GObject* object, GType i
}
}
- return 0;
+ return nullptr;
}
@@ -177,7 +177,7 @@ Glib::ObjectBase* wrap_create_new_wrapper_for_interface(GObject* object, GType i
ObjectBase* wrap_auto(GObject* object, bool take_copy)
{
if(!object)
- return 0;
+ return nullptr;
// Look up current C++ wrapper instance:
ObjectBase* pCppObject = ObjectBase::_get_current_wrapper(object);
@@ -190,7 +190,7 @@ ObjectBase* wrap_auto(GObject* object, bool take_copy)
if(!pCppObject)
{
g_warning("Failed to wrap object of type '%s'. Hint: this error is commonly caused by failing to call
a library init() function.", G_OBJECT_TYPE_NAME(object));
- return 0;
+ return nullptr;
}
}
diff --git a/glib/src/iochannel.ccg b/glib/src/iochannel.ccg
index 13319f1..d9f9a5e 100644
--- a/glib/src/iochannel.ccg
+++ b/glib/src/iochannel.ccg
@@ -235,7 +235,7 @@ IOStatus IOChannel::read_line(Glib::ustring& line)
GError* gerror = nullptr;
gsize bytes = 0;
- const auto status = g_io_channel_read_line(gobj(), buf.addr(), &bytes, 0, &gerror);
+ const auto status = g_io_channel_read_line(gobj(), buf.addr(), &bytes, nullptr, &gerror);
if(gerror)
{
@@ -297,7 +297,7 @@ IOStatus IOChannel::set_encoding(const std::string& encoding)
GError* gerror = nullptr;
const auto status = g_io_channel_set_encoding(
- gobj(), (encoding.empty()) ? 0 : encoding.c_str(), &gerror);
+ gobj(), (encoding.empty()) ? nullptr : encoding.c_str(), &gerror);
if(gerror)
{
@@ -316,7 +316,7 @@ std::string IOChannel::get_encoding() const
void IOChannel::set_line_term(const std::string& term)
{
if(term.empty())
- g_io_channel_set_line_term(gobj(), 0, 0);
+ g_io_channel_set_line_term(gobj(), nullptr, 0);
else
g_io_channel_set_line_term(gobj(), term.data(), term.size());
}
@@ -506,7 +506,7 @@ GSource* GlibmmIOChannel::io_create_watch(GIOChannel* channel, GIOCondition cond
try
{
const auto source = wrapper->create_watch_vfunc((IOCondition) condition);
- return (source) ? source->gobj_copy() : 0;
+ return (source) ? source->gobj_copy() : nullptr;
}
catch(...)
{
diff --git a/glib/src/keyfile.ccg b/glib/src/keyfile.ccg
index 5e7a215..71c94a5 100644
--- a/glib/src/keyfile.ccg
+++ b/glib/src/keyfile.ccg
@@ -126,7 +126,7 @@ bool KeyFile::load_from_dirs(const std::string& file, const Glib::ArrayHandle<st
Glib::ustring KeyFile::to_data()
{
GError* gerror = nullptr;
- char *const str = g_key_file_to_data(gobj(), 0, &gerror);
+ char *const str = g_key_file_to_data(gobj(), nullptr, &gerror);
if(gerror)
Glib::Error::throw_exception(gerror);
@@ -149,7 +149,7 @@ Glib::ArrayHandle<Glib::ustring> KeyFile::get_keys(const Glib::ustring& group_na
char** const array = g_key_file_get_keys(
const_cast<GKeyFile*>(gobj()),
- (group_name.empty()) ? 0 : group_name.c_str(),
+ (group_name.empty()) ? nullptr : group_name.c_str(),
&length, &gerror);
if(gerror)
@@ -164,8 +164,8 @@ Glib::ustring KeyFile::get_locale_string(const Glib::ustring& group_name,
GError* gerror = nullptr;
char *const str = g_key_file_get_locale_string(
const_cast<GKeyFile*>(gobj()),
- (group_name.empty()) ? 0 : group_name.c_str(),
- key.c_str(), 0, &gerror);
+ (group_name.empty()) ? nullptr : group_name.c_str(),
+ key.c_str(), nullptr, &gerror);
if(gerror)
Glib::Error::throw_exception(gerror);
@@ -178,7 +178,7 @@ bool KeyFile::get_boolean(const Glib::ustring& key) const
GError* gerror = nullptr;
const bool value =
static_cast<bool>(g_key_file_get_boolean(const_cast<GKeyFile*>(gobj()),
- 0, key.c_str(), &gerror));
+ nullptr, key.c_str(), &gerror));
if(gerror)
Glib::Error::throw_exception(gerror);
@@ -189,7 +189,7 @@ int KeyFile::get_integer(const Glib::ustring& key) const
{
GError* gerror = nullptr;
const int value = g_key_file_get_integer(const_cast<GKeyFile*>(gobj()),
- 0, key.c_str(), &gerror);
+ nullptr, key.c_str(), &gerror);
if(gerror)
Glib::Error::throw_exception(gerror);
@@ -200,7 +200,7 @@ gint64 KeyFile::get_int64(const Glib::ustring& key) const
{
GError* gerror = nullptr;
- const gint64 value = g_key_file_get_int64(const_cast<GKeyFile*>(gobj()), 0,
+ const gint64 value = g_key_file_get_int64(const_cast<GKeyFile*>(gobj()), nullptr,
key.c_str(), &gerror);
if(gerror)
@@ -214,7 +214,7 @@ guint64 KeyFile::get_uint64(const Glib::ustring& key) const
GError* gerror = nullptr;
const guint64 value = g_key_file_get_uint64(const_cast<GKeyFile*>(gobj()),
- 0, key.c_str(), &gerror);
+ nullptr, key.c_str(), &gerror);
if(gerror)
Glib::Error::throw_exception(gerror);
@@ -225,7 +225,7 @@ guint64 KeyFile::get_uint64(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<GKeyFile*>(gobj()), 0, key.c_str(), &(gerror));
+ double retvalue = g_key_file_get_double(const_cast<GKeyFile*>(gobj()), nullptr, key.c_str(), &(gerror));
if(gerror)
::Glib::Error::throw_exception(gerror);
@@ -235,7 +235,7 @@ double KeyFile::get_double(const Glib::ustring& key) const
void KeyFile::set_double(const Glib::ustring& key, double value)
{
- g_key_file_set_double(gobj(), 0, key.c_str(), value);
+ g_key_file_set_double(gobj(), nullptr, key.c_str(), value);
}
# define GLIBMM_ERROR_ARG
@@ -250,7 +250,7 @@ Glib::ArrayHandle<Glib::ustring> KeyFile::get_string_list(const Glib::ustring& g
char** const array = g_key_file_get_string_list(
const_cast<GKeyFile*>(gobj()),
- (group_name.empty()) ? 0 : group_name.c_str(),
+ (group_name.empty()) ? nullptr : group_name.c_str(),
key.c_str(), &length, &gerror);
GLIBMM_THROW(gerror);
@@ -268,7 +268,7 @@ Glib::ArrayHandle<Glib::ustring> KeyFile::get_locale_string_list(const Glib::ust
char** const array = g_key_file_get_locale_string_list(
const_cast<GKeyFile*>(gobj()),
- (group_name.empty()) ? 0 : group_name.c_str(),
+ (group_name.empty()) ? nullptr : group_name.c_str(),
key.c_str(), locale.c_str(), &length, &gerror);
GLIBMM_THROW(gerror);
@@ -285,7 +285,7 @@ Glib::ArrayHandle<bool> KeyFile::get_boolean_list(const Glib::ustring& group_nam
gboolean *const array = g_key_file_get_boolean_list(
const_cast<GKeyFile*>(gobj()),
- (group_name.empty()) ? 0 : group_name.c_str(),
+ (group_name.empty()) ? nullptr : group_name.c_str(),
key.c_str(), &length, &gerror);
GLIBMM_THROW(gerror);
@@ -302,7 +302,7 @@ Glib::ArrayHandle<int> KeyFile::get_integer_list(const Glib::ustring& group_name
int *const array = g_key_file_get_integer_list(
const_cast<GKeyFile*>(gobj()),
- (group_name.empty()) ? 0 : group_name.c_str(),
+ (group_name.empty()) ? nullptr : group_name.c_str(),
key.c_str(), &length, &gerror);
GLIBMM_THROW(gerror);
@@ -328,7 +328,7 @@ Glib::ArrayHandle<double> KeyFile::get_double_list(const Glib::ustring& group_na
void KeyFile::set_string_list(const Glib::ustring& group_name, const Glib::ustring& key,
const Glib::ArrayHandle<Glib::ustring>& list)
{
- g_key_file_set_string_list(gobj(), (group_name.empty()) ? 0 : group_name.c_str(),
+ g_key_file_set_string_list(gobj(), (group_name.empty()) ? nullptr : group_name.c_str(),
key.c_str(), list.data(), list.size());
}
@@ -336,14 +336,14 @@ void KeyFile::set_locale_string_list(const Glib::ustring& group_name,
const Glib::ustring& key, const Glib::ustring& locale,
const Glib::ArrayHandle<Glib::ustring>& list)
{
- g_key_file_set_locale_string_list(gobj(), (group_name.empty()) ? 0 : group_name.c_str(),
+ g_key_file_set_locale_string_list(gobj(), (group_name.empty()) ? nullptr : group_name.c_str(),
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<int>& list)
{
- g_key_file_set_integer_list(gobj(), (group_name.empty()) ? 0 : group_name.c_str(),
+ g_key_file_set_integer_list(gobj(), (group_name.empty()) ? nullptr : group_name.c_str(),
key.c_str(), const_cast<int*>(list.data()), list.size());
}
@@ -357,14 +357,14 @@ void KeyFile::set_double_list(const Glib::ustring& group_name, const Glib::ustri
void KeyFile::set_boolean_list(const Glib::ustring& group_name, const Glib::ustring& key,
const Glib::ArrayHandle<bool>& list)
{
- g_key_file_set_boolean_list(gobj(), (group_name.empty()) ? 0 : group_name.c_str(),
+ g_key_file_set_boolean_list(gobj(), (group_name.empty()) ? nullptr : group_name.c_str(),
key.c_str(), const_cast<gboolean*>(list.data()), list.size());
}
Glib::ustring KeyFile::get_comment() const
{
GError* gerror = nullptr;
- char *const str = g_key_file_get_comment(const_cast<GKeyFile*>(gobj()), 0, 0, &gerror);
+ char *const str = g_key_file_get_comment(const_cast<GKeyFile*>(gobj()), nullptr, nullptr, &gerror);
GLIBMM_THROW(gerror);
@@ -375,8 +375,8 @@ Glib::ustring KeyFile::get_comment(const Glib::ustring& group_name GLIBMM_ERROR_
{
GError* gerror = nullptr;
char *const str = g_key_file_get_comment(const_cast<GKeyFile*>(gobj()),
- (group_name.empty()) ? 0 : group_name.c_str(),
- 0, &gerror);
+ (group_name.empty()) ? nullptr : group_name.c_str(),
+ nullptr, &gerror);
GLIBMM_THROW(gerror);
return Glib::convert_return_gchar_ptr_to_ustring(str);
@@ -385,7 +385,7 @@ Glib::ustring KeyFile::get_comment(const Glib::ustring& group_name GLIBMM_ERROR_
void KeyFile::set_comment(const Glib::ustring& comment GLIBMM_ERROR_ARG)
{
GError* gerror = nullptr;
- g_key_file_set_comment(gobj(), 0, 0, comment.c_str(), &gerror);
+ g_key_file_set_comment(gobj(), nullptr, nullptr, comment.c_str(), &gerror);
GLIBMM_THROW(gerror);
}
@@ -394,8 +394,8 @@ void KeyFile::set_comment(const Glib::ustring& group_name, const Glib::ustring&
GLIBMM_ERROR_ARG)
{
GError* gerror = nullptr;
- g_key_file_set_comment(gobj(), (group_name.empty()) ? 0 : group_name.c_str(),
- 0, comment.c_str(), &gerror);
+ g_key_file_set_comment(gobj(), (group_name.empty()) ? nullptr : group_name.c_str(),
+ nullptr, comment.c_str(), &gerror);
GLIBMM_THROW(gerror);
}
diff --git a/glib/src/optionentry.ccg b/glib/src/optionentry.ccg
index 1548aab..49810c4 100644
--- a/glib/src/optionentry.ccg
+++ b/glib/src/optionentry.ccg
@@ -116,7 +116,7 @@ void OptionEntry::set_description(const Glib::ustring& value)
gobject_->description = nullptr;
}
- gobj()->description = (value).empty() ? 0 : g_strdup((value).c_str());
+ gobj()->description = (value).empty() ? nullptr : g_strdup((value).c_str());
}
void OptionEntry::set_arg_description(const Glib::ustring& value)
@@ -127,7 +127,7 @@ void OptionEntry::set_arg_description(const Glib::ustring& value)
gobject_->arg_description = nullptr;
}
- gobj()->arg_description = (value).empty() ? 0 : g_strdup((value).c_str());
+ gobj()->arg_description = (value).empty() ? nullptr : g_strdup((value).c_str());
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]