| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
<html> |
| 16 |
<head> |
| 17 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 18 |
<meta http-equiv="Content-Language" content="en-us"> |
| 19 |
<title>variant</title> |
| 20 |
</head> |
| 21 |
<body bgcolor="#DAD3C5" vlink="#0094D2" link="#003258"> |
| 22 |
<table align="left" border="0" cellspacing="0" cellpadding="0" valign=top> |
| 23 |
<tr> |
| 24 |
<td width=105 height=40><a href="https://projects.eclipse.org/projects/tools.titan"><img src="../images/titan_transparent.gif" border=0 width=105 height=40 align="left" alt="Titan"></a></td> |
| 25 |
</tr> |
| 26 |
</table> |
| 27 |
<table border="0" align="right" cellpadding="0" cellspacing="0"> |
| 28 |
<tr> |
| 29 |
<td><a href="../titan_main.html" alt="contents"><img border="0" src="../images/ao.jpg" width="53" height="40"></a></td> |
| 30 |
<td><a href="../titan_index.html" alt="index"><img border="0" src="../images/up.jpg" width="53" height="40"></a></td> |
| 31 |
<td><a href="var.html" alt="previous"><img border="0" src="../images/left.jpg" width="53" height="40"></a></td> |
| 32 |
<td><a href="verdicttype.html" alt="next"><img border="0" src="../images/right.jpg" width="53" height="40"></a></td> |
| 33 |
</tr> |
| 34 |
</table> |
| 35 |
<p><br clear="all"> |
| 36 |
</p> |
| 37 |
<hr> |
| 38 |
<h1>variant</h1> |
| 39 |
<hr align="left" width="75%"> |
| 40 |
<p>The attribute is used to refine the currently specified encoding scheme instead of its replacement. |
| 41 |
<p>Currently, two encoding schemes are supported in TITAN: RAW and TEXT. |
| 42 |
<p>The RAW coder encodes and decodes TTCN-3 values to/from bitstreams. The TEXT coder can be utilized for text-based protocols. |
| 43 |
<p>There are presently twenty-two arguments for the RAW coder specified as follows |
| 44 |
<ul> |
| 45 |
<li>FIELDLENGTH specifies the length of the encoded type;</li> |
| 46 |
<li>COMP specifies how negative integer numbers are encoded ;</li> |
| 47 |
<li>ALIGN specifies whether the actual value will be padded from left or right;</li> |
| 48 |
<li>BITORDERINFIELD specifies whether the most or the less significant bit will be sent first on the port;</li> |
| 49 |
<li>BYTEORDER specifies whether the first or the last byte will be sent first on the port;</li> |
| 50 |
<li>BITORDER specifies the sequence of the bits within an octet;</li> |
| 51 |
<li>HEXORDER specifies the sequencer of the hexadecimal digits in the encoded data;</li> |
| 52 |
<li>FIELDORDER specifies how consecutive fields of a structured type is framed into octets;</li> |
| 53 |
<li>EXTENSION_BIT manipulates the bit used in some protocols to code data spanning several octets;</li> |
| 54 |
<li>EXTENSION_BIT_GROUP limits the extension bit mechanism to a group of the fields in a record;</li> |
| 55 |
<li>PADDING is used when the encoded type shall end at a multiple of padding units;</li> |
| 56 |
<li>PREPADDING is used when the encoded type shall start at a multiple of padding units;</li> |
| 57 |
<li>PADDING_PATTERN specifies padding pattern used by padding mechanism;</li> |
| 58 |
<li>PADDALL means that the padding parameter specified for a whole record or set will be valid for every field of the record/set;</li> |
| 59 |
<li>LENGTHTO specifies which fields are considered when calculating the length parameter;</li> |
| 60 |
<li>LENGTHINDEX extends the LENGTHTO attribute;</li> |
| 61 |
<li>UNIT attribute is used in conjunction with the LENGTHTO or POINTERTO attribute;</li> |
| 62 |
<li>POINTERTO specifies to which field a pointer points;</li> |
| 63 |
<li>PTROFFSET specifies where the pointed field area starts and the base field of pointer calculating;</li> |
| 64 |
<li>TAG identifies specific values in certain fields of the set, record elements or union choices;</li> |
| 65 |
<li>CROSSTAG is used when one field of a record specifies the union member of an other field of a record;</li> |
| 66 |
<li>PRESENCE indicates the presence of an other optional field within records.</li> |
| 67 |
</ul> |
| 68 |
<p>The above arguments are described in detail in the Appendix B of the TITAN user documentation.</p> |
| 69 |
<p>Related keywords:</p> |
| 70 |
<ul> |
| 71 |
<li><a href="encode.html"><b><font face="Courier New" color="#003258" size="4">encode</font></b></a></li> |
| 72 |
<li><a href="with.html"><b><font face="Courier New" color="#003258" size="4">with</font></b></a></li> |
| 73 |
<li><a href="override.html"><b><font face="Courier New" color="#003258" size="4">override</font></b></a></li> |
| 74 |
</ul> |
| 75 |
<hr align="left" width="50%"> |
| 76 |
<div align="center"> |
| 77 |
<center> |
| 78 |
<table border="0" width="90%" bgcolor="#FFB599" cellpadding="4"> |
| 79 |
<tr> |
| 80 |
<td width="100%"> |
| 81 |
<h3 align="center"><font face="Courier New" color="#003258" size="5"><b>variant</b></font> [ <font face="Courier New" color="#003258" size="5"><b>override</b></font> ] [ <font |
| 82 |
face="Courier New" color="#003258" size="5"><b>(</b></font><i>qualifier</i><font face="Courier New" color="#003258" size="5"><b>)</b></font> ] <font face="Courier New" color="#003258" size="5"><b>"</b></font><i>argument</i><b><font |
| 83 |
face="Courier New" color="#003258" size="5">"</font></b></h3> |
| 84 |
</td> |
| 85 |
</tr> |
| 86 |
</table> |
| 87 |
</center> |
| 88 |
</div> |
| 89 |
<ul> |
| 90 |
<li> |
| 91 |
<p>the optional <b><font face="Courier New">override</font></b> directive forces all contained types at all lower scopes to be forced to the specified attribute.</p> |
| 92 |
</li> |
| 93 |
<li> |
| 94 |
<p>the optional <i>qualifier</i> points out the entity for which the argument is valid.</p> |
| 95 |
</li> |
| 96 |
<li> |
| 97 |
<p><i>argument</i> is a free-text string specifying the actual attribute.</p> |
| 98 |
</li> |
| 99 |
<li>When using the variant attribute, it is very important to specify the desired codec in the with attributes of the module definition using the <code>encode</code> directive. |
| 100 |
</ul> |
| 101 |
<hr align="left" width="50%"> |
| 102 |
<p>Example: |
| 103 |
<p><code> module m {<br> |
| 104 |
type integer INT2 with { variant "COMP(2scompl)", "FIELDLENGTH(8)" } </font><br> |
| 105 |
} with { encode "RAW" } </code> |
| 106 |
<p>The encoding of the integer value -1 results in the bit string 11111111.</p> |
| 107 |
<hr align="left" width="25%"> |
| 108 |
<hr align="left" width="25%"> |
| 109 |
<p><a HREF="BNF.html#attribkeyword">BNF definition</a> of <font face="Courier New"> variant</font></p> |
| 110 |
</body> |
| 111 |
</html> |