#!/usr/bin/env python

"""
A buffer class for fast I/O.
"""

from _hotbuf import _hotbuf, BoundaryError
from struct import Struct

_long = Struct('l')

class hotbuf(_hotbuf):

    def pack( self, structobj, *values ):
        """
        Pack using the given Struct object 'structobj', the remaining arguments.
        """
        size = structobj.size
        if size > len(self):
            raise BoundaryError("attempted to write beyond buffer limit")
        structobj.pack_to(self, 0, *values)
        self.position += size

