An IDL union is similar to an IDL structure, except that an instance of a union can contain a value for one field only. IDL union declarations look like this:
module TMod { union TUn switch (long) { case 5: long lVal; case 9, 7: short sVal; default: double dVal; };};
The declaration has a discriminator of
the datatype specified by switch (typename)
.
Each field declaration must have a case specifier
that describes the matching discriminator value. There can be one default field
that applies when the discriminator matches no other value. At runtime,
the union’s discriminator tells which field contains the
current value. In the example above, a discriminator value of seven
indicates that the sVal field contains the current
value.
Copyright © 2005. Sybase Inc. All rights reserved. |