bit7z 4.1.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) 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 "bitdefines.hpp"
14#include "bitformat.hpp"
15#include "bitsharedlibrary.hpp"
16#include "bittypes.hpp"
17
19struct IInArchive;
20struct IOutArchive;
21
22template< typename T >
23class CMyComPtr;
25
29namespace bit7z {
30
42#ifdef __DOXYGEN__
43constexpr auto kDefaultLibrary = "<platform-dependent value>";
44#elif defined( _WIN32 )
45constexpr auto kDefaultLibrary = BIT7Z_STRING( "7z.dll" );
46#elif defined( __linux__ )
47constexpr auto kDefaultLibrary = "/usr/lib/p7zip/7z.so"; // Default installation path of the p7zip shared library.
48#else
49constexpr auto kDefaultLibrary = "./7z.so";
50#endif
51
55class Bit7zLibrary final {
56 public:
57 Bit7zLibrary( const Bit7zLibrary& ) = delete;
58
59 Bit7zLibrary( Bit7zLibrary&& ) = delete;
60
61 auto operator=( const Bit7zLibrary& ) -> Bit7zLibrary& = delete;
62
63 auto operator=( Bit7zLibrary&& ) -> Bit7zLibrary& = delete;
64
72 explicit Bit7zLibrary( const tstring& libraryPath = kDefaultLibrary );
73
77 ~Bit7zLibrary() = default;
78
84 BIT7Z_DEPRECATED_MSG( "Since v4.1. Please use the useLargePages() method." )
86
90 void useLargePages() const;
91
92 private:
93 BitSharedLibrary mLibrary;
94 LibrarySymbol mCreateObjectFunc;
95
96 BIT7Z_NODISCARD
97 auto initInArchive( const BitInFormat& format ) const -> CMyComPtr< IInArchive >;
98
99 BIT7Z_NODISCARD
100 auto initOutArchive( const BitInOutFormat& format ) const -> CMyComPtr< IOutArchive >;
101
102 friend class BitInputArchive;
103 friend class BitOutputArchive;
104};
105
106} // namespace bit7z
107
108#endif // BIT7ZLIBRARY_HPP
~Bit7zLibrary()=default
Destructs the Bit7zLibrary object, freeing the loaded shared library.
void setLargePageMode()
Set the 7-zip shared library to use large memory pages.
void useLargePages() const
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:68
The BitInOutFormat class specifies a format available for creating new archives and extract old ones.
Definition bitformat.hpp:115
The main namespace of the bit7z library.
Definition bit7zlibrary.hpp:29
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:43
std::basic_string< tchar > tstring
Definition bittypes.hpp:104