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.
8 * Copyright (C) 2004, 2005, 2006 Martin Geisler.
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.
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.
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
25 namespace lsolesen\pel;
28 * Classes used to hold longs, both signed and unsigned.
30 * @author Martin Geisler <mgeisler@users.sourceforge.net>
31 * @license http://www.gnu.org/licenses/gpl.html GNU General Public
37 * Class for holding signed longs.
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}.
43 * @author Martin Geisler <mgeisler@users.sourceforge.net>
46 class PelEntrySLong extends PelEntryNumber
50 * Make a new entry that can hold a signed long.
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.
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}.
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.
71 public function __construct($tag, $value = null)
74 $this->min = - 2147483648;
75 $this->max = 2147483647;
76 $this->format = PelFormat::SLONG;
78 $value = func_get_args();
80 $this->setValueArray($value);
84 * Convert a number into bytes.
87 * int the number that should be converted.
90 * PelByteOrder one of {@link PelConvert::LITTLE_ENDIAN} and
91 * {@link PelConvert::BIG_ENDIAN}, specifying the target byte order.
93 * @return string bytes representing the number given.
95 public function numberToBytes($number, $order)
97 return PelConvert::sLongToBytes($number, $order);