summaryrefslogtreecommitdiff
path: root/glib/src/optiongroup.ccg
diff options
context:
space:
mode:
authorKjell Ahlstedt <kjell.ahlstedt@bredband.net>2011-02-06 16:54:52 +0100
committerMurray Cumming <murrayc@murrayc.com>2011-02-08 10:53:22 +0100
commit6ea6ca5074d44ed4e832cacb56b794c88de428be (patch)
tree5961377d98eaa8e73e7e30127536223ead36ce04 /glib/src/optiongroup.ccg
parentf4d6bc29fcf364ddfb5cd714ccf41637f1e2c676 (diff)
downloadglibmm-6ea6ca5074d44ed4e832cacb56b794c88de428be.tar.gz
OptionGroup: An on_post_parse() override need not call the base class.
* glib/src/optiongroup.[hg|ccg]: The C post_parse callback is a static protected member function, which performs all necessary post-parsing. OptionGroup::on_post_parse is a dummy function. * examples/options/main.cc: The on_pre_parse, on_post_parse, and on_error overrides don't call the base class functions. Bug 588988.
Diffstat (limited to 'glib/src/optiongroup.ccg')
-rw-r--r--glib/src/optiongroup.ccg53
1 files changed, 25 insertions, 28 deletions
diff --git a/glib/src/optiongroup.ccg b/glib/src/optiongroup.ccg
index 04f5aedb..ed5e45a6 100644
--- a/glib/src/optiongroup.ccg
+++ b/glib/src/optiongroup.ccg
@@ -46,20 +46,6 @@ static gboolean g_callback_pre_parse(GOptionContext* context, GOptionGroup* /* g
return false;
}
-static gboolean g_callback_post_parse(GOptionContext* context, GOptionGroup* /* group */, gpointer data, GError** /* TODO error */)
-{
- OptionContext cppContext(context, false /* take_ownership */);
- //OptionGroup cppGroup(group, true /* take_copy */); //Maybe this should be option_group.
-
- OptionGroup* option_group = static_cast<OptionGroup*>(data);
- if(option_group)
- {
- return option_group->on_post_parse(cppContext, *option_group);
- }
- else
- return false;
-}
-
static void g_callback_error(GOptionContext* context, GOptionGroup* /* group */, gpointer data, GError** /* TODO error*/)
{
OptionContext cppContext(context, false /* take_ownership */);
@@ -98,13 +84,37 @@ static void OptionGroup_Translate_glibmm_callback_destroy(void* data)
} //anonymous namespace
+//static
+gboolean OptionGroup::post_parse_callback(GOptionContext* context,
+ GOptionGroup* /* group */, gpointer data, GError** /* TODO error */)
+{
+ OptionContext cppContext(context, false /* take_ownership */);
+ //OptionGroup cppGroup(group, true /* take_copy */); //Maybe this should be option_group.
+
+ OptionGroup* option_group = static_cast<OptionGroup*>(data);
+ if(option_group)
+ {
+ //The C args have now been given values by g_option_context_parse().
+ //Convert C values to C++ values:
+
+ for(type_map_entries::iterator iter = option_group->map_entries_.begin();
+ iter != option_group->map_entries_.end(); ++iter)
+ {
+ CppOptionEntry& cpp_entry = iter->second;
+ cpp_entry.convert_c_to_cpp();
+ }
+ return option_group->on_post_parse(cppContext, *option_group);
+ }
+ else
+ 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, 0 /* destroy_func */) ),
has_ownership_(true)
{
//Connect callbacks, so that derived classes can override the virtual methods:
- g_option_group_set_parse_hooks(gobj(), &g_callback_pre_parse, &g_callback_post_parse);
+ g_option_group_set_parse_hooks(gobj(), &g_callback_pre_parse, &post_parse_callback);
g_option_group_set_error_hook(gobj(), &g_callback_error);
}
@@ -218,19 +228,6 @@ bool OptionGroup::on_pre_parse(OptionContext& /* context */, OptionGroup& /* gro
bool OptionGroup::on_post_parse(OptionContext& /* context */, OptionGroup& /* group */)
{
- //Call this at the start of overrides.
-
- //TODO: Maybe put this in the C callback:
-
- //The C args have now been given values by GOption.
- //Convert C values to C++ values:
-
- for(type_map_entries::iterator iter = map_entries_.begin(); iter != map_entries_.end(); ++iter)
- {
- CppOptionEntry& cpp_entry = iter->second;
- cpp_entry.convert_c_to_cpp();
- }
-
return true;
}