zipios  2.2.0
Zipios -- a small C++ library that provides easy access to .zip files.
filecollection.hpp
Go to the documentation of this file.
1 #pragma once
2 #ifndef ZIPIOS_FILECOLLECTION_HPP
3 #define ZIPIOS_FILECOLLECTION_HPP
4 
5 /*
6  Zipios -- a small C++ library that provides easy access to .zip files.
7 
8  Copyright (C) 2000-2007 Thomas Sondergaard
9  Copyright (C) 2015-2019 Made to Order Software Corporation
10 
11  This library is free software; you can redistribute it and/or
12  modify it under the terms of the GNU Lesser General Public
13  License as published by the Free Software Foundation; either
14  version 2.1 of the License, or (at your option) any later version.
15 
16  This library is distributed in the hope that it will be useful,
17  but WITHOUT ANY WARRANTY; without even the implied warranty of
18  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19  Lesser General Public License for more details.
20 
21  You should have received a copy of the GNU Lesser General Public
22  License along with this library; if not, write to the Free Software
23  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 */
25 
33 #include "zipios/fileentry.hpp"
34 
35 
36 namespace zipios
37 {
38 
39 
41 {
42 public:
43  typedef std::shared_ptr<FileCollection> pointer_t;
44  typedef std::vector<pointer_t> vector_t;
45  typedef std::shared_ptr<std::istream> stream_pointer_t;
46 
47  enum class MatchPath : uint32_t
48  {
49  IGNORE,
50  MATCH
51  };
52 
53  FileCollection(std::string const & filename = "");
54  FileCollection(FileCollection const & src);
56  virtual pointer_t clone() const = 0;
57  virtual ~FileCollection();
58 
59  virtual void addEntry(FileEntry const & entry);
60  virtual void close();
61  virtual FileEntry::vector_t entries() const;
62  virtual FileEntry::pointer_t getEntry(std::string const & name, MatchPath matchpath = MatchPath::MATCH) const;
63  virtual stream_pointer_t getInputStream(std::string const & entry_name, MatchPath matchpath = MatchPath::MATCH) = 0;
64  virtual std::string getName() const;
65  virtual size_t size() const;
66  bool isValid() const;
67  virtual void mustBeValid() const;
68  void setMethod(size_t limit, StorageMethod small_storage_method, StorageMethod large_storage_method);
69  void setLevel(size_t limit, FileEntry::CompressionLevel small_compression_level, FileEntry::CompressionLevel large_compression_level);
70 
71 protected:
72  std::string m_filename;
74  bool m_valid = true;
75 };
76 
77 
78 std::ostream & operator << (std::ostream& os, FileCollection const& collection);
79 
80 
81 } // zipios namespace
82 
83 // Local Variables:
84 // mode: cpp
85 // indent-tabs-mode: nil
86 // c-basic-offset: 4
87 // tab-width: 4
88 // End:
89 
90 // vim: ts=4 sw=4 et
91 #endif
zipios::FileEntry::CompressionLevel
int CompressionLevel
The compression level to be used to save an entry.
Definition: fileentry.hpp:85
zipios::FileCollection::setLevel
void setLevel(size_t limit, FileEntry::CompressionLevel small_compression_level, FileEntry::CompressionLevel large_compression_level)
Change the compression level to the specified value.
Definition: filecollection.cpp:567
zipios::FileCollection::entries
virtual FileEntry::vector_t entries() const
Retrieve the array of entries.
Definition: filecollection.cpp:396
zipios::FileCollection::getEntry
virtual FileEntry::pointer_t getEntry(std::string const &name, MatchPath matchpath=MatchPath::MATCH) const
Get an entry from this collection.
Definition: filecollection.cpp:424
zipios::FileCollection::m_valid
bool m_valid
Definition: filecollection.hpp:74
zipios::FileCollection::clone
virtual pointer_t clone() const =0
Create a clone of this object.
zipios::FileCollection::stream_pointer_t
std::shared_ptr< std::istream > stream_pointer_t
A shared pointer to an input stream.
Definition: filecollection.hpp:45
zipios::FileCollection::size
virtual size_t size() const
Returns the number of entries in the FileCollection.
Definition: filecollection.cpp:474
zipios::FileEntry
A FileEntry represents an entry in a FileCollection.
Definition: fileentry.hpp:75
zipios::FileCollection::FileCollection
FileCollection(std::string const &filename="")
Initializes a FileCollection object.
Definition: filecollection.cpp:269
zipios::FileCollection::mustBeValid
virtual void mustBeValid() const
Check whether the collection is valid.
Definition: filecollection.cpp:509
zipios::FileEntry::pointer_t
std::shared_ptr< FileEntry > pointer_t
Definition: fileentry.hpp:78
zipios::FileCollection::operator=
FileCollection & operator=(FileCollection const &src)
Replace the content of a collection with a copy of another collection.
Definition: filecollection.cpp:315
zipios::operator<<
std::ostream & operator<<(std::ostream &os, FileCollection const &collection)
Write a FileCollection to the output stream.
Definition: filecollection.cpp:598
zipios::FileCollection::getInputStream
virtual stream_pointer_t getInputStream(std::string const &entry_name, MatchPath matchpath=MatchPath::MATCH)=0
Retrieve pointer to an istream.
zipios::FileCollection::vector_t
std::vector< pointer_t > vector_t
Definition: filecollection.hpp:44
zipios::FileCollection
Base class for various file collections.
Definition: filecollection.hpp:40
zipios::FileCollection::MatchPath::IGNORE
@ IGNORE
zipios::FileCollection::MatchPath
MatchPath
Definition: filecollection.hpp:47
zipios::FileCollection::close
virtual void close()
Close the current FileEntry of this FileCollection.
Definition: filecollection.cpp:378
zipios::FileCollection::~FileCollection
virtual ~FileCollection()
Make sure the resources are released.
Definition: filecollection.cpp:349
zipios::StorageMethod
StorageMethod
The types used with FileEntry::setMethod and FileEntry::getMethod.
Definition: fileentry.hpp:48
zipios::FileCollection::MatchPath::MATCH
@ MATCH
zipios::FileCollection::setMethod
void setMethod(size_t limit, StorageMethod small_storage_method, StorageMethod large_storage_method)
Change the storage method to the specified value.
Definition: filecollection.cpp:532
zipios::FileCollection::m_entries
FileEntry::vector_t m_entries
Definition: filecollection.hpp:73
zipios::FileCollection::pointer_t
std::shared_ptr< FileCollection > pointer_t
Definition: filecollection.hpp:43
zipios::FileCollection::getName
virtual std::string getName() const
Returns the name of the FileCollection.
Definition: filecollection.cpp:456
zipios::FileCollection::m_filename
std::string m_filename
Definition: filecollection.hpp:72
fileentry.hpp
Define the zipios::FileEntry class.
zipios::FileEntry::vector_t
std::vector< pointer_t > vector_t
Definition: fileentry.hpp:79
zipios
The zipios namespace includes the Zipios library definitions.
Definition: backbuffer.cpp:35
zipios::FileCollection::isValid
bool isValid() const
Check whether the current collection is valid.
Definition: filecollection.cpp:493
zipios::FileCollection::addEntry
virtual void addEntry(FileEntry const &entry)
Add an entry to this collection.
Definition: filecollection.cpp:368