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

Parameter retrieval methods. More...

Collaboration diagram for Parameter Management:

Functions

std::size_t Recognition::Magic::GetParameter (Parameters parameter) const
 Get the value of a specific parameter.
std::optional< std::size_t > Recognition::Magic::GetParameter (Parameters parameter, const std::nothrow_t &tag) const noexcept
 Get the value of a specific parameter (noexcept version).
ParameterValueMapT Recognition::Magic::GetParameters () const
 Get all parameter values.
std::optional< ParameterValueMapTRecognition::Magic::GetParameters (const std::nothrow_t &tag) const noexcept
 Get all parameter values (noexcept version).

Detailed Description

Parameter retrieval methods.

Methods for querying libmagic parameter values.

Function Documentation

◆ GetParameter() [1/2]

std::size_t Recognition::Magic::GetParameter ( Magic::Parameters parameter) const
nodiscard

Get the value of a specific parameter.

Retrieves the current value of the specified parameter.

Parameters
[in]parameterThe parameter to query.
Returns
Current value of the parameter.
Exceptions
MagicIsClosedIf the Magic instance is closed.
auto maxBytes = magic.GetParameter(Magic::Parameters::BytesMax);
std::println("Maximum bytes to scan: {}", maxBytes);
@ BytesMax
Definition magic.hpp:389
See also
Parameters for available parameters
SetParameter()
Since
10.0.0
Examples
magic_examples.cpp.

◆ GetParameter() [2/2]

std::optional< std::size_t > Recognition::Magic::GetParameter ( Parameters parameter,
const std::nothrow_t & tag ) const
nodiscardnoexcept

Get the value of a specific parameter (noexcept version).

Parameters
[in]parameterThe parameter to query.
[in]tagPass std::nothrow to select this overload.
Returns
Current value of the parameter, or std::nullopt if closed.
Since
10.0.0

◆ GetParameters() [1/2]

Magic::ParameterValueMapT Recognition::Magic::GetParameters ( ) const
nodiscard

Get all parameter values.

Retrieves a map of all parameters and their current values.

Returns
Map from Parameters enum values to their current values.
Exceptions
MagicIsClosedIf the Magic instance is closed.
auto params = magic.GetParameters();
for (const auto& [param, value] : params) {
std::println("{}: {}", ToString(param), value);
}
friend std::string ToString(Flags)
Friend declaration for ToString(Flags) free function.
Definition magic.cpp:2355
See also
ParameterValueMapT
SetParameters()
Since
10.0.0
Examples
magic_examples.cpp.

◆ GetParameters() [2/2]

std::optional< Magic::ParameterValueMapT > Recognition::Magic::GetParameters ( const std::nothrow_t & tag) const
nodiscardnoexcept

Get all parameter values (noexcept version).

Parameters
[in]tagPass std::nothrow to select this overload.
Returns
Map from Parameters to values, or std::nullopt if closed.
Since
10.0.0