Hi!
In the process of going through our interfaces, one thing I am
thinking we should do is ditch the multiple val_*() in favor of a
single method, probably get(), which instead of returning a value will
just pass in a reference that we will populate. Main reason for this?
I believe this would make the current interface a little more bullet
proof then what we have now. If I had my druthers I would love to find
a consistent manner to determine if the conversion was illegal as
well. We inherit this bad behavior, I would love to start fixing it.
There are three things I typically care about:
isNull()
isConversionError()
Off the top of my head we could do either:
bool get(int32_t& value, bool& is_null);
bool get(int32_t& value, bool& illegal_conversion);
In the above the first method would return state would determine if an
illegal conversion occurred or not. In the second we would handle NULL
case via return, and for conversion we would pass reference. The only
advantage I can see with having one over the other, is that the second
method we could adopt and slowly fix/add errors for illegal conversion
(something I would love for us to do, I dislike this particular
"gotcha").
...and yes, this is not a rewrite of the entire interface for row,
which should happen, but I believe this will solve a few programatic
mistakes I find from time to time, and will also let me introduce a
vector<char> (and maybe std::string?) while I am at it. We are using
std::string in enough places right now that this will solve some
conversion issues as well.
For that matter, a good task to do at some point it to write up all of
the interfaces that we should be add vector and string interfaces too.
I believe I handled protocol{} a while ago, but I know there are
another half dozen that should be done as well.
On a general note, I mentioned to Monty Taylor that we should be
making sure any new code is using references and const as much as
possible. I am cleaning up some of the engine interface around this
right now and doing this. In general we should be doing this where
ever we can. From watching bug reports, these two simple things would
save us a lot of headaches.
Cheers,
-Brian
_______________________________________________
Mailing list: https://launchpad.net/~drizzle-discuss
Post to : [email protected]
Unsubscribe : https://launchpad.net/~drizzle-discuss
More help : https://help.launchpad.net/ListHelp