fcoll.h

Go to the documentation of this file.
00001 #ifndef fcoll_H
00002 #define fcoll_H
00003 
00004 #include "zipios-config.h"
00005 
00006 #include <vector>
00007 #include <string>
00008 
00009 #include "fcollexceptions.h"
00010 #include "fileentry.h"
00011 
00012 namespace zipios {
00013 
00014 using std::vector;
00015 
00021 class BaseExport FileCollection {
00022 public:
00024   explicit FileCollection()
00025     : _filename( "-"   ),
00026       _entries ( 0     ),
00027       _valid   ( false ) {}
00028 
00030   FileCollection( const FileCollection &src ) ;
00031 
00033   const FileCollection &operator= ( const FileCollection &src ) ;
00034   
00036   virtual void close() = 0 ;
00037 
00038   enum MatchPath { 
00039     IGN, 
00040     MATCH 
00041   } ;
00048   virtual ConstEntries entries() const ;
00049 
00050 
00061   virtual ConstEntryPointer getEntry( const string &name, 
00062                                      MatchPath matchpath = MATCH ) const ;
00072   virtual istream *getInputStream( const ConstEntryPointer &entry ) = 0 ;
00073 
00086   virtual istream *getInputStream( const string &entry_name, 
00087                                      MatchPath matchpath = MATCH ) = 0 ;
00091   virtual string getName() const ;
00095   virtual int size() const ;
00096 
00100   bool isValid() const { return _valid ; }
00101 
00106   virtual FileCollection *clone() const = 0 ;
00107 
00108 
00110   virtual ~FileCollection () ;
00111 protected:
00112   string _filename ;
00113   Entries _entries ;
00114   bool _valid ;
00115 };
00116 
00117 
00118 //
00119 // Inline methods
00120 //
00121 
00122 inline ostream & operator<< (ostream &os, const FileCollection& collection) {
00123         os << "collection '" << collection.getName() << "' {" ;
00124         ConstEntries entries = collection.entries();
00125         ConstEntries::const_iterator it;
00126         bool isFirst=true;
00127         for (it=entries.begin(); it != entries.end(); ++it) {
00128                 if(! isFirst)
00129                         os << ", ";
00130                 isFirst = false;
00131                 os << (*it)->getName();
00132         }
00133         os << "}";
00134         return os;
00135 }
00136 
00137 } // namespace
00138 
00139 #endif
00140 
00145 /*
00146   Zipios++ - a small C++ library that provides easy access to .zip files.
00147   Copyright (C) 2000  Thomas Søndergaard
00148   
00149   This library is free software; you can redistribute it and/or
00150   modify it under the terms of the GNU Lesser General Public
00151   License as published by the Free Software Foundation; either
00152   version 2 of the License, or (at your option) any later version.
00153   
00154   This library is distributed in the hope that it will be useful,
00155   but WITHOUT ANY WARRANTY; without even the implied warranty of
00156   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00157   Lesser General Public License for more details.
00158   
00159   You should have received a copy of the GNU Lesser General Public
00160   License along with this library; if not, write to the Free Software
00161   Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
00162 */

Generated on Wed Nov 23 19:00:11 2011 for FreeCAD by  doxygen 1.6.1