Unpack a binary message into this object's attributes.

        Pass the correct length for list unpacking.

        Args:
            buff (bytes): Binary data package to be unpacked.
            offset (int): Where to begin unpacking.
761126
def unpack(self, buff, offset=0):
        
        unpack_length = UBInt16()
        unpack_length.unpack(buff, offset)
        super().unpack(buff[:offset+unpack_length], offset)
291482
function unpackResourceRecord(buf, offset) {
  var bytes = 0;

  //  - variable length name
  var nbname = NBName.fromBuffer(buf, offset + bytes);
  if (nbname.error) {
    return {error: nbname.error};
  }

  bytes += nbname.bytesRead;

  var record = {};
  record.nbname = nbname;

  //  - 16-bit RR type
  var t = buf.readUInt16BE(offset + bytes);
  bytes += 2;

  record.type = con.RR_TYPE_TO_STRING[t];
  if (record.type === undefined) {
    return {
      error: new Error('Illegal resource record type [' + t + '] for name [' +
                       nbname + ']')
    };
  }
  var rdataParser = RR_TYPE_TO_PARSER[record.type];

  //  - 16-bit RR class
  var clazz = buf.readUInt16BE(offset + bytes);
  bytes += 2;

  if (clazz !== con.CLASS_IN) {
    return {
      error: new Error('Unexpected resource record class [' + clazz +
                       '] for name [' + record.nbname + ']; expected class [' +
                       con.CLASS_IN + '].')
    };
  }

  //  - 32-bit TTL
  record.ttl = buf.readUInt32BE(offset + bytes);
  bytes += 4;

  //  - 16-bit resource data length in bytes
  var dataLen = buf.readUInt16BE(offset + bytes);
  bytes += 2;

  //  - variable length resource data
  var res = rdataParser(buf, offset + bytes, dataLen, record);
  if (res.error) {
    return {error: res.error};
  }

  bytes += res.bytesRead;

  return {bytesRead: bytes, record: record};
}
1312822
def _unpack_tuple(self, buff):
        
        cardinality = struct_L.unpack_from(buff)[0]
        _tuple = ['']*cardinality
        offset = 4    # The first 4 bytes in the response body is the <count> we have already read
        for i in xrange(cardinality):
            field_size, offset = self._unpack_int_base128(buff, offset)
            field_data = struct.unpack_from("<%ds" % field_size, buff, offset)[0]
            _tuple[i] = field(field_data)
            offset += field_size

        return tuple(_tuple)
40754
def read_byte(self, base, offset=0):
        
        fmt = 'B'
        return self._read_int(fmt, base, offset)
644924
def _AlignDecodedDataOffset(self, decoded_data_offset):
    
    self._file_object.seek(0, os.SEEK_SET)

    self._decoder = self._GetDecoder()
    self._decoded_data = b''

    encoded_data_offset = 0
    encoded_data_size = self._file_object.get_size()

    while encoded_data_offset < encoded_data_size:
      read_count = self._ReadEncodedData(self._ENCODED_DATA_BUFFER_SIZE)
      if read_count == 0:
        break

      encoded_data_offset += read_count

      if decoded_data_offset < self._decoded_data_size:
        self._decoded_data_offset = decoded_data_offset
        break

      decoded_data_offset -= self._decoded_data_size
121241
def decode(cls, data, bytes_to_read=None):
        
        if isinstance(data, bytes):
            data = io.BytesIO(data)
        if bytes_to_read is None:
            bytes_to_read = Int32.decode(data)

        # if FetchRequest max_bytes is smaller than the available message set
        # the server returns partial data for the final message
        # So create an internal buffer to avoid over-reading
        raw = io.BytesIO(data.read(bytes_to_read))

        items = []
        while bytes_to_read:
            try:
                offset = Int64.decode(raw)
                msg_bytes = Bytes.decode(raw)
                bytes_to_read -= 8 + 4 + len(msg_bytes)
                items.append((offset, len(msg_bytes), Message.decode(msg_bytes)))
            except ValueError:
                # PartialMessage to signal that max_bytes may be too small
                items.append((None, None, PartialMessage()))
                break
        return items
1158899
@SuppressWarnings("unchecked")
    // The warning 'unchecked cast' being suppressed here comes from the build() formally returning
    // a MessageLite-derived class that cannot be statically guaranteed to be the MessageType.
    private void deserializeMessage(ByteBuffer buff) throws Exception {
        MessageType msg = (MessageType) prototype.newBuilderForType().mergeFrom(ByteString.copyFrom(buff)).build();
        resetTimeout();
        handler.messageReceived(this, msg);
    }
712628
def serialize(self, buf, offset):
        
        fields = [ofproto.oxm_from_user(k, uv) for (k, uv)
                  in self._fields2]

        hdr_pack_str = '!HH'
        field_offset = offset + struct.calcsize(hdr_pack_str)
        for (n, value, mask) in fields:
            field_offset += ofproto.oxm_serialize(n, value, mask, buf,
                                                  field_offset)

        length = field_offset - offset
        msg_pack_into(hdr_pack_str, buf, offset, ofproto.OFPMT_OXM, length)
        self.length = length

        pad_len = utils.round_up(length, 8) - length
        msg_pack_into("%dx" % pad_len, buf, field_offset)

        return length + pad_len
1178077
def readByte(self):
        
        byte = unpack('B' if not self.signed else 'b', self.readAt(self.offset, 1))[0]
        self.offset += 1
        return byte
1185407
function(buff, offset, n) {
    var i;
    for(i = 0; i < n && zip_deflate_pos < zip_deflate_data.length; i++)
	buff[offset + i] =
	    zip_deflate_data.charCodeAt(zip_deflate_pos++) & 0xff;
    return i;
}
1347862
def read(self, data, offset=0):
        
        if isinstance(data, Buffer):
            return data.read(self)

        try:
            args = list(self._struct.unpack_from(data, offset))
        except TypeError as error:
            # Working around struct.unpack_from issue #10212
            logger.debug("error: %s", error)
            args = list(self._struct.unpack_from(str(bytearray(data)), offset))
        args.reverse()
        return self.popValue(args)
354885
def unpack(self, format_text):
        
        data = _unpack_from(format_text, self.data, self.offset)
        self.offset += _calcsize(format_text)
        return data
343650
def unpack_struct(self, struct):
        

        size = struct.size

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

        if avail < size:
            raise UnpackException(struct.format, size, avail)

        self.offset = offset + size
        return struct.unpack_from(self.data, offset)
633859
def unpack(self, buff, offset=0):
        
        super().unpack(buff, offset)
        # Recover field from field_and_hasmask.
        try:
            self.oxm_field = self._unpack_oxm_field()
        except ValueError as exception:
            raise UnpackException(exception)

        # The last bit of field_and_mask is oxm_hasmask
        self.oxm_hasmask = (self.oxm_field_and_mask & 1) == 1  # as boolean

        # Unpack oxm_value that has oxm_length bytes
        start = offset + 4  # 4 bytes: class, field_and_mask and length
        end = start + self.oxm_length
        self.oxm_value = buff[start:end]
524401
def unpack(packed, object_hook=decode,
           list_hook=None, use_list=False, encoding='utf-8',
           unicode_errors='strict', object_pairs_hook=None,
           max_buffer_size=0, ext_hook=ExtType):
    

    return Unpacker(packed, object_hook=object_hook,
                    list_hook=list_hook,
                    use_list=use_list, encoding=encoding,
                    unicode_errors=unicode_errors,
                    object_pairs_hook=object_pairs_hook,
                    max_buffer_size=max_buffer_size,
                    ext_hook=ext_hook)
1302843
def unpack(self, unpacker):
        

        (count, ) = unpacker.unpack_struct(_H)

        # first item is never present in the actual data buffer, but
        # the count number acts like it would be.
        items = [(None, None), ]
        count -= 1

        # Long and Double const types will "consume" an item count,
        # but not data
        hackpass = False

        for _i in range(0, count):

            if hackpass:
                # previous item was a long or double
                hackpass = False
                items.append((None, None))

            else:
                item = _unpack_const_item(unpacker)
                items.append(item)

                # if this item was a long or double, skip the next
                # counter.
                if item[0] in (CONST_Long, CONST_Double):
                    hackpass = True

        self.consts = items
793044
def _pfp__unpack_data(self, raw_data):
        
        if self._pfp__pack_type is None:
            return
        if self._pfp__no_unpack:
            return

        unpack_func = self._pfp__packer
        unpack_args = []
        if self._pfp__packer is not None:
            unpack_func = self._pfp__packer
            unpack_args = [false(), raw_data]

        elif self._pfp__unpack is not None:
            unpack_func = self._pfp__unpack
            unpack_args = [raw_data]

        # does not need to be converted to a char array
        if not isinstance(unpack_func, functions.NativeFunction):
            io_stream = bitwrap.BitwrappedStream(six.BytesIO(raw_data))
            unpack_args[-1] = Array(len(raw_data), Char, io_stream)

        res = unpack_func.call(unpack_args, *self._pfp__pack_func_call_info, no_cast=True)
        if isinstance(res, Array):
            res = res._pfp__build()

        io_stream = six.BytesIO(res)
        tmp_stream = bitwrap.BitwrappedStream(io_stream)

        tmp_stream.padded = self._pfp__interp.get_bitfield_padded()

        self._ = self._pfp__parsed_packed = self._pfp__pack_type(tmp_stream)

        self._._pfp__watch(self)