1 |
<? |
2 |
// ------------------------------------------------------------------------- |
3 |
// $Id: Deep.php,v 1.1 2003/02/03 14:51:44 joko Exp $ |
4 |
// ------------------------------------------------------------------------- |
5 |
// $Log: Deep.php,v $ |
6 |
// Revision 1.1 2003/02/03 14:51:44 joko |
7 |
// + initial commit |
8 |
// + refactored from flib/... |
9 |
// |
10 |
// ------------------------------------------------------------------------- |
11 |
|
12 |
|
13 |
// rename to Data::Hash::Addressable??? |
14 |
|
15 |
class Data_Deep { |
16 |
|
17 |
var $payload; |
18 |
|
19 |
function Data_Deep(&$payload) { |
20 |
$this->payload = &$payload; |
21 |
} |
22 |
|
23 |
function &get($attr) { |
24 |
$evalstr = 'return $this->payload' . $this->_getHKR($attr) . ';'; |
25 |
$val = eval($evalstr); |
26 |
return $val; |
27 |
} |
28 |
|
29 |
function set($attr, $val) { |
30 |
//$evalstr = '$this->payload' . $this->_getHKR($attr) . ' = \'' . $val . '\';'; |
31 |
$evalstr = '$this->payload' . $this->_getHKR($attr) . ' = $val;'; |
32 |
eval($evalstr); |
33 |
} |
34 |
|
35 |
function getPayload() { |
36 |
return $this->payload; |
37 |
} |
38 |
|
39 |
function _getHKR($key) { |
40 |
$attr_arr = split('\.', $key); |
41 |
$attr_hkr = '["' . join('"]["', $attr_arr) . '"]'; |
42 |
return $attr_hkr; |
43 |
} |
44 |
|
45 |
} |
46 |
|
47 |
?> |