IFF.h

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 2000  Dancer A.L Vesperman
00003 
00004 This program is free software; you can redistribute it and/or
00005 modify it under the terms of the GNU General Public License
00006 as published by the Free Software Foundation; either version 2
00007 of the License, or (at your option) any later version.
00008 
00009 This program is distributed in the hope that it will be useful,
00010 but WITHOUT ANY WARRANTY; without even the implied warranty of
00011 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00012 GNU General Public License for more details.
00013 
00014 You should have received a copy of the GNU General Public License
00015 along with this program; if not, write to the Free Software
00016 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00017 */
00018 
00019 #ifndef __IFF_H_
00020 #define __IFF_H_
00021 
00022 #include <vector>
00023 #include <string>
00024 #include "common_types.h"
00025 #include "U7file.h"
00026 
00027 
00028 class IFF : public U7file
00029 {
00030 public:
00031   struct  IFFhdr
00032   {
00033     char  form_magic[4];
00034     uint32  size;
00035     char  data_type[4];
00036     IFFhdr() {}
00037     IFFhdr(const IFFhdr &i) : size(i.size)
00038     {
00039       std::memcpy(form_magic,i.form_magic,sizeof(form_magic));
00040       std::memcpy(data_type,i.data_type,sizeof(data_type));
00041     }
00042     IFFhdr &operator=(const IFFhdr &i)
00043     {
00044       size=i.size;
00045       std::memcpy(form_magic,i.form_magic,sizeof(form_magic));
00046       std::memcpy(data_type,i.data_type,sizeof(data_type));
00047       return *this;
00048     }
00049   };
00050   struct  IFFobject
00051   {
00052     char  type[4];
00053     uint32  size;
00054     char  even;
00055   };
00056   struct  u7IFFobj
00057   {
00058     char  name[8];
00059     // char    data[]; // Variable
00060   };
00061   struct Reference
00062     {
00063     uint32  offset;
00064     uint32  size;
00065     Reference() : offset(0),size(0) {};
00066   };
00067 
00068 protected:
00069   IFFhdr  header;
00070   std::vector<Reference> object_list;
00071 
00072 public:
00073   IFF(const std::string &fname);
00074   IFF(const IFF &i) : header(i.header),object_list(i.object_list) {}
00075   IFF operator=(const IFF &i)
00076   {
00077     header=i.header;
00078     object_list=i.object_list;
00079     return *this;
00080   }
00081 
00082   // char *read_object(int objnum,uint32 &length);
00083   virtual uint32    number_of_objects(void) { return object_list.size(); };
00084   virtual char *    retrieve(uint32 objnum,std::size_t &len); // To a memory block
00085   virtual const char* get_archive_type() { return "IFF"; };
00086 
00087 private:
00088   IFF(); // No default constructor
00089   void IndexIFFFile(void);
00090 };
00091 
00092 
00093 #endif

Generated on Mon Jul 9 14:42:45 2007 for ExultEngine by  doxygen 1.5.1