00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #ifndef __FLEX_H_
00020 #define __FLEX_H_
00021
00022 #ifndef PENTAGRAM // DONT'T INCLUDE THIS IN PENTAGRAM!
00023
00024 #include <vector>
00025 #include <string>
00026 #include <iosfwd>
00027 #include "common_types.h"
00028 #include "U7file.h"
00029
00030 class DataSource;
00031
00032
00033 class Flex : public U7file
00034 {
00035 protected:
00036 char title[80];
00037 uint32 magic1;
00038 uint32 count;
00039 uint32 magic2;
00040 uint32 padding[9];
00041 struct Reference
00042 {
00043 uint32 offset;
00044 uint32 size;
00045 Reference() : offset(0),size(0) {};
00046 };
00047 std::vector<Reference> object_list;
00048
00049 public:
00050 Flex(const std::string &fname);
00051 Flex(const Flex &f) : magic1(f.magic1),count(f.count),magic2(f.magic2),object_list(f.object_list)
00052 { std::memcpy(title,f.title,sizeof(title));
00053 std::memcpy(padding,f.padding,sizeof(padding)); }
00054 Flex &operator=(const Flex &f)
00055 {
00056 magic1=f.magic1;
00057 count=f.count;
00058 magic2=f.magic2;
00059 object_list=f.object_list;
00060 std::memcpy(title,f.title,sizeof(title));
00061 std::memcpy(padding,f.padding,sizeof(padding));
00062 return *this;
00063 }
00064
00065 virtual uint32 number_of_objects(void) { return object_list.size(); };
00066 virtual char * retrieve(uint32 objnum,std::size_t &len);
00067 virtual const char *get_archive_type() { return "FLEX"; };
00068
00069 static void write_header(DataSource* out, const char *title, int count);
00070
00071 static bool is_flex(DataSource *in);
00072 static bool is_flex(const char *fname);
00073 private:
00074 Flex();
00075 void IndexFlexFile(void);
00076 };
00077
00078
00079
00080
00081 class Flex_writer
00082 {
00083 std::ofstream *out;
00084 int count;
00085 int index;
00086 long cur_start;
00087 uint8 *table;
00088 uint8 *tptr;
00089 public:
00090 Flex_writer(std::ofstream &o, const char *title, int cnt);
00091 ~Flex_writer();
00092 void mark_section_done();
00093 bool close();
00094 };
00095
00096 #endif // PENTAGRAM
00097
00098 #endif