Type Marshalling
The Insight schema will usually contain entities of basic types (boolean, integer, real and string), and sets and arrays of these. The type marshalling features allow values of external types (types added to Mosel by modules such as mmsystem) to be stored as strings in the Insight schema. Type marshalling can be enabled globally for a type, e.g.:
!@insight.marshal.type datetime string ! All values of type datetime will be represented by string in the Insight schema !@insight.manage=input public declarations today: datetime ! will be treated as 'string' in Insight schema alldatesin2000: set of constant datetime ! will be treated as 'set of string' in Insight schema birthdays: array(set of string) of datetime ! will be treated as 'array of string' in Insight schema now: time ! will not be in Insight schema; no annotation for type 'time' end-declarations
Or for individual entities, e.g.:
!@insight.manage=input public declarations !@insight.marshal.value string today: datetime ! will be treated as 'string' in Insight schema !@insight.marshal.value string alldatesin2000: set of constant datetime ! will be treated as 'set of string' in Insight schema !@insight.marshal.value string birthdays: array(set of string) of datetime ! will be treated as 'array of string' in Insight schema yesterday: datetime ! will not be in Insight schema; no marshalling annotation for this entity end-declarations
When applying the type marshalling to a set or array, the conversion will be applied to the values within the collection, not the collection itself (e.g. 'set of datetime' becomes 'set of string', not a scalar 'string' concatenating everything within the set.
The type marshalling annotations can be applied to any module type that supports conversion to and from string. In the standard Xpress installation, these are the types to which the annotation can be applied:
There are a few restrictions on using either type marshalling annotation:
- Marshalling can only be applied to module types as described above - not records, lists or nested types such as 'set of set of string'.
- When used with a set, the set must be declared set of constant to ensure it cannot contain duplicate values.
- For date/time/datetime types, the default string format will always be used, ignoring the datefmt, timefmt and datetimefmt parameters.
- Trying to marshal a native type that does not support conversion both to and from string will result in an error when running the scenario, not when loading the app into Insight.