FlexFile.h

Go to the documentation of this file.
00001 /*
00002 Copyright (C) 2005 The Pentagram team
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 FLEXFILE_H
00020 #define FLEXFILE_H
00021 
00022 #include "ArchiveFile.h"
00023 class IDataSource;
00024 
00025 class FlexFile : public ArchiveFile {
00026 public:
00027         ENABLE_RUNTIME_CLASSTYPE();
00028 
00031         explicit FlexFile(IDataSource* ds);
00032         virtual ~FlexFile();
00033 
00034         virtual bool exists(uint32 index) { return getSize(index) > 0; }
00035         virtual bool exists(const std::string& name) {
00036                 uint32 index;
00037                 if (nameToIndex(name, index))
00038                         return exists(index);
00039                 else
00040                         return false;
00041         }
00042 
00043         virtual uint8* getObject(uint32 index, uint32* size=0);
00044         virtual uint8* getObject(const std::string& name, uint32* size=0) {
00045                 uint32 index;
00046                 if (nameToIndex(name, index))
00047                         return getObject(index, size);
00048                 else
00049                         return 0;
00050         }
00051         
00052 
00053         virtual uint32 getSize(uint32 index);
00054         virtual uint32 getSize(const std::string& name) {
00055                 uint32 index;
00056                 if (nameToIndex(name, index))
00057                         return getSize(index);
00058                 else
00059                         return 0;
00060         }
00061 
00062         virtual uint32 getCount() { return count; }
00063 
00064         virtual uint32 getIndexCount() { return count; }
00065 
00066         virtual bool isIndexed() const { return true; }
00067         virtual bool isNamed() const { return false; }
00068 
00069         static bool isFlexFile(IDataSource* ds);
00070 
00071 protected:
00072         bool nameToIndex(const std::string& name, uint32& index);
00073 
00074         IDataSource* ds;
00075         uint32 count;
00076 
00077 private:
00078         uint32 getOffset(uint32 index);
00079 };
00080 
00081 
00082 #endif

Generated on Fri Jul 27 22:27:14 2007 for pentagram by  doxygen 1.4.7