Util
This header file collects various utility functions.
function clean_type_name
Get the clean name of the type, without any compiler-specific prefixes.
| std::string_view clean_type_name | ( | std::string_view raw_name | ); |
| PARAMETER | DESCRIPTION |
|---|---|
raw_name |
The raw type name. |
| RETURNS | DESCRIPTION |
|---|---|
std::string_view |
The clean type name. |
function default_output_filename
Get a default output file name based on input file name and extension.
It discards the directory part of the input file name and replaces the extension.
| std::filesystem::path default_output_filename | ( | const std::filesystem::path & input_filename, | |
| std::string_view extension | ); |
| PARAMETER | DESCRIPTION |
|---|---|
input_filename |
The input file name. |
extension |
The extension to use for the output file name. |
| RETURNS | DESCRIPTION |
|---|---|
std::filesystem::path |
The default output file name. |
function get_with_default
Get the value associated with a key in an unordered map, or return a default-constructed value if the key is not found.
| V get_with_default | ( | const std::unordered_map< K, V > & map, | |
| const K & key, | |||
| V default_value = {} | ); |
| PARAMETER | DESCRIPTION |
|---|---|
map |
The unordered map to search. |
key |
The key to look for. |
default_value |
The default value to return if the key is not found. |
| RETURNS | DESCRIPTION |
|---|---|
V |
The value associated with the key, or a default-constructed value if the key is not found. |
function join
Join a vector of symbols into a string with a separator between the symbols.
| std::string join | ( | const std::vector< Symbol > & symbols, | |
| std::string_view separator = ", " | ); |
| PARAMETER | DESCRIPTION |
|---|---|
symbols |
The symbols to join. |
separator |
The separator to use between the symbols. |
| RETURNS | DESCRIPTION |
|---|---|
std::string |
The joined string. |
function join
Join a range of strings into a string with a separator between the strings.
| std::string join | ( | const R & strings, | |
| std::string_view separator | ); |
| PARAMETER | DESCRIPTION |
|---|---|
strings |
The range of strings to join. |
separator |
The separator to use between the strings. |
| RETURNS | DESCRIPTION |
|---|---|
std::string |
The joined string. |
function replace_extension
Replace the extension of a file name with a new extension.
| std::filesystem::path replace_extension | ( | const std::filesystem::path & file_name, | |
| std::string_view extension | ); |
| PARAMETER | DESCRIPTION |
|---|---|
file_name |
The file name to replace the extension of. |
extension |
The new extension to use. |
| RETURNS | DESCRIPTION |
|---|---|
std::filesystem::path |
The file name with the replaced extension. |
function sorted
Sort a range of elements and return the sorted collection.
| std::vector< T > sorted | ( | const R & collection, | |
| Comp comp = {} | ); |
| PARAMETER | DESCRIPTION |
|---|---|
collection |
The range of elements to sort. |
comp |
The comparison function to use for sorting. If not provided, the default comparison operator will be used. |
| RETURNS | DESCRIPTION |
|---|---|
std::vector< T > |
The sorted collection. |
function sorted
Sort a range of elements specified by iterators and return the sorted collection.
| std::vector< T > sorted | ( | I first, | |
| I last, | |||
| Comp comp = {} | ); |
| PARAMETER | DESCRIPTION |
|---|---|
first |
The iterator pointing to the first element in the range. |
last |
The iterator pointing to one past the last element in the range. |
comp |
The comparison function to use for sorting. If not provided, the default comparison operator will be used. |
| RETURNS | DESCRIPTION |
|---|---|
std::vector< T > |
The sorted collection. |
function split
Split a string into a vector of strings based on a set of delimiters.
| std::vector< std::string > split | ( | std::string_view str, | |
| std::string_view delimiters = " \t\n\r\f\v", | |||
| bool keep_empty = false | ); |
| PARAMETER | DESCRIPTION |
|---|---|
str |
The string to split. |
delimiters |
The set of delimiters to use for splitting. |
keep_empty |
If |
| RETURNS | DESCRIPTION |
|---|---|
std::vector< std::string > |
The vector of split strings. |
function strerror_string
Get a string representation of a system error code.
| std::string strerror_string | ( | std::optional< int > errnum = {} | ); |
| PARAMETER | DESCRIPTION |
|---|---|
errnum |
The error code to get the string representation of. If not provided, the current value of |
| RETURNS | DESCRIPTION |
|---|---|
std::string |
The string representation of the error code. |
function trim
Trim characters from the beginning and end of a string.
| std::string_view trim | ( | std::string_view str, | |
| std::string_view characters = " \t\n\r\f\v" | ); |
| PARAMETER | DESCRIPTION |
|---|---|
str |
The string to trim. |
characters |
The set of characters to trim. |
| RETURNS | DESCRIPTION |
|---|---|
std::string_view |
The trimmed string. |