ifdentry.cpp

00001 /*
00002  * libopenraw - ifdentry.cpp
00003  *
00004  * Copyright (C) 2006 Hubert Figuiere
00005  *
00006  * This library is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Lesser General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2.1 of the License, or (at your option) any later version.
00010  *
00011  * This library is distributed in the hope that it will be useful,
00012  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00013  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014  * Lesser General Public License for more details.
00015  *
00016  * You should have received a copy of the GNU Lesser General Public
00017  * License along with this library; if not, write to the Free Software
00018  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00019  */
00020 
00021 
00022 #include <cassert>
00023 
00024 #include "exception.h"
00025 #include "endianutils.h"
00026 
00027 #include "ifdfilecontainer.h"
00028 #include "ifdentry.h"
00029 #include "ifd.h"
00030 
00031 namespace OpenRaw {
00032     namespace Internals {
00033 
00034 
00035         IFDEntry::IFDEntry(int16_t _id, int16_t _type, 
00036                                              int32_t _count, uint32_t _data,
00037                                              IFDFileContainer &_container)
00038             : m_id(_id), m_type(_type),             
00039                 m_count(_count), m_data(_data), 
00040                 m_container(_container)
00041         {
00042         }
00043 
00044 
00045         IFDEntry::~IFDEntry()
00046         {
00047         }
00048 
00049         uint32_t IFDEntry::getLong() 
00050             throw (BadTypeException, TooBigException)
00051         {
00052             if (m_type != IFD::EXIF_FORMAT_LONG) {
00053                 throw BadTypeException();
00054             }
00055             if (m_count > 1) {
00056                 throw TooBigException();
00057             }
00058             uint32_t val;
00059             if (m_container.endian() == RawContainer::ENDIAN_LITTLE) {
00060                 val = EL32((uint8_t*)&m_data);
00061             }
00062             else {
00063                 val = BE32((uint8_t*)&m_data);
00064             }
00065             return val;
00066         }
00067 
00068         uint16_t IFDEntry::getShort() 
00069             throw (BadTypeException, TooBigException)
00070         {
00071             if (m_type != IFD::EXIF_FORMAT_SHORT) {
00072                 throw BadTypeException();
00073             }
00074             if (m_count > 1) {
00075                 throw TooBigException();
00076             }
00077             uint32_t val;
00078             if (m_container.endian() == RawContainer::ENDIAN_LITTLE) {
00079                 val = EL16((uint8_t*)&m_data);
00080             }
00081             else {
00082                 val = BE16((uint8_t*)&m_data);
00083             }
00084             return val;
00085         }
00086 
00087     }
00088 }

Generated on Sat Jan 27 11:36:13 2007 for libopenraw by  doxygen 1.4.7