Instance state inspection methods.
More...
Instance state inspection methods.
Methods for querying the current lifecycle state.
◆ IsDatabaseLoaded()
| bool Recognition::Magic::IsDatabaseLoaded |
( |
| ) |
const |
|
nodiscardnoexcept |
Check if a magic database is loaded.
- Returns
- true if a database is loaded (instance in Valid state), false otherwise (Closed or Opened state).
- Lifecycle State Check
| State | Returns |
| Closed | false |
| Opened | false |
| Valid | true |
- See also
- Magic Core "Magic Lifecycle" for state diagram
-
LoadDatabaseFile()
-
IsOpen()
-
IsValid()
- Since
- 10.0.0
- Examples
- magic_examples.cpp.
◆ IsOpen()
| bool Recognition::Magic::IsOpen |
( |
| ) |
const |
|
nodiscardnoexcept |
Check if the Magic instance is open.
- Returns
- true if open (Opened or Valid state), false if Closed.
- Lifecycle State Check
| State | Returns |
| Closed | false |
| Opened | true |
| Valid | true |
- Note
- An open instance may still not be valid for identification if no database is loaded. Use IsValid() to check both.
- See also
- Magic Core "Magic Lifecycle" for state diagram
-
Open()
-
Close()
-
IsValid()
- Since
- 10.0.0
- Examples
- magic_examples.cpp.
◆ IsValid()
| bool Recognition::Magic::IsValid |
( |
| ) |
const |
|
nodiscardnoexcept |
Check if the Magic instance is valid for file identification.
An instance is valid if it is both open and has a database loaded, i.e., it is in the Valid state.
- Returns
- true if in Valid state (open and database loaded), false if in Closed or Opened state.
- Lifecycle State Check
| State | Returns |
| Closed | false |
| Opened | false |
| Valid | true |
}
Magic() noexcept
Default constructor. Creates an unopened Magic instance.
Definition magic.cpp:2421
FileTypeT IdentifyFile(const std::filesystem::path &path) const
Identify the type of a single file.
Definition magic.cpp:2530
@ Mime
Definition magic.hpp:328
bool IsValid() const noexcept
Check if the Magic instance is valid for file identification.
Definition magic.cpp:2633
- See also
- Magic Core "Magic Lifecycle" for state diagram
-
IsOpen()
-
IsDatabaseLoaded()
-
operator bool()
- Since
- 10.0.0
- Examples
- magic_examples.cpp.