Archived
This forum has been archived. Please start a new discussion on GitHub.
How to define a variant type?
Hi,
Did anybody define "Variant" data type like windows's COM in ICE? I had defined a struct to present the variant.
enum ValueType {VTINT, VTSHORT, VTLONG, VTFLOAT, VTDOUBLE, VTSTRING, VTBYTE, VTBOOLEAN,
VTINTSEQ, VTSHORTSEQ, VTLONGSEQ, VTFLOATSEQ, VTDOUBLESEQ, VTSTRINGSEQ, VTBYTESEQ, VTBOOLEANSEQ};
struct Variant
{
ValueType type;
Ice::ByteSeq byValues;
};
I'm not very satisfact with the definition. Have any more suggestion?
Thanks in advance.
Did anybody define "Variant" data type like windows's COM in ICE? I had defined a struct to present the variant.
enum ValueType {VTINT, VTSHORT, VTLONG, VTFLOAT, VTDOUBLE, VTSTRING, VTBYTE, VTBOOLEAN,
VTINTSEQ, VTSHORTSEQ, VTLONGSEQ, VTFLOATSEQ, VTDOUBLESEQ, VTSTRINGSEQ, VTBYTESEQ, VTBOOLEANSEQ};
struct Variant
{
ValueType type;
Ice::ByteSeq byValues;
};
I'm not very satisfact with the definition. Have any more suggestion?
Thanks in advance.
0
Comments
-
Is "Variant" the same as a union type? If so, I recommend to use a class hierarchy, e.g.:
class VariantBase { };
class VariantInt extends VariantBase { int value; };
class VariantDouble extends VariantBase { double value; };
etc.0 -
Thanks a lot. Let me try.0