Titan



setencode


The self.setencode operation sets the default encoding method for encoding and decoding operations on values of a specified type.

Related keywords:


self.setencode (type, encoding);


Example:

type record MyRecord {
   integer num,
   charstring str
}
with {
   encode "XML";
   encode "JSON";
}

var MyRecord r := { num := 3, str := "abc" };

self.setencode(MyRecord, "XML");

var bitstring bs1 := encvalue(r); // uses the "XML" encoding method set by the 'setencode' operation

var bitstring bs2 := encvalue(r, "", "JSON"); // ignores the 'setencode' operation and uses the "JSON" encoding method set by the dynamic encoding argument



BNF definition of setencode