| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
<html> |
| 12 |
<head> |
| 13 |
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"> |
| 14 |
<meta http-equiv="Content-Language" content="en-us"> |
| 15 |
<title>setencode</title> |
| 16 |
</head> |
| 17 |
<body bgcolor="#DAD3C5" vlink="#0094D2" link="#003258"> |
| 18 |
<table align="left" border="0" cellspacing="0" cellpadding="0" valign=top> |
| 19 |
<tr> |
| 20 |
<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> |
| 21 |
</tr> |
| 22 |
</table> |
| 23 |
<table border="0" align="right" cellpadding="0" cellspacing="0"> |
| 24 |
<tr> |
| 25 |
<td><a href="../titan_main.html" alt="contents"><img border="0" src="../images/ao.jpg" width="53" height="40"></a></td> |
| 26 |
<td><a href="../titan_index.html" alt="index"><img border="0" src="../images/up.jpg" width="53" height="40"></a></td> |
| 27 |
<td><a href="set.html" alt="previous"><img border="0" src="../images/left.jpg" width="53" height="40"></a></td> |
| 28 |
<td><a href="setstate.html" alt="next"><img border="0" src="../images/right.jpg" width="53" height="40"></a></td> |
| 29 |
</tr> |
| 30 |
</table> |
| 31 |
<p><br clear="all"> |
| 32 |
</p> |
| 33 |
<hr> |
| 34 |
<h1>setencode</h1> |
| 35 |
<hr align="left" width="75%"> |
| 36 |
<p>The <i>self.setencode</i> operation sets the default encoding method for encoding and decoding operations on values of a specified type. |
| 37 |
<ul> |
| 38 |
<li>The <i>type</i> (first) argument indicates which type's default encoding method is set by the operation. This type must have |
| 39 |
at least two encoding methods set with its attributes.</li> |
| 40 |
<li>The <i>encoding</i> (second) argument indicates which encoding method is to be set as default. This must match one of the encoding methods set for the type.</li> |
| 41 |
<li>This operation affects all <i>encvalue, decvalue, encvalue_unichar and decvalue_unichar</i> operations with no dynamic encoding argument, all |
| 42 |
<i>decmatch</i> templates, and all value and parameter redirects with the <i>@decoded</i> modifier within the scope of the current component (<i>self</i>).</li> |
| 43 |
</ul> |
| 44 |
<p>Related keywords:</p> |
| 45 |
<ul> |
| 46 |
<li><a href="encvalue.html"><b><font face="Courier New" color="#003258" size="4">encvalue</font></b></a></li> |
| 47 |
<li><a href="encvalue_unichar.html"><b><font face="Courier New" color="#003258" size="4">encvalue_unichar</font></b></a></li> |
| 48 |
<li><a href="decvalue.html"><b><font face="Courier New" color="#003258" size="4">decvalue</font></b></a></li> |
| 49 |
<li><a href="decvalue_unichar.html"><b><font face="Courier New" color="#003258" size="4">decvalue_unichar</font></b></a></li> |
| 50 |
</ul> |
| 51 |
<hr align="left" width="50%"> |
| 52 |
<div align="center"> |
| 53 |
<center> |
| 54 |
<table border="0" width="90%" bgcolor="#FFB599" cellpadding="4"> |
| 55 |
<tr> |
| 56 |
<td width="100%"> |
| 57 |
<h3 align="center"><font face="Courier New" color="#003258" size="5"><b>self.setencode (</b></font><i>type, |
| 58 |
encoding</i><font face="Courier New" color="#003258" size="5"><b>);</b></font></h3> |
| 59 |
</td> |
| 60 |
</tr> |
| 61 |
</table> |
| 62 |
</center> |
| 63 |
</div> |
| 64 |
<hr align="left" width="50%"> |
| 65 |
<p>Example: |
| 66 |
<p><font face="Courier New">type record MyRecord {<br> |
| 67 |
integer num,<br> |
| 68 |
charstring str<br> |
| 69 |
}<br> |
| 70 |
with {<br> |
| 71 |
encode "XML";<br> |
| 72 |
encode "JSON";<br> |
| 73 |
}</font> |
| 74 |
<p><font face="Courier New">var MyRecord r := { num := 3, str := "abc" };</font> |
| 75 |
<p><font face="Courier New">self.setencode(MyRecord, "XML");</font> |
| 76 |
<p><font face="Courier New">var bitstring bs1 := encvalue(r); // uses the "XML" encoding method set by the 'setencode' operation</font> |
| 77 |
<p><font face="Courier New">var bitstring bs2 := encvalue(r, "", "JSON"); // ignores the 'setencode' operation and uses the "JSON" encoding method |
| 78 |
set by the dynamic encoding argument</font> |
| 79 |
<hr align="left" width="25%"> |
| 80 |
<hr align="left" width="25%"> |
| 81 |
<p><a HREF="BNF.html#setencode">BNF definition</a> of <font face="Courier New"> setencode</font></p> |
| 82 |
</body> |
| 83 |
</html> |