bit7z 4.0.0
A C++ library for interfacing with the 7-zip shared libs.
Loading...
Searching...
No Matches
bit7zlibrary.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 BIT7ZLIBRARY_HPP
11#define BIT7ZLIBRARY_HPP
12
13#include <string>
14
15#include "bitformat.hpp"
16#include "bittypes.hpp"
17#include "bitwindows.hpp"
18
20struct IInArchive;
21struct IOutArchive;
22
23template< typename T >
24class CMyComPtr;
26
30namespace bit7z {
31
43#ifdef __DOXYGEN__
44constexpr auto kDefaultLibrary = "<platform-dependent value>";
45#elif defined( _WIN32 )
46constexpr auto kDefaultLibrary = BIT7Z_STRING( "7z.dll" );
47#elif defined( __linux__ )
48constexpr auto kDefaultLibrary = "/usr/lib/p7zip/7z.so"; // Default installation path of the p7zip shared library.
49#else
50constexpr auto kDefaultLibrary = "./7z.so";
51#endif
52
56class Bit7zLibrary final {
57 public:
58 Bit7zLibrary( const Bit7zLibrary& ) = delete;
59
60 Bit7zLibrary( Bit7zLibrary&& ) = delete;
61
62 auto operator=( const Bit7zLibrary& ) -> Bit7zLibrary& = delete;
63
64 auto operator=( Bit7zLibrary&& ) -> Bit7zLibrary& = delete;
65
73 explicit Bit7zLibrary( const tstring& libraryPath = kDefaultLibrary );
74
79
84
85 private:
86 HMODULE mLibrary;
87 FARPROC mCreateObjectFunc;
88
89 BIT7Z_NODISCARD
90 auto initInArchive( const BitInFormat& format ) const -> CMyComPtr< IInArchive >;
91
92 BIT7Z_NODISCARD
93 auto initOutArchive( const BitInOutFormat& format ) const -> CMyComPtr< IOutArchive >;
94
95 friend class BitInputArchive;
96 friend class BitOutputArchive;
97};
98
99} // namespace bit7z
100
101#endif // BIT7ZLIBRARY_HPP
The Bit7zLibrary class allows accessing the basic functionalities provided by the 7z DLLs.
Definition bit7zlibrary.hpp:56
~Bit7zLibrary()
Destructs the Bit7zLibrary object, freeing the loaded shared library.
void setLargePageMode()
Set the 7-zip shared library to use large memory pages.
Bit7zLibrary(const tstring &libraryPath=kDefaultLibrary)
Constructs a Bit7zLibrary object by loading the specified 7zip shared library.
The BitInFormat class specifies an extractable archive format.
Definition bitformat.hpp:58
The BitInOutFormat class specifies a format available for creating new archives and extract old ones.
Definition bitformat.hpp:105
The BitInputArchive class, given a handler object, allows reading/extracting the content of archives.
Definition bitinputarchive.hpp:31
The BitOutputArchive class, given a creator object, allows creating new archives.
Definition bitoutputarchive.hpp:60
The main namespace of the bit7z library.
Definition bit7zlibrary.hpp:30
constexpr auto kDefaultLibrary
The default file path for the 7-zip shared library to be used by bit7z in case the user doesn't pass ...
Definition bit7zlibrary.hpp:44