variant
The attribute is used to refine the currently specified encoding scheme instead of its replacement.
Currently, two encoding schemes are supported in TITAN: RAW and TEXT.
The RAW coder encodes and decodes TTCN-3 values to/from bitstreams. The TEXT coder can be utilized for text-based protocols.
There are presently twenty-two arguments for the RAW coder specified as follows
- FIELDLENGTH specifies the length of the encoded type;
- COMP specifies how negative integer numbers are encoded ;
- ALIGN specifies whether the actual value will be padded from left or right;
- BITORDERINFIELD specifies whether the most or the less significant bit will be sent first on the port;
- BYTEORDER specifies whether the first or the last byte will be sent first on the port;
- BITORDER specifies the sequence of the bits within an octet;
- HEXORDER specifies the sequencer of the hexadecimal digits in the encoded data;
- FIELDORDER specifies how consecutive fields of a structured type is framed into octets;
- EXTENSION_BIT manipulates the bit used in some protocols to code data spanning several octets;
- EXTENSION_BIT_GROUP limits the extension bit mechanism to a group of the fields in a record;
- PADDING is used when the encoded type shall end at a multiple of padding units;
- PREPADDING is used when the encoded type shall start at a multiple of padding units;
- PADDING_PATTERN specifies padding pattern used by padding mechanism;
- PADDALL means that the padding parameter specified for a whole record or set will be valid for every field of the record/set;
- LENGTHTO specifies which fields are considered when calculating the length parameter;
- LENGTHINDEX extends the LENGTHTO attribute;
- UNIT attribute is used in conjunction with the LENGTHTO or POINTERTO attribute;
- POINTERTO specifies to which field a pointer points;
- PTROFFSET specifies where the pointed field area starts and the base field of pointer calculating;
- TAG identifies specific values in certain fields of the set, record elements or union choices;
- CROSSTAG is used when one field of a record specifies the union member of an other field of a record;
- PRESENCE indicates the presence of an other optional field within records.
The above arguments are described in detail in the Appendix B of the TITAN user documentation.
Related keywords:
variant [ override ] [ (qualifier) ] "argument"
|
-
the optional override directive forces all contained types at all lower scopes to be forced to the specified attribute.
-
the optional qualifier points out the entity for which the argument is valid.
-
argument is a free-text string specifying the actual attribute.
- When using the variant attribute, it is very important to specify the desired codec in the with attributes of the module definition using the
encode
directive.
Example:
module m {
type integer INT2 with { variant "COMP(2scompl)", "FIELDLENGTH(8)" }
} with { encode "RAW" }
The encoding of the integer value -1 results in the bit string 11111111.
BNF definition of variant