00001
00002 #include "zipios++/zipios-config.h"
00003
00004 #include <algorithm>
00005 #include <string>
00006 #include <vector>
00007
00008 #include "zipios++/fcoll.h"
00009
00010 namespace zipios {
00011
00012 using std::find_if ;
00013
00014
00015
00016
00017 ConstEntries FileCollection::entries() const {
00018 if ( ! _valid )
00019 throw InvalidStateException( "Attempt to get entries from an invalid FileCollection" ) ;
00020
00021
00022
00023
00024
00025 ConstEntries cep_vec ;
00026 cep_vec.reserve( _entries.size() ) ;
00027 Entries::const_iterator cit ;
00028 for ( cit = _entries.begin() ; cit != _entries.end() ; ++cit )
00029 cep_vec.push_back( *cit ) ;
00030
00031 return cep_vec ;
00032 }
00033
00034 ConstEntryPointer FileCollection::getEntry( const string &name,
00035 MatchPath matchpath ) const {
00036 if ( ! _valid )
00037 throw InvalidStateException( "Attempt to get an entry from an invalid FileCollection" ) ;
00038
00039 Entries::const_iterator iter ;
00040 if ( matchpath == MATCH )
00041 iter = find_if( _entries.begin(), _entries.end(), FileEntry::MatchName( name ) ) ;
00042 else
00043 iter = find_if( _entries.begin(), _entries.end(), FileEntry::MatchFileName( name ) ) ;
00044 if ( iter == _entries.end() )
00045 return 0 ;
00046 else
00047 return *iter ;
00048 }
00049
00050 string FileCollection::getName() const {
00051 if ( ! _valid )
00052 throw InvalidStateException( "Attempt to get the name of an invalid FileCollection" ) ;
00053 return _filename ;
00054 }
00055
00056
00057 int FileCollection::size() const {
00058 if ( ! _valid )
00059 throw InvalidStateException( "Attempt to get size of an invalid FileCollection" ) ;
00060 return _entries.size() ;
00061 }
00062
00063 FileCollection::~FileCollection() {
00064 }
00065
00066
00067 }
00068
00073 00074 00075 00076 00077 00078 00079 00080 00081 00082 00083 00084 00085 00086 00087 00088 00089 00090