collcoll.h
Go to the documentation of this file.
#ifndef COLLCOLL_H
#define COLLCOLL_H
#include "zipios++/zipios-config.h"
#include <string>
#include <vector>
#include "zipios++/fcoll.h"
namespace zipios {
using std::string ;
class CollectionCollection : public FileCollection {
public:
static inline CollectionCollection &inst() ;
explicit CollectionCollection() ;
inline CollectionCollection( const CollectionCollection &src ) ;
inline const CollectionCollection &operator= ( const CollectionCollection &src ) ;
bool addCollection( const FileCollection &collection ) ;
bool addCollection( FileCollection *collection ) ;
virtual void close() ;
virtual ConstEntries entries() const ;
virtual ConstEntryPointer getEntry( const string &name,
MatchPath matchpath = MATCH ) const ;
virtual istream *getInputStream( const ConstEntryPointer &entry ) ;
virtual istream *getInputStream( const string &entry_name,
MatchPath matchpath = MATCH ) ;
virtual int size() const ;
virtual FileCollection *clone() const ;
virtual ~CollectionCollection() ;
protected:
void getEntry( const string &name,
ConstEntryPointer &cep,
std::vector< FileCollection * >::const_iterator &it,
MatchPath matchpath = MATCH ) const ;
vector< FileCollection * > _collections ;
private:
static CollectionCollection *_inst ;
};
typedef CollectionCollection CColl ;
//
// Inline (member) functions
//
CollectionCollection &CollectionCollection::inst() {
if( _inst != 0 )
return *_inst ;
else
return *( _inst = new CollectionCollection ) ;
}
CollectionCollection::CollectionCollection( const CollectionCollection &src )
: FileCollection( src )
{
_collections.reserve( src._collections.size() ) ;
std::vector< FileCollection * >::const_iterator it ;
for ( it = src._collections.begin() ; it != src._collections.end() ; ++it )
_collections.push_back( (*it)->clone() ) ;
}
const CollectionCollection &
CollectionCollection::operator= ( const CollectionCollection &src ) {
this->FileCollection::operator=( src ) ;
// FileCollection::=( static_cast< FileCollection >( src ) ) ;
if ( this != &src ) {
// Destroy current contents.
std::vector< FileCollection * >::const_iterator it ;
for ( it = _collections.begin() ; it != _collections.end() ; ++it )
delete *it ;
// Then copy src's content.
_collections.clear() ;
_collections.reserve( src._collections.size() ) ;
for ( it = src._collections.begin() ; it != src._collections.end() ; ++it )
_collections.push_back( (*it)->clone() ) ;
}
return *this ;
}
} // namespace
#endif
/*
Zipios++ - a small C++ library that provides easy access to .zip files.
Copyright (C) 2000 Thomas Søndergaard
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
zipios::CollectionCollection
CollectionCollection is a FileCollection that consists of an arbitrary number of FileCollections.
Definition collcoll.h:26
zipios::CollectionCollection::entries
virtual ConstEntries entries() const
Returns a vector of const pointers to the entries in the FileCollection.
Definition collcoll.cpp:46
zipios::CollectionCollection::getEntry
virtual ConstEntryPointer getEntry(const string &name, MatchPath matchpath=MATCH) const
Returns a ConstEntryPointer to a FileEntry object for the entry with the specified name.
Definition collcoll.cpp:58
zipios::CollectionCollection::addCollection
bool addCollection(const FileCollection &collection)
Adds a collection.
Definition collcoll.cpp:21
zipios::CollectionCollection::inst
static CollectionCollection & inst()
This static method provides a singleton instance of a CollectionCollection.
Definition collcoll.h:111
zipios::CollectionCollection::clone
virtual FileCollection * clone() const
Create a heap allocated clone of the object this method is called for.
Definition collcoll.cpp:108
zipios::CollectionCollection::getInputStream
virtual istream * getInputStream(const ConstEntryPointer &entry)
Returns a pointer to an opened istream for the specified FileEntry.
Definition collcoll.cpp:72
zipios::CollectionCollection::CollectionCollection
CollectionCollection()
Constructor.
Definition collcoll.cpp:16
zipios::CollectionCollection::size
virtual int size() const
Returns the number in entries in all collections kept by the CollectionCollection object.
Definition collcoll.cpp:98
zipios::CollectionCollection::close
virtual void close()
Closes the FileCollection.
Definition collcoll.cpp:41
zipios::CollectionCollection::operator=
const CollectionCollection & operator=(const CollectionCollection &src)
Copy assignment operator.
Definition collcoll.h:129
zipios::FileCollection::operator=
const FileCollection & operator=(const FileCollection &src)
Copy assignment operator.
Definition fcoll.h:125
zipios::FileCollection::FileCollection
FileCollection()
FileCollection constructor.
Definition fcoll.h:24
zipios::CColl
CollectionCollection CColl
Shortcut name for a CollectionCollection.
Definition collcoll.h:104
fcoll.h
Header file that defines FileCollection.
zipios::ConstEntryPointer
SimpleSmartPointer< const FileEntry > ConstEntryPointer
ConstEntryPointer is a SimpleSmartPointer for const FileEntry's.
Definition fileentry.h:37
zipios::ConstEntries
vector< EntryPointer > ConstEntries
ConstEntries is a vector of ConstEntryPointer's.
Definition fileentry.h:43