[bind10-dev] data classes
JINMEI Tatuya / 神明達哉
jinmei at isc.org
Fri Oct 23 18:45:58 UTC 2009
At Thu, 22 Oct 2009 18:25:10 +0200,
Jelte Jansen <jelte at isc.org> wrote:
> To get values back there are currently two versions; a set like
> int ElementPtr->int_value(), std::string ElementPtr->string_value() etc. But
> these are of course only relevant to one specific subtype, and for all the
> others i can't really think of a general way to return a decent value if the
> type is something else. So this would be a place to throw an exception (as in
> principle you should be able to know or at least ask what type you would be
> getting).
I have one quick question: what's wrong with throwing an exception in
this case (except the hot fundamental point of whether to use
exceptions in general)? As you indicated, if someone calls
int_value() for a non-integer element, it's clearly a bug, so throwing
an exception seems to be reasonable to me.
Or is your main concern with this approach that you need to list all
type-specific getter methods in the base class?
---
JINMEI, Tatuya
Internet Systems Consortium, Inc.
More information about the bind10-dev
mailing list