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
virtual FileEntry::pointer_t getEntry(std::string const &name, MatchPath matchpath=MatchPath::MATCH) const
Get an entry from this collection.
std::ostream & operator<<(std::ostream &os, FileCollection const &collection)
Write a FileCollection to the output stream.
The zipios namespace includes the Zipios library definitions.
Definition: backbuffer.cpp:35
std::shared_ptr< FileCollection > pointer_t
virtual void addEntry(FileEntry const &entry)
Add an entry to this collection.
FileCollection(std::string const &filename="")
Initializes a FileCollection object.
virtual pointer_t clone() const =0
Create a clone of this object.
std::shared_ptr< std::istream > stream_pointer_t
A shared pointer to an input stream.
std::vector< pointer_t > vector_t
virtual FileEntry::vector_t entries() const
Retrieve the array of entries.
virtual std::string getName() const
Returns the name of the FileCollection.
StorageMethod
The types used with FileEntry::setMethod and FileEntry::getMethod.
Definition: fileentry.hpp:48
int CompressionLevel
The compression level to be used to save an entry.
Definition: fileentry.hpp:85
virtual stream_pointer_t getInputStream(std::string const &entry_name, MatchPath matchpath=MatchPath::MATCH)=0
Retrieve pointer to an istream.
virtual size_t size() const
Returns the number of entries in the FileCollection.
FileEntry::vector_t m_entries
virtual ~FileCollection()
Make sure the resources are released.
virtual void close()
Close the current FileEntry of this FileCollection.
virtual void mustBeValid() const
Check whether the collection is valid.
FileCollection & operator=(FileCollection const &src)
Replace the content of a collection with a copy of another collection.
A FileEntry represents an entry in a FileCollection.
Definition: fileentry.hpp:75
Base class for various file collections.
void setLevel(size_t limit, FileEntry::CompressionLevel small_compression_level, FileEntry::CompressionLevel large_compression_level)
Change the compression level to the specified value.
Define the zipios::FileEntry class.
bool isValid() const
Check whether the current collection is valid.
std::shared_ptr< FileEntry > pointer_t
Definition: fileentry.hpp:78
void setMethod(size_t limit, StorageMethod small_storage_method, StorageMethod large_storage_method)
Change the storage method to the specified value.
std::vector< pointer_t > vector_t
Definition: fileentry.hpp:79