fileentry.h
Go to the documentation of this file.00001 #ifndef FILEENTRY_H
00002 #define FILEENTRY_H
00003
00004 #include "zipios-config.h"
00005
00006 #include <string>
00007 #include <vector>
00008 #include "meta-iostreams.h"
00009
00010 #include "simplesmartptr.h"
00011 #include "zipios_defs.h"
00012
00013 namespace zipios {
00014
00015 using std::vector ;
00016 using std::ostream ;
00017 using std::istream ;
00018 using std::string ;
00019
00025 enum StorageMethod { STORED = 0, SHRUNK, REDUCED1, REDUCED2,
00026 REDUCED3, REDUCED4, IMPLODED, RESERVED,
00027 DEFLATED } ;
00028
00029 class FileEntry ;
00030
00033 typedef SimpleSmartPointer< FileEntry > EntryPointer ;
00034
00035
00037 typedef SimpleSmartPointer< const FileEntry > ConstEntryPointer ;
00038
00040 typedef vector< EntryPointer > Entries ;
00041
00043 typedef vector< EntryPointer > ConstEntries ;
00044
00045
00046
00052 class BaseExport FileEntry {
00053 public:
00054
00055
00056
00057
00062 virtual string getComment() const = 0 ;
00069 virtual uint32 getCompressedSize() const = 0 ;
00074 virtual uint32 getCrc() const = 0 ;
00080 virtual vector< unsigned char > getExtra() const = 0 ;
00085 virtual StorageMethod getMethod() const = 0 ;
00091 virtual string getName() const = 0 ;
00095 virtual string getFileName() const = 0 ;
00099 virtual uint32 getSize() const = 0 ;
00103 virtual int getTime() const = 0 ;
00109 virtual bool isValid() const = 0 ;
00110
00116 virtual bool isDirectory() const = 0 ;
00117
00121 virtual void setComment( const string &comment ) = 0 ;
00125 virtual void setCompressedSize( uint32 size ) = 0 ;
00129 virtual void setCrc( uint32 crc ) = 0 ;
00133 virtual void setExtra( const vector< unsigned char > &extra ) = 0 ;
00137 virtual void setMethod( StorageMethod method ) = 0 ;
00141 virtual void setName( const string &name ) = 0 ;
00145 virtual void setSize( uint32 size ) = 0 ;
00149 virtual void setTime( int time ) = 0 ;
00150
00154 virtual string toString() const = 0 ;
00155
00160 virtual FileEntry *clone() const = 0 ;
00161
00163 virtual ~FileEntry() {}
00164
00165
00166 class MatchName ;
00167 class MatchFileName ;
00168 protected:
00169 friend class SimpleSmartPointer< FileEntry > ;
00170 friend class SimpleSmartPointer< const FileEntry > ;
00171 void ref() const { _refcount.ref() ; }
00172 unsigned int unref() const { return _refcount.unref() ; }
00173
00174 ReferenceCount< FileEntry > _refcount ;
00175 };
00176
00181 class FileEntry::MatchName {
00182 public:
00183 explicit MatchName( const string &name ) : _name( name ) {}
00184 bool operator() ( const ConstEntryPointer &entry ) {
00185 return entry->getName() == _name ;
00186 }
00187 private:
00188 string _name ;
00189 };
00190
00195 class FileEntry::MatchFileName {
00196 public:
00197 explicit MatchFileName( const string &name ) : _name( name ) {}
00198 bool operator() ( const ConstEntryPointer &entry ) {
00199 return entry->getFileName() == _name ;
00200 }
00201 private:
00202 string _name ;
00203 };
00204
00205 BaseExport ostream &operator<< ( ostream &os, const FileEntry &entry ) ;
00206
00207 inline ostream &operator<< ( ostream &os, const ConstEntryPointer &entry ) {
00208 os << *entry ;
00209 return os ;
00210 }
00211
00212
00213
00214 }
00215
00216 #endif
00217
00218
00223
00224
00225
00226
00227
00228
00229
00230
00231
00232
00233
00234
00235
00236
00237
00238
00239
00240