|
Libmagicxx v10.0.3
A modern C++23 wrapper for libmagic — the library that powers the Unix file command.
|
Implementation of the Magic class and supporting utilities. More...

Classes | |
| class | Recognition::Magic::MagicPrivate |
| PIMPL implementation class for Magic. More... | |
| struct | Recognition::Magic::MagicPrivate::FlagsConverter |
| Converter between C++ flag types and libmagic flag values. More... | |
| struct | Recognition::Magic::MagicPrivate::LibmagicPairConverter |
| Extracts values from libmagic constant pairs. More... | |
Namespaces | |
| namespace | Recognition |
| Root namespace for the libmagicxx library. | |
| namespace | Recognition::Detail |
| Internal namespace for libmagic C library integration. | |
Functions | |
| std::string | Recognition::ToString (const Magic::FileTypeEntryT &file_type_entry, const std::string &type_separator=" -> ") |
| Convert a file type entry to a string. | |
| std::string | Recognition::ToString (const Magic::FileTypeMapT &file_type_map, const std::string &type_separator=" -> ", const std::string &file_separator="\n") |
| Convert a file type map to a string. | |
| std::string | Recognition::ToString (const Magic::ExpectedFileTypeT &expected_file_type) |
| Convert an expected file type result to a string. | |
| std::string | Recognition::ToString (const Magic::ExpectedFileTypeEntryT &expected_file_type_entry, const std::string &type_separator=" -> ") |
| Convert an expected file type entry to a string. | |
| std::string | Recognition::ToString (const Magic::ExpectedFileTypeMapT &expected_file_type_map, const std::string &type_separator=" -> ", const std::string &file_separator="\n") |
| Convert an expected file type map to a string. | |
| std::string | Recognition::ToString (Magic::Flags flag) |
| Convert a Magic flag to its string name. | |
| std::string | Recognition::ToString (const Magic::FlagsContainerT &flags, const std::string &separator=", ") |
| Convert a container of flags to a string. | |
| std::string | Recognition::ToString (Magic::Parameters parameter) |
| Convert a Magic parameter to its string name. | |
| std::string | Recognition::ToString (const Magic::ParameterValueT ¶meter_value, const std::string &value_separator=": ") |
| Convert a parameter-value pair to a string. | |
| std::string | Recognition::ToString (const Magic::ParameterValueMapT ¶meters, const std::string &value_separator=": ", const std::string ¶meter_separator=", ") |
| Convert a parameter-value map to a string. | |
Implementation of the Magic class and supporting utilities.
This file contains the complete implementation of the libmagicxx library, including:
The implementation uses the PIMPL (Pointer to IMPLementation) idiom to:
The underlying libmagic C library is wrapped in the Detail namespace to isolate its symbols. All libmagic calls go through MagicPrivate, which:
| Component | Purpose |
|---|---|
| Detail::magic_* | Wrapped libmagic C functions |
| MagicPrivate | PIMPL class holding cookie and state |
| MagicPrivate::FlagsConverter | Converts between flag representations |
| MagicPrivate::LibmagicPairConverter | Extracts values from flag/param pairs |
| MagicPrivate::ThrowExceptionOnFailure | Error handling template |
| ToString() overloads | String conversion utilities |
The three-state lifecycle (Closed -> Opened -> Valid) is tracked by: