MagicPrivate construction methods.
More...
MagicPrivate construction methods.
Constructors for creating MagicPrivate instances in various initial states (closed, opened, or valid).
◆ MagicPrivate() [1/5]
| Recognition::Magic::MagicPrivate::MagicPrivate |
( |
| ) |
|
|
defaultnoexcept |
Default constructor creates a closed instance.
Creates a MagicPrivate in the Closed state with:
- m_cookie = nullptr
- m_flags_mask = 0
- m_is_database_loaded = false
- Lifecycle State
- After construction: Closed
- See also
- Open() to transition to Opened state
◆ MagicPrivate() [2/5]
| Recognition::Magic::MagicPrivate::MagicPrivate |
( |
const FlagsContainerT & | flags_container, |
|
|
const std::filesystem::path & | database_file ) |
|
inline |
Construct with flags container (throwing version).
Alternative constructor accepting a container of individual Flags values instead of a bitmask.
- Parameters
-
| [in] | flags_container | Container (vector) of Flags enum values. |
| [in] | database_file | Path to magic database file to load. |
- Exceptions
-
| MagicOpenError | If magic_open() fails. |
| EmptyPath | If database_file is empty. |
| PathDoesNotExist | If database_file does not exist. |
| PathIsNotRegularFile | If database_file is not a regular file. |
| MagicLoadDatabaseFileError | If magic_load() fails. |
- Lifecycle Transition
- Closed → Opened → Valid
- Usage Example
PIMPL implementation class for Magic.
Definition magic.cpp:222
std::vector< Flags > FlagsContainerT
Container type holding a collection of Magic::Flags.
Definition magic.hpp:401
@ Mime
Definition magic.hpp:328
@ Compress
Definition magic.hpp:319
- See also
- Magic::Magic(const FlagsContainerT&, const std::filesystem::path&)
◆ MagicPrivate() [3/5]
| Recognition::Magic::MagicPrivate::MagicPrivate |
( |
const FlagsContainerT & | flags_container, |
|
|
const std::nothrow_t & | tag, |
|
|
const std::filesystem::path & | database_file ) |
|
inlinenoexcept |
Construct with flags container (noexcept version).
Non-throwing variant accepting a container of Flags values. Silently fails if initialization encounters errors.
- Parameters
-
| [in] | flags_container | Container (vector) of Flags enum values. |
| [in] | tag | Pass std::nothrow to select this overload. |
| [in] | database_file | Path to magic database file to load. |
- Lifecycle State
- After construction:
- Valid if both Open() and LoadDatabaseFile() succeed
- Opened if only Open() succeeds
- Closed if Open() fails
- Note
- Check IsValid() after construction to verify success.
- See also
- Magic::Magic(const FlagsContainerT&, const std::nothrow_t&, const std::filesystem::path&)
◆ MagicPrivate() [4/5]
| Recognition::Magic::MagicPrivate::MagicPrivate |
( |
FlagsMaskT | flags_mask, |
|
|
const std::filesystem::path & | database_file ) |
|
inline |
Construct and initialize with flags (throwing version).
Creates a MagicPrivate, opens it with the specified flags, and loads the magic database file in a single step.
- Parameters
-
| [in] | flags_mask | Configuration flags as a bitmask. |
| [in] | database_file | Path to magic database file to load. |
- Exceptions
-
| MagicOpenError | If magic_open() fails. |
| EmptyPath | If database_file is empty. |
| PathDoesNotExist | If database_file does not exist. |
| PathIsNotRegularFile | If database_file is not a regular file. |
| MagicLoadDatabaseFileError | If magic_load() fails. |
- Lifecycle Transition
- Closed → Opened → Valid
- Implementation
void LoadDatabaseFile(const std::filesystem::path &database_file)
Load a magic database file (throwing version).
Definition magic.cpp:1356
void Open(FlagsMaskT flags_mask)
Open the magic instance with flags (throwing version).
Definition magic.cpp:1468
- See also
- Magic::Magic(FlagsMaskT, const std::filesystem::path&)
◆ MagicPrivate() [5/5]
| Recognition::Magic::MagicPrivate::MagicPrivate |
( |
FlagsMaskT | flags_mask, |
|
|
const std::nothrow_t & | tag, |
|
|
const std::filesystem::path & | database_file ) |
|
inlinenoexcept |
Construct and initialize with flags (noexcept version).
Non-throwing variant that silently fails on errors. The short-circuit evaluation ensures LoadDatabaseFile() is only called if Open() succeeds.
- Parameters
-
| [in] | flags_mask | Configuration flags as a bitmask. |
| [in] | tag | Pass std::nothrow to select this overload. |
| [in] | database_file | Path to magic database file to load. |
- Lifecycle State
- After construction:
- Valid if both Open() and LoadDatabaseFile() succeed
- Opened if only Open() succeeds
- Closed if Open() fails
- Implementation
- Uses short-circuit && to ensure proper sequencing:
Open(flags_mask, std::nothrow)
- Note
- Check IsValid() after construction to verify success.
- See also
- Magic::Magic(FlagsMaskT, const std::nothrow_t&, const std::filesystem::path&)