The encoded segments finally will appear on a stream as well as the decoding will process data, that arrives on a stream. The stream may be bound to a RS232 line, a TCP/IP line, a batch file, a pipe or whatever medium is required.
There is an option to choose, whether the output methods are to produce HL7 encoding rule compliant data or human readable data, that is used in order to debug the protocol. This human readable data will be output in a LISP like style, since LISP provides a simple notation for complex objects. The style can however be modified on compile time.
The mechanisms that C++ provides with the `iostream' library are very powerful and elegant. However we have to extend the iostream object by some variables, which allow us to set several states for the streams. There are currently the following states that a stream can assume:
`hl7er' and `debug' are boolean values which are of course mutually exclusive. They are however not represented in a single bit because there may be more coding modes to be integrated into the system.
The `level' is normally set to 0, but there are cases, when the level of the stream must be increased. Consider a composite data type CX, which does refer in one of its components to an other composite data type CY: The components of CY thus become the subcomponents of CX. However, the i/o methods of CY need to know if CY is regarded as a composite field or as a composite component. If the latter is true, the level is increased by one and CY uses the subcomponent delimiter to terminate its components. However, it becomes clear that CY may not have in turn a composite component, since there is no sub-sub-component delimiter. In fact in v2.1 the subcomponent feature is never used. Rather such composites are flattened terminating each component by a `^' (for an example see the definition of the CN data type in chapter 2).