1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace SPSS\Sav\Record\Info; |
4
|
|
|
|
5
|
|
|
use SPSS\Buffer; |
6
|
|
|
use SPSS\Sav\Record\Info; |
7
|
|
|
|
8
|
|
|
class MachineInteger extends Info |
9
|
|
|
{ |
10
|
|
|
const SUBTYPE = 3; |
11
|
|
|
|
12
|
|
|
/** |
13
|
|
|
* @var array [Major, Minor, Revision] |
14
|
|
|
*/ |
15
|
|
|
public $version = [1, 0, 0]; |
16
|
|
|
|
17
|
|
|
/** |
18
|
|
|
* @var int Machine code. |
19
|
|
|
*/ |
20
|
|
|
public $machineCode = 0; |
21
|
|
|
|
22
|
|
|
/** |
23
|
|
|
* @var int Floating point representation code. |
24
|
|
|
* For IEEE 754 systems this is 1. |
25
|
|
|
* IBM 370 sets this to 2, |
26
|
|
|
* and DEC VAX E to 3. |
27
|
|
|
*/ |
28
|
|
|
public $floatingPointRep = 1; |
29
|
|
|
|
30
|
|
|
/** |
31
|
|
|
* @var int Compression code. |
32
|
|
|
* Always set to 1, regardless of whether or how the file is compressed. |
33
|
|
|
*/ |
34
|
|
|
public $compressionCode = 1; |
35
|
|
|
|
36
|
|
|
/** |
37
|
|
|
* @var int Machine endianness. |
38
|
|
|
* 1 indicates big-endian, |
39
|
|
|
* 2 indicates little-endian. |
40
|
|
|
*/ |
41
|
|
|
public $endianness = 2; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @var int Character code. |
45
|
|
|
* The following values have been actually observed in system files: |
46
|
|
|
* 1 EBCDIC. |
47
|
|
|
* 2 7-bit ASCII. |
48
|
|
|
* 3 8-bit ASCII. |
49
|
|
|
* 4 DEC Kanji. |
50
|
|
|
* 1250 The windows-1250 code page for Central European and Eastern European languages. |
51
|
|
|
* 1252 The windows-1252 code page for Western European languages. |
52
|
|
|
* 28591 ISO 8859-1. |
53
|
|
|
* 65001 UTF-8. |
54
|
|
|
*/ |
55
|
|
|
public $characterCode = 65001; |
56
|
|
|
|
57
|
|
|
/** |
58
|
|
|
* @var int Always set to 4. |
59
|
|
|
*/ |
60
|
|
|
protected $dataSize = 4; |
61
|
|
|
|
62
|
|
|
/** |
63
|
|
|
* @var int Always set to 8. |
64
|
|
|
*/ |
65
|
|
|
protected $dataCount = 8; |
66
|
|
|
|
67
|
|
|
/** |
68
|
|
|
* @param Buffer $buffer |
69
|
|
|
*/ |
70
|
|
|
public function read(Buffer $buffer) |
71
|
|
|
{ |
72
|
|
|
parent::read($buffer); |
73
|
|
|
$this->version = [$buffer->readInt(), $buffer->readInt(), $buffer->readInt()]; |
74
|
|
|
$this->machineCode = $buffer->readInt(); |
75
|
|
|
$this->floatingPointRep = $buffer->readInt(); |
76
|
|
|
$this->compressionCode = $buffer->readInt(); |
77
|
|
|
$this->endianness = $buffer->readInt(); |
78
|
|
|
$this->characterCode = $buffer->readInt(); |
79
|
|
|
} |
80
|
|
|
|
81
|
|
|
/** |
82
|
|
|
* @param Buffer $buffer |
83
|
|
|
*/ |
84
|
|
|
public function write(Buffer $buffer) |
85
|
|
|
{ |
86
|
|
|
parent::write($buffer); |
87
|
|
|
$buffer->writeInt($this->version[0]); |
88
|
|
|
$buffer->writeInt($this->version[1]); |
89
|
|
|
$buffer->writeInt($this->version[2]); |
90
|
|
|
$buffer->writeInt($this->machineCode); |
91
|
|
|
$buffer->writeInt($this->floatingPointRep); |
92
|
|
|
$buffer->writeInt($this->compressionCode); |
93
|
|
|
$buffer->writeInt($this->endianness); |
94
|
|
|
$buffer->writeInt($this->characterCode); |
95
|
|
|
} |
96
|
|
|
} |