fileentry.h
Go to the documentation of this file.
#ifndef FILEENTRY_H
#define FILEENTRY_H
#include "zipios++/zipios-config.h"
#include <string>
#include <vector>
#include "zipios++/meta-iostreams.h"
#include "zipios++/simplesmartptr.h"
#include "zipios++/zipios_defs.h"
namespace zipios {
using std::vector ;
using std::ostream ;
using std::istream ;
using std::string ;
enum StorageMethod { STORED = 0, SHRUNK, REDUCED1, REDUCED2,
REDUCED3, REDUCED4, IMPLODED, RESERVED,
DEFLATED } ;
class FileEntry ;
typedef SimpleSmartPointer< FileEntry > EntryPointer ;
typedef SimpleSmartPointer< const FileEntry > ConstEntryPointer ;
typedef vector< EntryPointer > Entries ;
typedef vector< EntryPointer > ConstEntries ;
class FileEntry {
public:
/* Default construcotr, copy constructor and copy assignment
operator are sufficient. */
virtual string getComment() const = 0 ;
virtual uint32 getCompressedSize() const = 0 ;
virtual uint32 getCrc() const = 0 ;
virtual vector< unsigned char > getExtra() const = 0 ;
virtual StorageMethod getMethod() const = 0 ;
virtual string getName() const = 0 ;
virtual string getFileName() const = 0 ;
virtual uint32 getSize() const = 0 ;
virtual int getTime() const = 0 ;
virtual bool isValid() const = 0 ;
// virtual int hashCode() const = 0 ;
virtual bool isDirectory() const = 0 ;
virtual void setComment( const string &comment ) = 0 ;
virtual void setCompressedSize( uint32 size ) = 0 ;
virtual void setCrc( uint32 crc ) = 0 ;
virtual void setExtra( const vector< unsigned char > &extra ) = 0 ;
virtual void setMethod( StorageMethod method ) = 0 ;
virtual void setName( const string &name ) = 0 ;
virtual void setSize( uint32 size ) = 0 ;
virtual void setTime( int time ) = 0 ;
virtual string toString() const = 0 ;
virtual FileEntry *clone() const = 0 ;
virtual ~FileEntry() {}
// protected:
class MatchName ;
class MatchFileName ;
protected:
friend class SimpleSmartPointer< FileEntry > ;
friend class SimpleSmartPointer< const FileEntry > ;
void ref() const { _refcount.ref() ; }
unsigned int unref() const { return _refcount.unref() ; }
ReferenceCount< FileEntry > _refcount ;
};
class FileEntry::MatchName {
public:
explicit MatchName( const string &name ) : _name( name ) {}
bool operator() ( const ConstEntryPointer &entry ) {
return entry->getName() == _name ;
}
private:
string _name ;
};
class FileEntry::MatchFileName {
public:
explicit MatchFileName( const string &name ) : _name( name ) {}
bool operator() ( const ConstEntryPointer &entry ) {
return entry->getFileName() == _name ;
}
private:
string _name ;
};
ostream &operator<< ( ostream &os, const FileEntry &entry ) ;
inline ostream &operator<< ( ostream &os, const ConstEntryPointer &entry ) {
os << *entry ;
return os ;
}
} // 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::FileEntry::MatchFileName
Function object to be used with the STL find_if algorithm to find a FileEntry in a container,...
Definition fileentry.h:195
zipios::FileEntry::MatchName
Function object to be used with the STL find_if algorithm to find a FileEntry in a container,...
Definition fileentry.h:181
zipios::FileEntry
A FileEntry represents an entry in a FileCollection.
Definition fileentry.h:52
zipios::FileEntry::getCompressedSize
virtual uint32 getCompressedSize() const =0
Returns the compressed size of the entry.
zipios::FileEntry::getComment
virtual string getComment() const =0
Returns the comment of the entry, if it has one.
zipios::FileEntry::setSize
virtual void setSize(uint32 size)=0
Sets the size field for the entry.
zipios::FileEntry::isDirectory
virtual bool isDirectory() const =0
Returns true if the entry is a directory.
zipios::FileEntry::getExtra
virtual vector< unsigned char > getExtra() const =0
Returns a vector of bytes of extra data that may be stored with the entry.
zipios::FileEntry::clone
virtual FileEntry * clone() const =0
Create a heap allocated clone of the object this method is called for.
zipios::FileEntry::toString
virtual string toString() const =0
Returns a human-readable string representation of the entry.
zipios::FileEntry::setCrc
virtual void setCrc(uint32 crc)=0
Sets the crc field.
zipios::FileEntry::getFileName
virtual string getFileName() const =0
Returns the filename of the entry.
zipios::FileEntry::getCrc
virtual uint32 getCrc() const =0
Returns the Crc for the entry, if it has one.
zipios::FileEntry::setMethod
virtual void setMethod(StorageMethod method)=0
Sets the storage method field for the entry.
zipios::FileEntry::isValid
virtual bool isValid() const =0
Any method or operator that initializes a FileEntry may set a flag, that specifies whether the read e...
zipios::FileEntry::getTime
virtual int getTime() const =0
Returns the date and time of FIXME: what?
zipios::FileEntry::~FileEntry
virtual ~FileEntry()
FileEntry destructor.
Definition fileentry.h:163
zipios::FileEntry::getName
virtual string getName() const =0
Returns the full filename of the entry, including a path if the entry is stored in a subfolder.
zipios::FileEntry::setComment
virtual void setComment(const string &comment)=0
Sets the comment field for the FileEntry.
zipios::FileEntry::getMethod
virtual StorageMethod getMethod() const =0
Returns the method used to store the entry in the FileCollection.
zipios::FileEntry::setCompressedSize
virtual void setCompressedSize(uint32 size)=0
Set the compressed size field of the entry.
zipios::FileEntry::setName
virtual void setName(const string &name)=0
Sets the name field for the entry.
zipios::FileEntry::getSize
virtual uint32 getSize() const =0
Returns the (uncompressed) size of the entry data.
zipios::FileEntry::setTime
virtual void setTime(int time)=0
Sets the time field for the entry.
zipios::FileEntry::setExtra
virtual void setExtra(const vector< unsigned char > &extra)=0
Sets the extra field.
zipios::SimpleSmartPointer< FileEntry >
zipios::ConstEntryPointer
SimpleSmartPointer< const FileEntry > ConstEntryPointer
ConstEntryPointer is a SimpleSmartPointer for const FileEntry's.
Definition fileentry.h:37
zipios::StorageMethod
StorageMethod
The types used with FileEntry::setMethod and FileEntry::getMethod.
Definition fileentry.h:25
zipios::EntryPointer
SimpleSmartPointer< FileEntry > EntryPointer
EntryPointer is a SimpleSmartPointer for FileEntry's.
Definition fileentry.h:33
zipios::ConstEntries
vector< EntryPointer > ConstEntries
ConstEntries is a vector of ConstEntryPointer's.
Definition fileentry.h:43
zipios::Entries
vector< EntryPointer > Entries
Entries is a vector of EntryPointer's.
Definition fileentry.h:40
simplesmartptr.h
Header file that defines SimpleSmartPointer and ReferenceCount.
zipios_defs.h
Header file that defines some simple data types.