def add_with_segmentation(string)
      # As the encoded DICOM string will be cut in multiple, smaller pieces, we need to monitor the length of our encoded strings:
      if (string.length + @stream.length) > @max_size
        split_and_add(string)
      elsif (30 + @stream.length) > @max_size
        # End the current segment, and start on a new segment for this string.
        @segments << @stream.export
        @stream.add_last(string)
      else
        # We are nowhere near the limit, simply add the string:
        @stream.add_last(string)
      end
    end
def add_with_segmentation(string)
      # As the encoded DICOM string will be cut in multiple, smaller pieces, we need to monitor the length of our encoded strings:
      if (string.length + @stream.length) > @max_size
        split_and_add(string)
      elsif (30 + @stream.length) > @max_size
        # End the current segment, and start on a new segment for this string.
        @segments << @stream.export
        @stream.add_last(string)
      else
        # We are nowhere near the limit, simply add the string:
        @stream.add_last(string)
      end
    end
Adds an encoded string to the output stream, while keeping track of the
 accumulated size of the output stream, splitting it up as necessary, and
 transferring the encoded string fragments to an array.

 @param [String] string a pre-encoded string