bit7z 4.1.0
A C++ library for interfacing with the 7-zip shared libs.
Loading...
Searching...
No Matches
bitnestedarchivereader.hpp
1/*
2 * bit7z - A C++ static library to interface with the 7-zip shared libraries.
3 * Copyright (c) Riccardo Ostani - All Rights Reserved.
4 *
5 * This Source Code Form is subject to the terms of the Mozilla Public
6 * License, v. 2.0. If a copy of the MPL was not distributed with this
7 * file, You can obtain one at https://mozilla.org/MPL/2.0/.
8 */
9
10#ifndef BITNESTEDARCHIVEREADER_HPP
11#define BITNESTEDARCHIVEREADER_HPP
12
13#include "bitabstractarchiveopener.hpp"
14#include "bitarchiveiteminfo.hpp"
15#include "bitinputarchive.hpp"
16
17namespace bit7z {
18
23class BitNestedArchiveReader final : public BitAbstractArchiveOpener {
24 public:
40 const Bit7zLibrary& lib,
41 const BitInputArchive& parentArchive,
42 std::uint32_t index,
43 const BitInFormat& format,
44 const tstring& password = {}
45 );
46
61 const Bit7zLibrary& lib,
62 const BitInputArchive& parentArchive,
63 const BitInFormat& format,
64 const tstring& password = {}
65 );
66
70 BIT7Z_NODISCARD
71 auto maxMemoryUsage() const noexcept -> std::uint64_t;
72
76 BIT7Z_NODISCARD
77 auto detectedFormat() const noexcept -> const BitInFormat&;
78
86 BIT7Z_NODISCARD
87 auto archiveProperty( BitProperty property ) const -> BitPropVariant;
88
98 BIT7Z_NODISCARD
99 auto itemProperty( std::uint32_t index, BitProperty property ) const -> BitPropVariant;
100
104 BIT7Z_NODISCARD
105 auto itemsCount() const -> std::uint32_t;
106
110 BIT7Z_NODISCARD
111 auto items() const -> std::vector< BitArchiveItemInfo >;
112
118 void extractTo( const tstring& outDir ) const;
119
126 void extractTo( std::map< tstring, buffer_t >& outMap ) const;
127
133 void test() const;
134
138 BIT7Z_NODISCARD
139 auto openCount() const -> std::size_t;
140
146 void setMaxMemoryUsage( std::uint64_t value ) noexcept;
147
148 private:
149 BitInputArchive mNestedArchive;
150 const BitInputArchive& mParentArchive;
151 std::uint32_t mIndexInParent;
152 std::uint64_t mMaxMemoryUsage;
153
154 mutable std::uint32_t mCachedItemsCount;
155 mutable std::uint32_t mLastReadItem; // TODO: Use std::optional< std::uint32_t > once we move to C++17
156 mutable std::size_t mOpenCount;
157
158 void openSequentially() const;
159
160 BIT7Z_NODISCARD
161 auto needReopen( std::uint32_t index = 0 ) const -> bool;
162
163 BIT7Z_NODISCARD
164 auto calculateItemsCount() const -> std::uint32_t;
165};
166
167} // namespace bit7z
168
169#endif //BITNESTEDARCHIVEREADER_HPP
The Bit7zLibrary class allows accessing the basic functionalities provided by the 7z DLLs.
Definition bit7zlibrary.hpp:55
auto password() const -> const tstring &
auto format() const noexcept -> const BitInFormat &override
The BitArchiveItemInfo class represents an archived item and that stores all its properties for later...
Definition bitarchiveiteminfo.hpp:26
The BitInFormat class specifies an extractable archive format.
Definition bitformat.hpp:68
The BitInputArchive class, given a handler object, allows reading/extracting the content of archives.
Definition bitinputarchive.hpp:64
auto itemProperty(std::uint32_t index, BitProperty property) const -> BitPropVariant
Gets the specified property of an item in the archive.
void test() const
Tests the archive without extracting its content.
BitNestedArchiveReader(const Bit7zLibrary &lib, const BitInputArchive &parentArchive, const BitInFormat &format, const tstring &password={})
Constructs a BitNestedArchiveReader object of the first item in the parent archive.
void setMaxMemoryUsage(std::uint64_t value) noexcept
Sets the max memory usage limit to be used while extracting the parent archive.
auto itemsCount() const -> std::uint32_t
void extractTo(const tstring &outDir) const
Extracts the archive to the chosen directory.
auto items() const -> std::vector< BitArchiveItemInfo >
auto maxMemoryUsage() const noexcept -> std::uint64_t
auto detectedFormat() const noexcept -> const BitInFormat &
BitNestedArchiveReader(const Bit7zLibrary &lib, const BitInputArchive &parentArchive, std::uint32_t index, const BitInFormat &format, const tstring &password={})
Constructs a BitNestedArchiveReader object.
auto archiveProperty(BitProperty property) const -> BitPropVariant
Gets the specified archive property.
auto openCount() const -> std::size_t
The main namespace of the bit7z library.
Definition bit7zlibrary.hpp:29
BitProperty
The BitProperty enum represents the archive/item properties that 7-zip can read or write.
Definition bitpropvariant.hpp:32
std::basic_string< tchar > tstring
Definition bittypes.hpp:104
The BitPropVariant struct is a light extension to the WinAPI PROPVARIANT struct providing useful gett...
Definition bitpropvariant.hpp:161