c596a48f96507a77c4e359706291d77d9e34be48
[yaffs-website] / lsolesen / pel / src / PelEntrySLong.php
1 <?php
2
3 /**
4  * PEL: PHP Exif Library.
5  * A library with support for reading and
6  * writing all Exif headers in JPEG and TIFF images using PHP.
7  *
8  * Copyright (C) 2004, 2005, 2006 Martin Geisler.
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program in the file COPYING; if not, write to the
22  * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
23  * Boston, MA 02110-1301 USA
24  */
25 namespace lsolesen\pel;
26
27 /**
28  * Classes used to hold longs, both signed and unsigned.
29  *
30  * @author Martin Geisler <mgeisler@users.sourceforge.net>
31  * @license http://www.gnu.org/licenses/gpl.html GNU General Public
32  *          License (GPL)
33  * @package PEL
34  */
35
36 /**
37  * Class for holding signed longs.
38  *
39  * This class can hold longs, either just a single long or an array of
40  * longs. The class will be used to manipulate any of the Exif tags
41  * which can have format {@link PelFormat::SLONG}.
42  *
43  * @author Martin Geisler <mgeisler@users.sourceforge.net>
44  * @package PEL
45  */
46 class PelEntrySLong extends PelEntryNumber
47 {
48
49     /**
50      * Make a new entry that can hold a signed long.
51      *
52      * The method accept its arguments in two forms: several integer
53      * arguments or a single array argument. The {@link getValue}
54      * method will always return an array except for when a single
55      * integer argument is given here, or when an array with just a
56      * single integer is given.
57      *
58      * @param
59      *            PelTag the tag which this entry represents. This
60      *            should be one of the constants defined in {@link PelTag}
61      *            which have format {@link PelFormat::SLONG}.
62      *
63      * @param int $value...
64      *            the long(s) that this entry will represent
65      *            or an array of longs. The argument passed must obey the same
66      *            rules as the argument to {@link setValue}, namely that it should
67      *            be within range of a signed long (32 bit), that is between
68      *            -2147483648 and 2147483647 (inclusive). If not, then a {@link
69      *            PelOverflowException} will be thrown.
70      */
71     public function __construct($tag, $value = null)
72     {
73         $this->tag = $tag;
74         $this->min = - 2147483648;
75         $this->max = 2147483647;
76         $this->format = PelFormat::SLONG;
77
78         $value = func_get_args();
79         array_shift($value);
80         $this->setValueArray($value);
81     }
82
83     /**
84      * Convert a number into bytes.
85      *
86      * @param
87      *            int the number that should be converted.
88      *
89      * @param
90      *            PelByteOrder one of {@link PelConvert::LITTLE_ENDIAN} and
91      *            {@link PelConvert::BIG_ENDIAN}, specifying the target byte order.
92      *
93      * @return string bytes representing the number given.
94      */
95     public function numberToBytes($number, $order)
96     {
97         return PelConvert::sLongToBytes($number, $order);
98     }
99 }