On 12/26/2013 10:32 PM, Aurimas Cernius wrote:
> <...>
> 
> I don't quite understand what you're trying to achieve. Your point
> is to make Glib::KeyFile "easier to use", but I don't really see,
> how your proposal achieves that. Returning a wrapper object and
> writing if to check it's value does not seem to be "easier" than
> wrapping a call in try-catch:
> 
> <...>

Okay. I think the following code that uses the current API illustrates
my use case well:

if (f.has_key("a", "b") { // false is not unlikely
    bool parsed = false;
    int val;
    try {
        val = f.get_integer("a", "b");
        parsed = true;
    } catch (...) {
         // unlikely
    }
    if (parsed) {
        fun(val);
        // fun() must called only if val is parsed
        // This is not necessarily a function
    }
} else { /* no code, not unlikely */ }

Two observations:
* The keys are optional, thus exceptions can't be used to handle the
case when a key is not present
* fun() must not be called if the value has not been parsed correctly

Regards,
Povilas


_______________________________________________
gtkmm-list mailing list
gtkmm-list@gnome.org
https://mail.gnome.org/mailman/listinfo/gtkmm-list

Reply via email to