bit7z 4.0.0
A C++ library for interfacing with the 7-zip shared libs.
Loading...
Searching...
No Matches
bititemsvector.hpp
1/*
2 * bit7z - A C++ static library to interface with the 7-zip shared libraries.
3 * Copyright (c) 2014-2023 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 BITITEMSVECTOR_HPP
11#define BITITEMSVECTOR_HPP
12
13#include <map>
14#include <memory>
15
16#include "bitabstractarchivehandler.hpp"
17#include "bitfs.hpp"
18#include "bittypes.hpp"
19
20namespace bit7z {
21
22using std::vector;
23using std::map;
24using std::unique_ptr;
25
26namespace filesystem {
27class FilesystemItem;
28} // namespace filesystem
29
30using filesystem::FilesystemItem;
31
32struct GenericInputItem;
33using GenericInputItemPtr = std::unique_ptr< GenericInputItem >;
34using GenericInputItemVector = std::vector< GenericInputItemPtr >;
35
37struct IndexingOptions {
38 bool recursive = true;
39 bool retainFolderStructure = false;
40 bool onlyFiles = false;
41 bool followSymlinks = true;
42};
49class BitItemsVector final {
50 public:
52
53 BitItemsVector() = default;
54
55 BitItemsVector( const BitItemsVector& ) = default;
56
57 BitItemsVector( BitItemsVector&& ) = default;
58
59 auto operator=( const BitItemsVector& ) -> BitItemsVector& = default;
60
61 auto operator=( BitItemsVector&& ) -> BitItemsVector& = default;
62
73 void indexDirectory( const fs::path& inDir,
74 const tstring& filter = {},
76 IndexingOptions options = {} );
77
85 void indexPaths( const std::vector< tstring >& inPaths, IndexingOptions options = {} );
86
98 void indexPathsMap( const std::map< tstring, tstring >& inPaths, IndexingOptions options = {} );
99
109 void indexFile( const tstring& inFile, const tstring& name = {}, bool followSymlinks = true );
110
117 void indexBuffer( const std::vector< byte_t >& inBuffer, const tstring& name );
118
125 void indexStream( std::istream& inStream, const tstring& name );
126
130 BIT7Z_NODISCARD auto size() const -> std::size_t;
131
136 auto operator[]( GenericInputItemVector::size_type index ) const -> const GenericInputItem&;
137
142 BIT7Z_NODISCARD auto begin() const noexcept -> GenericInputItemVector::const_iterator;
143
148 BIT7Z_NODISCARD auto end() const noexcept -> GenericInputItemVector::const_iterator;
149
154 BIT7Z_NODISCARD auto cbegin() const noexcept -> GenericInputItemVector::const_iterator;
155
160 BIT7Z_NODISCARD auto cend() const noexcept -> GenericInputItemVector::const_iterator;
161
163
164 private:
166
167 void indexItem( const FilesystemItem& item, IndexingOptions options );
168};
169
170} // namespace bit7z
171
172#endif //BITITEMSVECTOR_HPP
The BitItemsVector class represents a vector of generic input items, i.e., items that can come from t...
Definition bititemsvector.hpp:49
auto cend() const noexcept -> GenericInputItemVector::const_iterator
auto end() const noexcept -> GenericInputItemVector::const_iterator
void indexBuffer(const std::vector< byte_t > &inBuffer, const tstring &name)
Indexes the given buffer, using the given name as a path when compressed in archives.
auto begin() const noexcept -> GenericInputItemVector::const_iterator
void indexFile(const tstring &inFile, const tstring &name={}, bool followSymlinks=true)
Indexes the given file path, with an optional user-defined path to be used in output archives.
void indexPathsMap(const std::map< tstring, tstring > &inPaths, IndexingOptions options={})
Indexes the given map of filesystem paths, adding to the vector all the files.
void indexStream(std::istream &inStream, const tstring &name)
Indexes the given standard input stream, using the given name as a path when compressed in archives.
void indexDirectory(const fs::path &inDir, const tstring &filter={}, FilterPolicy policy=FilterPolicy::Include, IndexingOptions options={})
Indexes the given directory, adding to the vector all the files that match the wildcard filter.
auto size() const -> std::size_t
void indexPaths(const std::vector< tstring > &inPaths, IndexingOptions options={})
Indexes the given vector of filesystem paths, adding to the item vector all the files.
auto cbegin() const noexcept -> GenericInputItemVector::const_iterator
The main namespace of the bit7z library.
Definition bit7zlibrary.hpp:30
FilterPolicy
Enumeration representing the policy according to which the archive handler should treat the items tha...
Definition bitabstractarchivehandler.hpp:66
@ Include
Extract/compress the items that match the pattern.