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
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 inline ostream & operator<< (ostream &os, const FileCollection& collection) {
00140 os << "collection '" << collection.getName() << "' {" ;
00141 ConstEntries entries = collection.entries();
00142 ConstEntries::const_iterator it;
00143 bool isFirst=true;
00144 for (it=entries.begin(); it != entries.end(); ++it) {
00145 if(! isFirst)
00146 os << ", ";
00147 isFirst = false;
00148 os << (*it)->getName();
00149 }
00150 os << "}";
00151 return os;
00152 }
00153
00154
00155 }
00156
00157 #endif
00158
00159
00292
00293
00294
00295
00296
00297
00298
00299
00300
00301
00302
00303
00304
00305
00306
00307
00308
00309