BIT STRING Type

12-1
The BIT STRING type is used to contain any data where individual bit values might have meaning. Mapping Services supports two types of BIT STRING access, Standard and Boolean. These are described below.
Standard BIT STRING Access
Standard BIT STRING access deals with the string as a whole, allowing manipulation of the entire component through a single operation, as for most other types.
External Form -- Input
Valid external form can be a string of one or more digits, each a zero (0) or a one (1). However, where named values are defined for the BIT STRING type, a list of named values, each separated by a plus sign (+) or a minus sign (-) sign, is an acceptable alternative. A named value preceded by a plus sign indicates that the named bit value should be set to true (the bit is set to 1), and a named value preceded by a minus sign indicates that the named bit value should be set to false (the bit is set to 0).
External Form -- Output
The output format depends upon whether or not named values are defined for the BIT STRING type. Where no named values are defined the output consists of a string of zero or more (always a multiple of 8) digits, each a 0 or 1. Where one or more named values do exist the output is a character string comprising each named value where the named bit is 1 (meaning the value is true). Each name is delimited with a plus sign (+).
Local Form and Behavior
When a string of 0’s and 1’s is supplied as input, each digit in the input sequence is treated (left to right) as the value of the corresponding bit in that position of the local form data. If the number of bits supplied is not a multiple of 8, trailing bits are set to zero and padded to a byte boundary. If the component has a fixed length exceeding that of the input string, the value is left aligned, and all unreferenced bytes are set to X’00’. If the component cannot contain the number of input bytes supplied, the string is truncated.
When a list of named values, each preceded by a plus sign (+) or a minus sign (-), is supplied as input, only the named bits take part in the operation. Each named bit preceded by a plus sign (+) is set to 1 (true), and each named bit preceded by a minus sign (-), is set to 0 (false). All other bits in the BIT STRING are unaffected by the input operation.
When fetching the value of a BIT STRING a named value list is always returned if any named values are defined for the type, else a string of 0s and 1s is returned corresponding to the BIT STRING values. Note that when named values are defined all other bits in the BIT STRING are ignored on output regardless of their value.
Named Values
It is possible to specify a list of names corresponding to particular bit positions, starting from zero. For example:
{ FLAG1(0), ALLSET (1), ...}
It is possible to use a list of these names, preceded by a plus or minus signs, to indicate set or not set as external form input for the bit string component. When output the names of the set bits, separated by plus signs are returned, for example:
+FLAG1+ALLSET ...
Constraints
It is possible to specify a size constraint on a bit string type using the SIZE keyword. For example:
BIT STRING (SIZE(2.4))
The size refers to the maximum number of bits (not bytes) in the bit string. Internally, the minimum is rounded down, and the maximum rounded up, to the nearest multiple of 8.
Boolean BIT STRING Access
Boolean BIT STRING access deals with individual bit level access and operates only through named values. We recommend this access because program access to bits is only via their symbolic named values, thus removing from NCL the need to know relative bit positions.
For Boolean BIT STRING access to be invoked the named value of a bit is provided by NCL as an additional name segment after the BIT STRING component name. Since the BIT STRING type is primitive, the additional name in the name hierarchy is understood to be a named value, and is treated as a BOOLEAN type. No matter where the named value is in the BIT STRING the value of the bit is always 0 or 1, as for a BOOLEAN type.
External Form -- Input
The local character strings TRUE and FALSE (not case sensitive) are accepted, the digit 0 is interpreted as false, and the digit 1 is true.
External Form -- Output
The digit 0 (false) or 1 (true) is always returned.
Local Form and Behavior
The component name plus the named value is treated as a reference to a specific bit (the bit position within the component being defined by the named value), and that bit is set to 0 or 1 depending upon the input. No other bits in the BIT STRING component are affected. If the component is extended to accommodate the input, all other bits are set to 0.
Named Values
Named values are not applicable to Boolean BIT STRING access.
Constraints
Constraints are not applicable to Boolean BIT STRING access.