bit7z 4.1.0
A C++ library for interfacing with the 7-zip shared libs.
Loading...
Searching...
No Matches
Bit7zLibraryLoader Class Referencefinal

The Bit7zLibraryLoader class provides deferred and optional loading of the 7-zip shared library. More...

#include <bit7z/bit7zlibraryloader.hpp>

Collaboration diagram for Bit7zLibraryLoader:

Public Member Functions

 Bit7zLibraryLoader () noexcept
 Constructs an empty Bit7zLibraryLoader without loading any library.
 Bit7zLibraryLoader (const tstring &libraryPath)
 Constructs a Bit7zLibraryLoader and immediately loads the specified 7-zip shared library.
 ~Bit7zLibraryLoader ()
 Destructs the Bit7zLibraryLoader, unloading the library if it was loaded.
auto isLoaded () const noexcept -> bool
 Checks whether a 7-zip shared library is currently loaded.
auto library () const -> const Bit7zLibrary &
 Returns a reference to the loaded Bit7zLibrary.
void load (const tstring &libraryPath)
 Loads the specified 7-zip shared library.
void load (const tstring &libraryPath, std::error_code &ec) noexcept
 Loads the specified 7-zip shared library (non-throwing overload).
 operator const Bit7zLibrary & () const
 Implicitly converts to the loaded Bit7zLibrary reference.
auto operator-> () const -> const Bit7zLibrary *
 Provides pointer-like access to the loaded Bit7zLibrary.
void unload () noexcept
 Unloads the currently loaded library, if any.

Detailed Description

The Bit7zLibraryLoader class provides deferred and optional loading of the 7-zip shared library.

Unlike Bit7zLibrary, which loads the shared library in its constructor, Bit7zLibraryLoader allows constructing an empty loader and loading the library at a later time. It also supports unloading and reloading the library, as well as non-throwing error handling.

Once loaded, the underlying Bit7zLibrary can be accessed via the library() method, the arrow operator, or implicit conversion.

Constructor & Destructor Documentation

◆ Bit7zLibraryLoader() [1/2]

Bit7zLibraryLoader ( )
noexcept

Constructs an empty Bit7zLibraryLoader without loading any library.

◆ Bit7zLibraryLoader() [2/2]

Bit7zLibraryLoader ( const tstring & libraryPath)
explicit

Constructs a Bit7zLibraryLoader and immediately loads the specified 7-zip shared library.

Parameters
libraryPaththe path to the 7-zip shared library to be loaded.

◆ ~Bit7zLibraryLoader()

Destructs the Bit7zLibraryLoader, unloading the library if it was loaded.

Member Function Documentation

◆ isLoaded()

auto isLoaded ( ) const -> bool
noexcept

Checks whether a 7-zip shared library is currently loaded.

Returns
true if a library is loaded, false otherwise.

◆ library()

auto library ( ) const -> const Bit7zLibrary &

Returns a reference to the loaded Bit7zLibrary.

Exceptions
BitExceptionif no library is currently loaded.
Returns
a const reference to the underlying Bit7zLibrary.

◆ load() [1/2]

void load ( const tstring & libraryPath)

Loads the specified 7-zip shared library.

If a library is already loaded, it is unloaded first.

Note
A failed load leaves the loader in an unloaded state even if it was previously loaded.
Parameters
libraryPaththe path to the 7-zip shared library to be loaded.

◆ load() [2/2]

void load ( const tstring & libraryPath,
std::error_code & ec )
noexcept

Loads the specified 7-zip shared library (non-throwing overload).

If a library is already loaded, it is unloaded first.

Note
A failed load leaves the loader in an unloaded state even if it was previously loaded.
Parameters
libraryPaththe path to the 7-zip shared library to be loaded.
ecan output error code indicating the result of the operation.

◆ operator const Bit7zLibrary &()

operator const Bit7zLibrary & ( ) const

Implicitly converts to the loaded Bit7zLibrary reference.

This allows passing a Bit7zLibraryLoader directly where a Bit7zLibrary reference is expected.

Exceptions
BitExceptionif no library is currently loaded.

◆ operator->()

auto operator-> ( ) const -> const Bit7zLibrary *

Provides pointer-like access to the loaded Bit7zLibrary.

Exceptions
BitExceptionif no library is currently loaded.
Returns
a pointer to the underlying Bit7zLibrary.

◆ unload()

void unload ( )
noexcept

Unloads the currently loaded library, if any.


The documentation for this class was generated from the following file: