Libmagicxx v10.0.3
A modern C++23 wrapper for libmagic — the library that powers the Unix file command.
Loading...
Searching...
No Matches

Instance state inspection methods. More...

Collaboration diagram for State Queries:

Functions

bool Recognition::Magic::MagicPrivate::IsDatabaseLoaded () const noexcept
 Check if a database is loaded.
bool Recognition::Magic::MagicPrivate::IsOpen () const noexcept
 Check if instance is open.
bool Recognition::Magic::MagicPrivate::IsValid () const noexcept
 Check if instance is valid for file identification.

Detailed Description

Instance state inspection methods.

Methods for querying the current lifecycle state.

Function Documentation

◆ IsDatabaseLoaded()

bool Recognition::Magic::MagicPrivate::IsDatabaseLoaded ( ) const
inlinenodiscardnoexcept

Check if a database is loaded.

Returns the state of the m_is_database_loaded flag, which is set to true only after a successful LoadDatabaseFile() call.

Returns
true if database is loaded (Valid state possible), false if not loaded (Closed or Opened state).
State Indicator
This is one of two flags that determine the lifecycle state:
  • IsOpen() returns true → Opened or Valid
  • IsDatabaseLoaded() returns true → Valid (when also open)
See also
Magic::IsDatabaseLoaded()
IsOpen()
IsValid()
LoadDatabaseFile()

◆ IsOpen()

bool Recognition::Magic::MagicPrivate::IsOpen ( ) const
inlinenodiscardnoexcept

Check if instance is open.

Returns whether the libmagic cookie has been allocated. A non-null cookie indicates the instance is at least in the Opened state.

Returns
true if cookie is allocated (Opened or Valid state), false if cookie is null (Closed state).
Implementation
return m_cookie != nullptr;
CookieT m_cookie
Definition magic.cpp:1920
See also
Magic::IsOpen()
Open()
IsValid()
CookieT

◆ IsValid()

bool Recognition::Magic::MagicPrivate::IsValid ( ) const
inlinenodiscardnoexcept

Check if instance is valid for file identification.

An instance is Valid when both conditions are met:

  • Cookie is allocated (IsOpen() returns true)
  • Database is loaded (IsDatabaseLoaded() returns true)
Returns
true if ready for file identification (Valid state), false otherwise (Closed or Opened state).
Implementation
return IsOpen() && IsDatabaseLoaded();
bool IsOpen() const noexcept
Check if instance is open.
Definition magic.cpp:1285
bool IsDatabaseLoaded() const noexcept
Check if a database is loaded.
Definition magic.cpp:1260
See also
Magic::IsValid()
Magic::operator bool()
IsOpen()
IsDatabaseLoaded()