Free functions for converting Magic types to human-readable strings.
More...
|
| 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.
|
Free functions for converting Magic types to human-readable strings.
These functions provide convenient string representations of Magic's result types for logging, debugging, and display purposes.
◆ ToString() [1/10]
| std::string Recognition::ToString |
( |
const Magic::ExpectedFileTypeEntryT & | expected_file_type_entry, |
|
|
const std::string & | type_separator = " -> " ) |
|
nodiscard |
Convert an expected file type entry to a string.
Formats a file path and its expected result (type or error) as a string.
- Parameters
-
| [in] | expected_file_type_entry | The file path and expected result pair. |
| [in] | type_separator | Separator between path and result (default: " -> "). |
- Returns
- Formatted string: "path -> type" or "path -> [error message]".
- See also
- Magic::ExpectedFileTypeEntryT
- Since
- 10.0.0
◆ ToString() [2/10]
| std::string Recognition::ToString |
( |
const Magic::ExpectedFileTypeMapT & | expected_file_type_map, |
|
|
const std::string & | type_separator = " -> ", |
|
|
const std::string & | file_separator = "\n" ) |
|
nodiscard |
Convert an expected file type map to a string.
Formats all file paths and their expected results as a multi-line string.
- Parameters
-
| [in] | expected_file_type_map | Map of file paths to expected results. |
| [in] | type_separator | Separator between path and result (default: " -> "). |
| [in] | file_separator | Separator between entries (default: "\\n"). |
- Returns
- Formatted string with all entries.
- See also
- Magic::ExpectedFileTypeMapT
- Since
- 10.0.0
◆ ToString() [3/10]
Convert an expected file type result to a string.
Returns the file type if successful, or the error message if failed.
- Parameters
-
| [in] | expected_file_type | The expected result from noexcept identification. |
- Returns
- The file type string on success, or error message on failure.
auto result = magic.IdentifyFile("/path/to/file", std::nothrow);
std::string ToString(const Magic::FileTypeEntryT &file_type_entry, const std::string &type_separator=" -> ")
Convert a file type entry to a string.
Definition magic.cpp:2293
- See also
- Magic::ExpectedFileTypeT
- Since
- 10.0.0
◆ ToString() [4/10]
| std::string Recognition::ToString |
( |
const Magic::FileTypeEntryT & | file_type_entry, |
|
|
const std::string & | type_separator = " -> " ) |
|
nodiscard |
Convert a file type entry to a string.
Formats a single file path and its identified type as a string.
- Parameters
-
| [in] | file_type_entry | The file type entry (path -> type pair). |
| [in] | type_separator | Separator between path and type (default: " -> "). |
- Returns
- Formatted string: "path -> type".
FileTypeMapT::value_type FileTypeEntryT
Key-value pair representing a single file and its detected type.
Definition magic.hpp:258
- See also
- Magic::FileTypeEntryT
- Since
- 10.0.0
- Examples
- magic_examples.cpp.
◆ ToString() [5/10]
| std::string Recognition::ToString |
( |
const Magic::FileTypeMapT & | file_type_map, |
|
|
const std::string & | type_separator = " -> ", |
|
|
const std::string & | file_separator = "\n" ) |
|
nodiscard |
Convert a file type map to a string.
Formats all file paths and their identified types as a multi-line string.
- Parameters
-
| [in] | file_type_map | Map of file paths to their types. |
| [in] | type_separator | Separator between path and type (default: " -> "). |
| [in] | file_separator | Separator between entries (default: "\\n"). |
- Returns
- Formatted string with all entries.
auto results = magic.IdentifyFiles(files);
- See also
- Magic::FileTypeMapT
- Since
- 10.0.0
◆ ToString() [6/10]
| std::string Recognition::ToString |
( |
const Magic::FlagsContainerT & | flags, |
|
|
const std::string & | separator = ", " ) |
|
nodiscard |
Convert a container of flags to a string.
Formats multiple flags as a comma-separated list.
- Parameters
-
| [in] | flags | Container of flags to convert. |
| [in] | separator | Separator between flags (default: ", "). |
- Returns
- Formatted string of flag names.
std::vector< Flags > FlagsContainerT
Container type holding a collection of Magic::Flags.
Definition magic.hpp:401
@ Mime
Definition magic.hpp:328
@ Compress
Definition magic.hpp:319
- See also
- Magic::FlagsContainerT
- Since
- 10.0.0
◆ ToString() [7/10]
| std::string Recognition::ToString |
( |
const Magic::ParameterValueMapT & | parameters, |
|
|
const std::string & | value_separator = ": ", |
|
|
const std::string & | parameter_separator = ", " ) |
|
nodiscard |
Convert a parameter-value map to a string.
Formats all parameters and their values as a formatted list.
- Parameters
-
| [in] | parameters | Map of parameters to values. |
| [in] | value_separator | Separator between name and value (default: ": "). |
| [in] | parameter_separator | Separator between entries (default: ", "). |
- Returns
- Formatted string of all parameter-value pairs.
auto params = magic.GetParameters();
- See also
- Magic::ParameterValueMapT
-
Magic::GetParameters()
- Since
- 10.0.0
◆ ToString() [8/10]
| std::string Recognition::ToString |
( |
const Magic::ParameterValueT & | parameter_value, |
|
|
const std::string & | value_separator = ": " ) |
|
nodiscard |
Convert a parameter-value pair to a string.
Formats a parameter and its value as "name: value".
- Parameters
-
| [in] | parameter_value | The parameter and its value. |
| [in] | value_separator | Separator between name and value (default: ": "). |
- Returns
- Formatted string: "ParameterName: value".
ParameterValueMapT::value_type ParameterValueT
Key-value pair representing a single parameter and its value.
Definition magic.hpp:415
@ BytesMax
Definition magic.hpp:389
- See also
- Magic::ParameterValueT
- Since
- 10.0.0
◆ ToString() [9/10]
Convert a Magic flag to its string name.
Friend declaration for ToString(Flags) free function.
Returns the symbolic name of a single flag value.
- Parameters
-
| [in] | flag | The flag to convert. |
- Returns
- String name of the flag (e.g., "Mime", "MimeType").
- See also
- Magic::Flags
- Since
- 10.0.0
◆ ToString() [10/10]
Convert a Magic parameter to its string name.
Friend declaration for ToString(Parameters) free function.
Returns the symbolic name of a single parameter value.
- Parameters
-
| [in] | parameter | The parameter to convert. |
- Returns
- String name of the parameter (e.g., "BytesMax", "RegexMax").
- See also
- Magic::Parameters
- Since
- 10.0.0