string Field
Last updated
Was this helpful?
Last updated
Was this helpful?
This field stores and abstracts away value of a text string. The <string> field has all the properties as well as extra properties and elements described below.
Such definition of the <string> does NOT have any limit on the length of the string, and will consume all the available data in the input buffer.
The default value of the <string> field when constructed can be specified using defaultValue . If not specified, defaults to empty string.
In case the string value needs to be serialized using predefined fixed length, use length property to specify the required value.
The code generator is expected to take the existence of such detached prefix into account and generate correct code for various field operations (read, write, etc...).
NOTE, that length, lengthPrefix and zeroTermSuffix properties are mutually exclusive, i.e. cannot be used together.
Many protocols prefix string with its length. The CommsDSL allows definition of such prefix using lengthPrefix child element, which must define prefix as field.
In case the prefix field is defined as external field, CommsDSL allows usage of lengthPrefix as , value of which contains name of the referenced field.
The CommsDSL also supports detached length prefix, when there are several other fields in the or in the between the length field and the <string>.
NOTE, the existence of $ prefix when specifying lengthPrefix value. It indicates that the referenced field is a sibling in the containing or the field.
Some protocols may terminate strings with 0 (zero) byte. The CommsDSL support such cases with existence of zeroTermSuffix with value.
Use for future references.