zipios 2.3.4
Zipios -- a small C++ library providing 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-2022 Made to Order Software Corp. All Rights Reserved
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
36namespace zipios
37{
38
39
41{
42public:
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 = std::string());
54 FileCollection(FileCollection const & rhs);
55 virtual pointer_t clone() const = 0;
56 virtual ~FileCollection();
57
59
60 virtual void addEntry(FileEntry const & entry);
61 virtual void close();
62 virtual FileEntry::vector_t entries() const;
63 virtual FileEntry::pointer_t getEntry(std::string const & name, MatchPath matchpath = MatchPath::MATCH) const;
64 virtual stream_pointer_t getInputStream(std::string const & entry_name, MatchPath matchpath = MatchPath::MATCH) = 0;
65 virtual std::string getName() const;
66 virtual size_t size() const;
67 bool isValid() const;
68 virtual void mustBeValid() const;
69 void setMethod(size_t limit, StorageMethod small_storage_method, StorageMethod large_storage_method);
70 void setLevel(size_t limit, FileEntry::CompressionLevel small_compression_level, FileEntry::CompressionLevel large_compression_level);
71
72protected:
73 std::string m_filename = std::string();
75 bool m_valid = true;
76};
77
78
79std::ostream & operator << (std::ostream & os, FileCollection const & collection);
80
81
82} // zipios namespace
83
84// Local Variables:
85// mode: cpp
86// indent-tabs-mode: nil
87// c-basic-offset: 4
88// tab-width: 4
89// End:
90
91// vim: ts=4 sw=4 et
92#endif
Base class for various file collections.
virtual FileEntry::pointer_t getEntry(std::string const &name, MatchPath matchpath=MatchPath::MATCH) const
Get an entry from this collection.
virtual void addEntry(FileEntry const &entry)
Add an entry to this collection.
bool isValid() const
Check whether the current collection is valid.
std::shared_ptr< FileCollection > pointer_t
virtual void mustBeValid() const
Check whether the collection is valid.
virtual stream_pointer_t getInputStream(std::string const &entry_name, MatchPath matchpath=MatchPath::MATCH)=0
Retrieve pointer to an istream.
std::shared_ptr< std::istream > stream_pointer_t
A shared pointer to an input stream.
virtual size_t size() const
Returns the number of entries in the FileCollection.
virtual ~FileCollection()
Make sure the resources are released.
std::vector< pointer_t > vector_t
void setMethod(size_t limit, StorageMethod small_storage_method, StorageMethod large_storage_method)
Change the storage method to the specified value.
virtual std::string getName() const
Returns the name of the FileCollection.
virtual void close()
Close the current FileEntry of this FileCollection.
FileEntry::vector_t m_entries
virtual pointer_t clone() const =0
Create a clone of this object.
FileCollection & operator=(FileCollection const &rhs)
Replace the content of a collection with a copy of another collection.
virtual FileEntry::vector_t entries() const
Retrieve the array of entries.
void setLevel(size_t limit, FileEntry::CompressionLevel small_compression_level, FileEntry::CompressionLevel large_compression_level)
Change the compression level to the specified value.
A FileEntry represents an entry in a FileCollection.
Definition fileentry.hpp:76
std::shared_ptr< FileEntry > pointer_t
Definition fileentry.hpp:78
int CompressionLevel
The compression level to be used to save an entry.
Definition fileentry.hpp:85
std::vector< pointer_t > vector_t
Definition fileentry.hpp:79
Define the zipios::FileEntry class.
The zipios namespace includes the Zipios library definitions.
std::ostream & operator<<(std::ostream &os, FileCollection const &collection)
Write a FileCollection to the output stream.
StorageMethod
The types used with FileEntry::setMethod and FileEntry::getMethod.
Definition fileentry.hpp:49