public function Decoder::decode in Smart IP 7.2
Same name and namespace in other branches
- 6.2 includes/vendor/maxmind-db/reader/src/MaxMind/Db/Reader/Decoder.php \MaxMind\Db\Reader\Decoder::decode()
2 calls to Decoder::decode()
- Decoder::decodeArray in includes/
vendor/ maxmind-db/ reader/ src/ MaxMind/ Db/ Reader/ Decoder.php - Decoder::decodeMap in includes/
vendor/ maxmind-db/ reader/ src/ MaxMind/ Db/ Reader/ Decoder.php
File
- includes/
vendor/ maxmind-db/ reader/ src/ MaxMind/ Db/ Reader/ Decoder.php, line 49
Class
Namespace
MaxMind\Db\ReaderCode
public function decode($offset) {
list(, $ctrlByte) = unpack('C', Util::read($this->fileStream, $offset, 1));
$offset++;
$type = $this->types[$ctrlByte >> 5];
// Pointers are a special case, we don't read the next $size bytes, we
// use the size to determine the length of the pointer and then follow
// it.
if ($type == 'pointer') {
list($pointer, $offset) = $this
->decodePointer($ctrlByte, $offset);
// for unit testing
if ($this->pointerTestHack) {
return array(
$pointer,
);
}
list($result) = $this
->decode($pointer);
return array(
$result,
$offset,
);
}
if ($type == 'extended') {
list(, $nextByte) = unpack('C', Util::read($this->fileStream, $offset, 1));
$typeNum = $nextByte + 7;
if ($typeNum < 8) {
throw new InvalidDatabaseException("Something went horribly wrong in the decoder. An extended type " . "resolved to a type number < 8 (" . $this->types[$typeNum] . ")");
}
$type = $this->types[$typeNum];
$offset++;
}
list($size, $offset) = $this
->sizeFromCtrlByte($ctrlByte, $offset);
return $this
->decodeByType($type, $offset, $size);
}