Replace repetitive code in SettingsObjectWrapper.cpp by functions?
Berthold Stoeger
bstoeger at mail.tuwien.ac.at
Sat Nov 18 09:48:30 PST 2017
Hi Dirk,
On Samstag, 18. November 2017 16:53:43 CET Dirk Hohndel wrote:
> > On Nov 18, 2017, at 12:02 AM, Berthold Stoeger
> > <bstoeger at mail.tuwien.ac.at> wrote:
> > Side note: Unfortunately, in some cases representations in pref and
> > SettingsObjectWrapper differ. :(
>
> Yes - and in most cases I think there are good reasons for that. char * vs
> QString for example
Oh, I didn't count those as different. For me these are different
representations of the same thing (a string).
I was talking about gems like setBuehlmann(), where one side saves a bool and
the other one an enum. Or setUnitSystem() where a string on one side is an
enum on the other, etc. :(
> > Note that this is really only a quick proof of concept and I probably
> > introduced numerous bugs. But if you think this is a good idea, I can try
> > to go over each case and check it for plausibility.
>
> The scary part (for me) is that you are using C++ constructs outside of my
> comfort zone. I have always pushed back when Tomaz went into what I
> consider C++-lala-land.
> I think I mostly understand what the template does and how the namespace
> is used, but I realize that I'd be uncomfortable editing this code without
> some serious Googling and that makes me nervous.
Note that the template stuff was simply born out of laziness. But it turned
out to be convenient because enums in C++ are not auto-converted into integers
(don't know the situation in C). The first template takes care of these cases.
The two other templates can be replaced by specialized functions. Also note
that I myself am not versed at all with templates.
The anonymous namespace thing is C++'s way of hiding something from other
translation units. Because static has a different meaning for member-
functions, it's a necessity for these. But template functions can be made
static, so I'll simply remove it.
But as I said, it's just a proof of concept. Maybe someone has a better idea?
Berthold
More information about the subsurface
mailing list