Libmagicxx v5.1.1
A C++ wrapper library over the Magic Number Recognition Library.
Loading...
Searching...
No Matches
Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Static Private Attributes | Friends | List of all members
recognition::magic::magic_private Class Reference

Classes

struct  flags_converter
 
struct  libmagic_pair_converter
 

Public Member Functions

 magic_private () noexcept=default
 
 magic_private (flags_mask_t flags_mask, const std::filesystem::path &database_file)
 
 magic_private (const flags_container_t &flags_container, const std::filesystem::path &database_file)
 
 magic_private (magic_private &&) noexcept=default
 
 magic_private (const magic_private &)=delete
 
magic_privateoperator= (magic_private &&) noexcept=default
 
magic_privateoperator= (const magic_private &)=delete
 
 ~magic_private ()=default
 
bool check (const std::filesystem::path &database_file) const noexcept
 
void close () noexcept
 
bool compile (const std::filesystem::path &database_file) const noexcept
 
flags_container_t get_flags () const
 
std::size_t get_parameter (parameters parameter) const
 
parameter_value_map_t get_parameters () const
 
file_type_t identify_file (const std::filesystem::path &path) const
 
expected_file_type_t identify_file (const std::filesystem::path &path, std::nothrow_t) const noexcept
 
bool is_open () const noexcept
 
void load_database_file (const std::filesystem::path &database_file)
 
void open (flags_mask_t flags_mask)
 
void open (const flags_container_t &flags_container)
 
void set_flags (flags_mask_t flags_mask)
 
void set_flags (const flags_container_t &flags_container)
 
void set_parameter (parameters parameter, std::size_t value)
 
void set_parameters (const parameter_value_map_t &parameters)
 

Private Types

using cookie_t
 
using libmagic_value_t = int
 
using libmagic_value_name_t = std::string
 
using libmagic_pair_t = std::pair<libmagic_value_t, const char*>
 

Private Member Functions

template<std::derived_from< magic_exception > ExceptionType, typename ResultType , typename ... ExceptionArgs>
requires std::same_as<ResultType, int> || std::same_as<ResultType, bool>
void throw_exception_on_failure (ResultType result, ExceptionArgs &&...args) const
 Throws an ExceptionType exception with ExceptionArgs if the result is false or equal to libmagic_error.
 
std::string get_error_message () const noexcept
 

Private Attributes

cookie_t m_cookie {nullptr}
 
flags_mask_t m_flags_mask {0}
 

Static Private Attributes

static constexpr auto libmagic_error = -1
 
static constexpr auto libmagic_flags_count = flags_mask_t{}.size()
 
static constexpr auto libmagic_parameter_count = 9uz
 
static constexpr libmagic_pair_t libmagic_flag_none
 
static constexpr std::array< libmagic_pair_t, libmagic_flags_countlibmagic_flags
 
static constexpr std::array< libmagic_pair_t, libmagic_parameter_countlibmagic_parameters
 

Friends

std::string to_string (flags)
 Convert the magic::flags to string.
 
std::string to_string (parameters)
 Convert the magic::parameters to string.
 

Member Typedef Documentation

◆ cookie_t

Initial value:
std::unique_ptr<detail::magic_set, decltype(
[](detail::magic_t cookie) noexcept {
detail::magic_close(cookie);
}
)>

◆ libmagic_pair_t

◆ libmagic_value_name_t

◆ libmagic_value_t

Constructor & Destructor Documentation

◆ magic_private() [1/5]

recognition::magic::magic_private::magic_private ( )
defaultnoexcept

◆ magic_private() [2/5]

recognition::magic::magic_private::magic_private ( flags_mask_t flags_mask,
const std::filesystem::path & database_file )
inline

◆ magic_private() [3/5]

recognition::magic::magic_private::magic_private ( const flags_container_t & flags_container,
const std::filesystem::path & database_file )
inline

◆ magic_private() [4/5]

recognition::magic::magic_private::magic_private ( magic_private && )
defaultnoexcept

◆ magic_private() [5/5]

recognition::magic::magic_private::magic_private ( const magic_private & )
delete

◆ ~magic_private()

recognition::magic::magic_private::~magic_private ( )
default

Member Function Documentation

◆ check()

bool recognition::magic::magic_private::check ( const std::filesystem::path & database_file) const
inlinenoexcept

◆ close()

void recognition::magic::magic_private::close ( )
inlinenoexcept

◆ compile()

bool recognition::magic::magic_private::compile ( const std::filesystem::path & database_file) const
inlinenoexcept

◆ get_error_message()

std::string recognition::magic::magic_private::get_error_message ( ) const
inlineprivatenoexcept

◆ get_flags()

flags_container_t recognition::magic::magic_private::get_flags ( ) const
inline

◆ get_parameter()

std::size_t recognition::magic::magic_private::get_parameter ( parameters parameter) const
inline

◆ get_parameters()

parameter_value_map_t recognition::magic::magic_private::get_parameters ( ) const
inline

◆ identify_file() [1/2]

file_type_t recognition::magic::magic_private::identify_file ( const std::filesystem::path & path) const
inline

◆ identify_file() [2/2]

expected_file_type_t recognition::magic::magic_private::identify_file ( const std::filesystem::path & path,
std::nothrow_t  ) const
inlinenoexcept

◆ is_open()

bool recognition::magic::magic_private::is_open ( ) const
inlinenoexcept

◆ load_database_file()

void recognition::magic::magic_private::load_database_file ( const std::filesystem::path & database_file)
inline

◆ open() [1/2]

void recognition::magic::magic_private::open ( const flags_container_t & flags_container)
inline

◆ open() [2/2]

void recognition::magic::magic_private::open ( flags_mask_t flags_mask)
inline

◆ operator=() [1/2]

magic_private & recognition::magic::magic_private::operator= ( const magic_private & )
delete

◆ operator=() [2/2]

magic_private & recognition::magic::magic_private::operator= ( magic_private && )
defaultnoexcept

◆ set_flags() [1/2]

void recognition::magic::magic_private::set_flags ( const flags_container_t & flags_container)
inline

◆ set_flags() [2/2]

void recognition::magic::magic_private::set_flags ( flags_mask_t flags_mask)
inline

◆ set_parameter()

void recognition::magic::magic_private::set_parameter ( parameters parameter,
std::size_t value )
inline

◆ set_parameters()

void recognition::magic::magic_private::set_parameters ( const parameter_value_map_t & parameters)
inline

◆ throw_exception_on_failure()

template<std::derived_from< magic_exception > ExceptionType, typename ResultType , typename ... ExceptionArgs>
requires std::same_as<ResultType, int> || std::same_as<ResultType, bool>
void recognition::magic::magic_private::throw_exception_on_failure ( ResultType result,
ExceptionArgs &&... args ) const
inlineprivate

Throws an ExceptionType exception with ExceptionArgs if the result is false or equal to libmagic_error.

Friends And Related Symbol Documentation

◆ to_string [1/2]

std::string to_string ( magic::flags flag)
friend

Convert the magic::flags to string.

Parameters
[in]flagThe flag.
Returns
The flag as a string.

◆ to_string [2/2]

std::string to_string ( magic::parameters parameter)
friend

Convert the magic::parameters to string.

Parameters
[in]parameterThe parameter.
Returns
The parameter as a string.

Member Data Documentation

◆ libmagic_error

constexpr auto recognition::magic::magic_private::libmagic_error = -1
staticconstexprprivate

◆ libmagic_flag_none

constexpr libmagic_pair_t recognition::magic::magic_private::libmagic_flag_none
staticconstexprprivate
Initial value:
{
std::make_pair(MAGIC_NONE, "none")
}
#define MAGIC_NONE
Definition magic.h:32

◆ libmagic_flags

constexpr std::array<libmagic_pair_t, libmagic_flags_count> recognition::magic::magic_private::libmagic_flags
staticconstexprprivate

◆ libmagic_flags_count

constexpr auto recognition::magic::magic_private::libmagic_flags_count = flags_mask_t{}.size()
staticconstexprprivate

◆ libmagic_parameter_count

constexpr auto recognition::magic::magic_private::libmagic_parameter_count = 9uz
staticconstexprprivate

◆ libmagic_parameters

constexpr std::array<libmagic_pair_t, libmagic_parameter_count> recognition::magic::magic_private::libmagic_parameters
staticconstexprprivate
Initial value:
{
std::make_pair(MAGIC_PARAM_INDIR_MAX, "indir_max"),
std::make_pair(MAGIC_PARAM_NAME_MAX, "name_max"),
std::make_pair(MAGIC_PARAM_ELF_PHNUM_MAX, "elf_phnum_max"),
std::make_pair(MAGIC_PARAM_ELF_SHNUM_MAX, "elf_shnum_max"),
std::make_pair(MAGIC_PARAM_ELF_NOTES_MAX, "elf_notes_max"),
std::make_pair(MAGIC_PARAM_REGEX_MAX, "regex_max"),
std::make_pair(MAGIC_PARAM_BYTES_MAX, "bytes_max"),
std::make_pair(MAGIC_PARAM_ENCODING_MAX, "encoding_max"),
std::make_pair(MAGIC_PARAM_ELF_SHSIZE_MAX, "elf_shsize_max")
}
#define MAGIC_PARAM_INDIR_MAX
Definition magic.h:146
#define MAGIC_PARAM_ELF_NOTES_MAX
Definition magic.h:150
#define MAGIC_PARAM_BYTES_MAX
Definition magic.h:152
#define MAGIC_PARAM_NAME_MAX
Definition magic.h:147
#define MAGIC_PARAM_ELF_SHNUM_MAX
Definition magic.h:149
#define MAGIC_PARAM_ENCODING_MAX
Definition magic.h:153
#define MAGIC_PARAM_ELF_SHSIZE_MAX
Definition magic.h:154
#define MAGIC_PARAM_REGEX_MAX
Definition magic.h:151
#define MAGIC_PARAM_ELF_PHNUM_MAX
Definition magic.h:148

◆ m_cookie

cookie_t recognition::magic::magic_private::m_cookie {nullptr}
private

◆ m_flags_mask

flags_mask_t recognition::magic::magic_private::m_flags_mask {0}
private

The documentation for this class was generated from the following file: