def read(self, count):
        """
        read count bytes from the underlying buffer and return them as a
        str. Raises an UnpackException if there is not enough data in
        the underlying buffer.
        """

        offset = self.offset
        if self.data:
            avail = len(self.data) - offset
        else:
            avail = 0

        if avail < count:
            raise UnpackException(None, count, avail)

        self.offset = offset + count
        return self.data[offset:self.offset]
read count bytes from the underlying buffer and return them as a
        str. Raises an UnpackException if there is not enough data in
        the underlying buffer.