| 1 |
lars |
1 |
<?php
|
|
|
2 |
|
|
|
3 |
/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4 foldmethod=marker: */
|
|
|
4 |
|
|
|
5 |
// LICENSE AGREEMENT. If folded, press za here to unfold and read license {{{
|
|
|
6 |
|
|
|
7 |
/**
|
|
|
8 |
* +-----------------------------------------------------------------------------+
|
|
|
9 |
* | Copyright (c) 2004-2006 Sergio Goncalves Carvalho |
|
|
|
10 |
* +-----------------------------------------------------------------------------+
|
|
|
11 |
* | This file is part of XML_RPC2. |
|
|
|
12 |
* | |
|
|
|
13 |
* | XML_RPC2 is free software; you can redistribute it and/or modify |
|
|
|
14 |
* | it under the terms of the GNU Lesser General Public License as published by |
|
|
|
15 |
* | the Free Software Foundation; either version 2.1 of the License, or |
|
|
|
16 |
* | (at your option) any later version. |
|
|
|
17 |
* | |
|
|
|
18 |
* | XML_RPC2 is distributed in the hope that it will be useful, |
|
|
|
19 |
* | but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
|
|
20 |
* | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
|
|
21 |
* | GNU Lesser General Public License for more details. |
|
|
|
22 |
* | |
|
|
|
23 |
* | You should have received a copy of the GNU Lesser General Public License |
|
|
|
24 |
* | along with XML_RPC2; if not, write to the Free Software |
|
|
|
25 |
* | Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA |
|
|
|
26 |
* | 02111-1307 USA |
|
|
|
27 |
* +-----------------------------------------------------------------------------+
|
|
|
28 |
* | Author: Sergio Carvalho <sergio.carvalho@portugalmail.com> |
|
|
|
29 |
* +-----------------------------------------------------------------------------+
|
|
|
30 |
*
|
|
|
31 |
* @category XML
|
|
|
32 |
* @package XML_RPC2
|
|
|
33 |
* @author Sergio Carvalho <sergio.carvalho@portugalmail.com>
|
|
|
34 |
* @copyright 2004-2006 Sergio Carvalho
|
|
|
35 |
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
|
|
36 |
* @version CVS: $Id: Integer64.php 224219 2006-12-02 18:09:49Z sergiosgc $
|
|
|
37 |
* @link http://pear.php.net/package/XML_RPC2
|
|
|
38 |
*/
|
|
|
39 |
|
|
|
40 |
// }}}
|
|
|
41 |
|
|
|
42 |
// dependencies {{{
|
|
|
43 |
require_once 'XML/RPC2/Exception.php';
|
|
|
44 |
require_once 'XML/RPC2/Backend/Php/Value/Scalar.php';
|
|
|
45 |
// }}}
|
|
|
46 |
|
|
|
47 |
/**
|
|
|
48 |
* XML_RPC integer value class. Instances of this class represent int scalars in XML_RPC
|
|
|
49 |
*
|
|
|
50 |
* @category XML
|
|
|
51 |
* @package XML_RPC2
|
|
|
52 |
* @author Sergio Carvalho <sergio.carvalho@portugalmail.com>
|
|
|
53 |
* @copyright 2004-2006 Sergio Carvalho
|
|
|
54 |
* @license http://www.gnu.org/copyleft/lesser.html LGPL License 2.1
|
|
|
55 |
* @link http://pear.php.net/package/XML_RPC2
|
|
|
56 |
*/
|
|
|
57 |
class XML_RPC2_Backend_Php_Value_Integer64 extends XML_RPC2_Backend_Php_Value_Scalar
|
|
|
58 |
{
|
|
|
59 |
|
|
|
60 |
// {{{ constructor
|
|
|
61 |
|
|
|
62 |
/**
|
|
|
63 |
* Constructor. Will build a new XML_RPC2_Backend_Php_Value_Integer64 with the given value
|
|
|
64 |
*
|
|
|
65 |
* @param mixed value
|
|
|
66 |
*/
|
|
|
67 |
public function __construct($nativeValue)
|
|
|
68 |
{
|
|
|
69 |
if (PHP_INT_SIZE < 8) throw new XML_RPC2_ConfigException('i8 XML-RPC extension can only be used with 64 bit (or larger) architectures');
|
|
|
70 |
$this->setScalarType('i8');
|
|
|
71 |
$this->setNativeValue($nativeValue);
|
|
|
72 |
}
|
|
|
73 |
|
|
|
74 |
// }}}
|
|
|
75 |
// {{{ decode()
|
|
|
76 |
|
|
|
77 |
/**
|
|
|
78 |
* decode. Decode transport XML and set the instance value accordingly
|
|
|
79 |
*
|
|
|
80 |
* @param mixed The decoded XML-RPC value,
|
|
|
81 |
*/
|
|
|
82 |
public static function decode($xml)
|
|
|
83 |
{
|
|
|
84 |
// TODO Remove reparsing of XML fragment, when SimpleXML proves more solid. Currently it segfaults when
|
|
|
85 |
// xpath is used both in an element and in one of its children
|
|
|
86 |
$xml = simplexml_load_string($xml->asXML());
|
|
|
87 |
$value = $xml->xpath('/value/i8/text()');
|
|
|
88 |
|
|
|
89 |
// Double cast explanation: http://pear.php.net/bugs/bug.php?id=8644
|
|
|
90 |
return (int) ((string) $value[0]);
|
|
|
91 |
}
|
|
|
92 |
|
|
|
93 |
// }}}
|
|
|
94 |
|
|
|
95 |
}
|
|
|
96 |
|
|
|
97 |
?>
|