Main Page   Class Hierarchy   Compound List   File List   Compound Members  

fcoll.h

Go to the documentation of this file.
00001 #ifndef fcoll_H
00002 #define fcoll_H
00003 
00004 #include "zipios++/zipios-config.h"
00005 
00006 #include <vector>
00007 #include <string>
00008 
00009 #include "zipios++/fcollexceptions.h"
00010 #include "zipios++/fileentry.h"
00011 
00012 namespace zipios {
00013 
00014 using std::vector;
00015 
00021 class FileCollection {
00022 public:
00024   explicit FileCollection() 
00025     : _filename( "-"   ),
00026       _entries ( 0     ),
00027       _valid   ( false ) {}
00028 
00030   inline FileCollection( const FileCollection &src ) ;
00031 
00033   inline const FileCollection &operator= ( const FileCollection &src ) ;
00034   
00036   virtual void close() = 0 ;
00037 
00044   virtual ConstEntries entries() const ;
00045 
00046   enum MatchPath { IGNORE, MATCH } ;
00047 
00058   virtual ConstEntryPointer getEntry( const string &name, 
00059                                      MatchPath matchpath = MATCH ) const ;
00069   virtual istream *getInputStream( const ConstEntryPointer &entry ) = 0 ;
00079   virtual istream *getInputStream( const string &entry_name, 
00080                                      MatchPath matchpath = MATCH ) = 0 ;
00084   virtual string getName() const ;
00088   virtual int size() const ;
00089 
00093   bool isValid() const { return _valid ; }
00094 
00099   virtual FileCollection *clone() const = 0 ;
00100 
00101 
00103   virtual ~FileCollection () ;
00104 protected:
00105   string _filename ;
00106   Entries _entries ;
00107   bool _valid ;
00108 };
00109 
00110 
00111 //
00112 // Inline methods
00113 //
00114 
00115 FileCollection::FileCollection( const FileCollection &src ) 
00116   : _filename( src._filename ),
00117     _valid   ( src._valid    )
00118 {
00119   _entries.reserve( src._entries.size() ) ;
00120   Entries::const_iterator it ;
00121   for ( it = src._entries.begin() ; it != src._entries.end() ; ++it )
00122     _entries.push_back( (*it)->clone() ) ;
00123 }
00124 
00125 const FileCollection &FileCollection::operator= ( const FileCollection &src ) {
00126   if ( this != &src ) {
00127     _filename = src._filename ;
00128     _valid    = src._valid    ;
00129     _entries.clear() ;
00130     _entries.reserve( src._entries.size() ) ;
00131     
00132     Entries::const_iterator it ;
00133     for ( it = src._entries.begin() ; it != src._entries.end() ; ++it )
00134       _entries.push_back( (*it)->clone() ) ;
00135   }
00136   return *this ;
00137 }
00138 
00139 } // namespace
00140 
00141 #endif
00142 
00143 
00274 /*
00275   Zipios++ - a small C++ library that provides easy access to .zip files.
00276   Copyright (C) 2000  Thomas Søndergaard
00277   
00278   This library is free software; you can redistribute it and/or
00279   modify it under the terms of the GNU Lesser General Public
00280   License as published by the Free Software Foundation; either
00281   version 2 of the License, or (at your option) any later version.
00282   
00283   This library is distributed in the hope that it will be useful,
00284   but WITHOUT ANY WARRANTY; without even the implied warranty of
00285   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00286   Lesser General Public License for more details.
00287   
00288   You should have received a copy of the GNU Lesser General Public
00289   License along with this library; if not, write to the Free Software
00290   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00291 */

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