Set object attributes from binary string representation.
        
        :param buf: The binary string representation of this object in database.
        :type buf: str
        :raises: :class:`keepassdb.exc.ParseError` - If errors encountered parsing struct.

def decode(self, buf):
        """
        Set object attributes from binary string representation.
        
        :param buf: The binary string representation of this object in database.
        :type buf: str
        :raises: :class:`keepassdb.exc.ParseError` - If errors encountered parsing struct.
        """
        index = 0
        while True:
            #self.log.debug("buffer state: index={0}, buf-ahead={1!r}".format(index, buf[index:]))
            substr = buf[index:index + 6]
            index += 6
            if index > len(buf):
                raise ValueError("Group header offset is out of range: {0}".format(index))
            (typ, siz) = struct.unpack('<H L', substr)
            self.order.append((typ, siz))
            
            substr = buf[index:index + siz]
            index += siz
            encoded = struct.unpack('<%ds' % siz, substr)[0]
            
            (name, marshall) = self.format[typ]
            if name is None:
                break
            try:
                value = marshall.decode(encoded)
                self.log.debug("Decoded field [{0}] to value {1!r}".format(name, value))
            except struct.error, msg:
                msg = '%s, typ=%d[size=%d] -> %s [buf = "%r"]' % \
                    (msg, typ, siz, self.format[typ], encoded)
                raise exc.ParseError(msg)
            setattr(self, name, value)