class parser_tools protected var dir_id protected var start_column pro

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
class parser_tools
{
protected var $dir_id;
protected var $start_column;
protected var $columns;
public function __construct($dir_id)
{
global $stations;
$this->dir_id = $dir_id;
$this->get_slice_values($stations);
}
}
class parser_tools_common extends parser_tools
{
public function get_slice_values(&$line)
{
if ($this->dir_id == 1)
{
$this->start_column = 0;
$this->columns = count($line) / 2;
}
else if ($this->dir_id == 2)
{
$this->start_column = //↓
$this->columns = count($line) / 2;
}
else
{
$this->start_column = 0;
$this->columns = count($line);
}
}
public function cut_line(&$line)
{
return array_slice($line, $this->start_column, $this->columns);
}
}
class parser_tools_1_8 extends parser_tools
{
public function get_slice_values(&$line)
{
if ($this->dir_id == 1)
{
$this->start_column = 0;
$this->columns = (count($line) + 1) / 2;
}
else if ($this->dir_id == 2)
{
$this->start_column = (count($line) + 1) / 2;
$this->columns = (count($line) - 1) / 2;
}
else
{
$this->start_column = 0;
$this->columns = count($line);
}
}
public function cut_line(&$line)
{
if ($this->dir_id == 2)
{
return array_merge(array($line[0]), array_slice($line, $this->start_column, $this->columns));
}
else
{
return array_slice($line, $this->start_column, $this->columns);
}
}
}