Main Page   Class Hierarchy   Compound List   File List   Compound Members  

fileentry.h

Go to the documentation of this file.
00001 #ifndef FILEENTRY_H
00002 #define FILEENTRY_H
00003 
00004 #include "zipios++/zipios-config.h"
00005 
00006 #include <string>
00007 #include <vector>
00008 #include "zipios++/meta-iostreams.h"
00009 
00010 #include "zipios++/simplesmartptr.h"
00011 #include "zipios++/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 FileEntry {
00053 public:
00054 
00055   /* Default construcotr, copy constructor and copy assignment
00056      operator are sufficient. */
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   //     virtual int hashCode() const = 0 ;
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 //  protected:
00166   class MatchName ;
00167   class MatchFileName ;
00168 protected:
00169   friend SimpleSmartPointer< FileEntry > ;
00170   friend 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 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 } // namespace
00215 
00216 #endif
00217 
00218 
00223 /*
00224   Zipios++ - a small C++ library that provides easy access to .zip files.
00225   Copyright (C) 2000  Thomas Søndergaard
00226   
00227   This library is free software; you can redistribute it and/or
00228   modify it under the terms of the GNU Lesser General Public
00229   License as published by the Free Software Foundation; either
00230   version 2 of the License, or (at your option) any later version.
00231   
00232   This library is distributed in the hope that it will be useful,
00233   but WITHOUT ANY WARRANTY; without even the implied warranty of
00234   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00235   Lesser General Public License for more details.
00236   
00237   You should have received a copy of the GNU Lesser General Public
00238   License along with this library; if not, write to the Free Software
00239   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00240 */

Generated at Tue Aug 14 20:39:26 2001 for Zipios++ by doxygen1.2.0 written by Dimitri van Heesch, © 1997-2000