![]() |
HAL
|
Classes | |
class | RecursiveDirectoryRange |
class | DirectoryRange |
struct | Color |
Functions | |
bool | file_exists (const std::string &filename) |
bool | folder_exists_and_is_accessible (const std::filesystem::path &folder) |
std::filesystem::path | get_binary_directory () |
std::filesystem::path | get_base_directory () |
std::filesystem::path | get_library_directory () |
std::filesystem::path | get_share_directory () |
std::filesystem::path | get_user_share_directory () |
std::filesystem::path | get_config_directory () |
std::filesystem::path | get_user_config_directory () |
std::filesystem::path | get_default_log_directory (std::filesystem::path source_file) |
std::vector< std::filesystem::path > | get_gate_library_directories () |
std::vector< std::filesystem::path > | get_plugin_directories () |
std::filesystem::path | get_first_directory_exists (std::vector< std::filesystem::path > path_hints) |
std::filesystem::path | get_file (std::string file_name, std::vector< std::filesystem::path > path_hints) |
std::filesystem::path | which (const std::string &name, const std::string &path) |
Result< std::filesystem::path > | get_unique_temp_directory (const std::string &prefix, const u32 max_attmeps) |
std::string | get_open_source_licenses () |
Result< u64 > | wrapped_stoull (const std::string &s, const u32 base) |
Result< u32 > | wrapped_stoul (const std::string &s, const u32 base) |
template<typename T > | |
CORE_API bool | unordered_vector_erase (std::vector< T > &vec, T element) |
template<typename T > | |
bool | vectors_have_same_content (std::vector< T > vec_1, std::vector< T > vec_2) |
CORE_API u64 | get_bit (const u64 value, const u64 index) |
CORE_API u64 | set_bit (const u64 value, const u64 index) |
CORE_API u64 | clear_bit (const u64 value, const u64 index) |
CORE_API u64 | toggle_bit (const u64 value, const u64 index) |
template<typename T > | |
CORE_API bool | ends_with (const T &s, const T &end) |
template<typename T > | |
CORE_API bool | starts_with (const T &s, const T &start) |
template<typename T > | |
CORE_API bool | is_digits (const T &s) |
template<typename T > | |
CORE_API bool | is_integer (const T &s) |
template<typename T > | |
CORE_API bool | is_floating_point (const T &s) |
template<typename T > | |
CORE_API std::vector< T > | split (const T &s, const char delim, bool obey_brackets=false) |
template<typename T > | |
CORE_API T | ltrim (const T &s, const char *to_remove=" \t\r\n") |
template<typename T > | |
CORE_API T | rtrim (const T &s, const char *to_remove=" \t\r\n") |
template<typename T > | |
CORE_API T | trim (const T &s, const char *to_remove=" \t\r\n") |
template<typename T > | |
CORE_API T | replace (const T &str, const T &search, const T &replace) |
template<typename Iterator , class Transform > | |
CORE_API std::string | join (const std::string &joiner, const Iterator &begin, const Iterator &end, const Transform &transform) |
template<typename T , class Transform > | |
CORE_API std::string | join (const std::string &joiner, const T &items, const Transform &transform) |
template<typename T > | |
CORE_API std::string | join (const std::string &joiner, const T &items) |
template<typename T > | |
CORE_API T | to_upper (const T &s) |
template<typename T > | |
CORE_API T | to_lower (const T &s) |
template<typename T > | |
CORE_API u32 | num_of_occurrences (const T &s, const T &substr) |
template<typename T , template< typename, typename... > class Container, typename... Args> | |
CORE_API std::vector< T > | to_vector (const Container< T, Args... > &container) |
template<typename T , template< typename, typename... > class Container, typename... Args> | |
CORE_API std::set< T > | to_set (const Container< T, Args... > &container) |
template<typename T1 , typename T2 > | |
CORE_API bool | is_subset (const T1 &subset, const T2 &superset) |
CORE_API bool hal::utils::ends_with | ( | const T & | s, |
const T & | end | ||
) |
Checks whether a string ends with another string.
[in] | s | - The string to analyze. |
[in] | end | - The ending to check for. |
s
ends with end
, false otherwise. Definition at line 147 of file utils.h.
Referenced by hal::plugin_manager::has_valid_file_extension().
CORE_API bool hal::utils::file_exists | ( | const std::string & | filename | ) |
CORE_API bool hal::utils::folder_exists_and_is_accessible | ( | const std::filesystem::path & | path | ) |
CORE_API std::filesystem::path hal::utils::get_base_directory | ( | ) |
Get the base path to the HAL installation.
Definition at line 99 of file utils.cpp.
References die, get_binary_directory(), and which().
Referenced by hal::core_utils_init(), get_config_directory(), get_library_directory(), get_share_directory(), and hal::TEST_F().
CORE_API std::filesystem::path hal::utils::get_binary_directory | ( | ) |
Get the path to the executable of HAL.
Definition at line 69 of file utils.cpp.
Referenced by hal::core_utils_init(), and get_base_directory().
CORE_API std::filesystem::path hal::utils::get_config_directory | ( | ) |
Get the path to the read-only global configuration directory of HAL.
The resulting path is relative to the binary directory.
Definition at line 163 of file utils.cpp.
References get_base_directory(), and get_first_directory_exists().
CORE_API std::filesystem::path hal::utils::get_default_log_directory | ( | std::filesystem::path | source_file = "" | ) |
Get the path to the default directory for log files.
If an netlist source file is provided, the function returns the parent directory.
[in] | source_file | - The netlist source file. |
Definition at line 178 of file utils.cpp.
References get_user_share_directory().
Referenced by hal::core_utils_init().
CORE_API std::filesystem::path hal::utils::get_file | ( | std::string | file_name, |
std::vector< std::filesystem::path > | path_hints | ||
) |
Search for the given filename in all paths provided by the path hints (searched in order).
[in] | file_name | - The filename to search for. |
[in] | path_hints | - A vector of hints. |
Definition at line 219 of file utils.cpp.
Referenced by hal::gate_library_manager::get_gate_library(), and hal::plugin_manager::get_plugin_path().
CORE_API std::filesystem::path hal::utils::get_first_directory_exists | ( | std::vector< std::filesystem::path > | path_hints | ) |
Get the first directory out of all the path hints that exists (searched in order).
[in] | path_hints | - A vector of hints. |
Definition at line 206 of file utils.cpp.
Referenced by get_config_directory(), and get_share_directory().
CORE_API std::vector< std::filesystem::path > hal::utils::get_gate_library_directories | ( | ) |
Get the paths to the locations where gate libraries are searched.
Definition at line 185 of file utils.cpp.
References get_share_directory(), and get_user_share_directory().
Referenced by hal::core_utils_init(), hal::gate_library_manager::get_all_path(), hal::gate_library_manager::get_gate_library(), and hal::gate_library_manager::load_all().
CORE_API std::filesystem::path hal::utils::get_library_directory | ( | ) |
Get the path to the shared and static libraries of HAL.
The resulting path is relative to the binary directory.
Definition at line 128 of file utils.cpp.
References get_base_directory().
Referenced by hal::core_utils_init(), and get_plugin_directories().
CORE_API std::string hal::utils::get_open_source_licenses | ( | ) |
Get the licenses of all embedded OpenSource Projects.
Definition at line 298 of file utils.cpp.
Referenced by hal::AboutDialog::AboutDialog().
CORE_API std::vector< std::filesystem::path > hal::utils::get_plugin_directories | ( | ) |
Get the paths to the locations where plugins are searched.
Definition at line 194 of file utils.cpp.
References get_library_directory(), and get_user_share_directory().
Referenced by hal::core_utils_init().
CORE_API std::filesystem::path hal::utils::get_share_directory | ( | ) |
Get the path to the shared objects of HAL.
The resulting path is relative to the binary directory.
Definition at line 148 of file utils.cpp.
References get_base_directory(), and get_first_directory_exists().
Referenced by hal::core_utils_init(), and get_gate_library_directories().
CORE_API Result< std::filesystem::path > hal::utils::get_unique_temp_directory | ( | const std::string & | prefix = "" , |
const u32 | max_attempts = 5 |
||
) |
Try to generate a unique temporary directory.
[in] | prefix | - A prefix that is added in front of the unique identifier. Defaults to an empty string. |
[in] | max_attmeps | - The maximum amount of attempts before the function fails. Defaults to 5 . |
CORE_API std::filesystem::path hal::utils::get_user_config_directory | ( | ) |
Get the path to the configuration directory of the user.
Definition at line 171 of file utils.cpp.
Referenced by hal::core_utils_init().
CORE_API std::filesystem::path hal::utils::get_user_share_directory | ( | ) |
Get the path to shared objects and files provided by the user.
Definition at line 156 of file utils.cpp.
Referenced by hal::core_utils_init(), get_default_log_directory(), get_gate_library_directories(), and get_plugin_directories().
CORE_API bool hal::utils::is_digits | ( | const T & | s | ) |
CORE_API bool hal::utils::is_floating_point | ( | const T & | s | ) |
CORE_API bool hal::utils::is_integer | ( | const T & | s | ) |
CORE_API bool hal::utils::is_subset | ( | const T1 & | subset, |
const T2 & | superset | ||
) |
Check whether one container is a subset of another container. The function checks whether all elements of the subset container are contained in the superset container.
[in] | subset | - The container containing the possible subset. |
[in] | superset | - The container containing the possible superset. |
CORE_API std::string hal::utils::join | ( | const std::string & | joiner, |
const Iterator & | begin, | ||
const Iterator & | end, | ||
const Transform & | transform | ||
) |
Join all elements of a iterator range with a joiner-string. A transformation is applied to all elements of the collections before joining.
[in] | joiner | - The string joining the elements. |
[in] | begin | - The start iterator. |
[in] | end | - The end iterator. |
[in] | transform | - The transformation function. |
Definition at line 412 of file utils.h.
Referenced by hal::dataflow::analyze(), join(), hal::ProgramOptions::parse(), hal::ProgramArguments::set_option(), and hal::dataflow::Result::write_txt().
CORE_API std::string hal::utils::join | ( | const std::string & | joiner, |
const T & | items | ||
) |
CORE_API std::string hal::utils::join | ( | const std::string & | joiner, |
const T & | items, | ||
const Transform & | transform | ||
) |
Join all elements of a collection with a joiner-string. A transformation is applied to all elements of the collections before joining.
[in] | joiner | - The string joining the elements. |
[in] | items | - The collection of elements to join. |
[in] | transform | - The transformation function. |
Definition at line 438 of file utils.h.
References join().
CORE_API T hal::utils::ltrim | ( | const T & | s, |
const char * | to_remove = " \t\r\n" |
||
) |
CORE_API T hal::utils::replace | ( | const T & | str, |
const T & | search, | ||
const T & | replace | ||
) |
Replace all occurences of a substring within a string with another string.
[in] | str | - The initial string. |
[in] | search | - The targetted substring. |
[in] | replace | - The replacement string. |
Definition at line 382 of file utils.h.
References control::str, and hal::T.
CORE_API T hal::utils::rtrim | ( | const T & | s, |
const char * | to_remove = " \t\r\n" |
||
) |
CORE_API std::vector<T> hal::utils::split | ( | const T & | s, |
const char | delim, | ||
bool | obey_brackets = false |
||
) |
Split a string into a vector of strings. The split delimiter can be specified by the user.
The delimiters are removed in the splitting process.
To avoid splitting within brackets, set obey_brackets
to true
.
[in] | s | - The string to split. |
[in] | delim | - The delimiter, indicating where to split. |
[in] | obey_brackets | - Flag to indicate whether brackets are obeyed. |
Definition at line 237 of file utils.h.
References hal::T.
Referenced by which().
CORE_API bool hal::utils::starts_with | ( | const T & | s, |
const T & | start | ||
) |
Checks whether a string begins with another string.
[in] | s | - The string to analyze. |
[in] | start | - The beginning to check for. |
s
begins with start
, false otherwise. Definition at line 167 of file utils.h.
Referenced by hal::dataflow::Result::create_modules(), and hal::TEST_F().
CORE_API T hal::utils::to_lower | ( | const T & | s | ) |
Convert a string to lower case.
[in] | s | - The string to convert. |
Definition at line 477 of file utils.h.
References hal::T.
Referenced by hal::netlist_parser_manager::can_parse(), hal::gate_library_parser_manager::register_parser(), hal::netlist_parser_manager::register_parser(), hal::gate_library_writer_manager::register_writer(), and hal::netlist_writer_manager::register_writer().
|
inline |
CORE_API T hal::utils::to_upper | ( | const T & | s | ) |
|
inline |
Turn a given iterable collection into a vector.
[in] | container | - The input collection. |
Definition at line 513 of file utils.h.
Referenced by hal::Gate::get_resolved_boolean_function(), hal::LUTTableModel::setBooleanFunction(), and hal::solve_fsm::solve_fsm_brute_force().
CORE_API T hal::utils::trim | ( | const T & | s, |
const char * | to_remove = " \t\r\n" |
||
) |
Remove any leading and trailing whitespace characters from the beginning and the end of a string.
[in] | s | - The string to trim. |
[in] | to_remove | - The characters to remove. |
Definition at line 358 of file utils.h.
References hal::T.
Referenced by hal::ProgramOptions::add(), hal::gate_library_parser_manager::register_parser(), hal::netlist_parser_manager::register_parser(), hal::gate_library_writer_manager::register_writer(), hal::netlist_writer_manager::register_writer(), hal::Gate::set_name(), hal::Module::set_name(), hal::Net::set_name(), and hal::Grouping::set_name().
|
inline |
bool hal::utils::vectors_have_same_content | ( | std::vector< T > | vec_1, |
std::vector< T > | vec_2 | ||
) |
Check whether two vectors have the same content regardless of their order.
[in] | vec_1 | - First vector. |
[in] | vec_2 | - Second vector. |
true
if the vectors have the same content, false
otherwise. Definition at line 78 of file utils.h.
Referenced by hal::TEST_F().
CORE_API std::filesystem::path hal::utils::which | ( | const std::string & | name, |
const std::string & | path = "" |
||
) |
Locate an executable in the given path environment.
[in] | name | - The name of the executable. |
[in] | path | - The search path (defaults to PATH environment variable). |
Definition at line 242 of file utils.cpp.
References name, split(), and UNUSED.
Referenced by get_base_directory().
A safe wrapper around the std::stoul function that provides a Result<> for error handling instead of exceptions.
[in] | s | - The string represntation of the number. |
[in] | base | - The base of the integer, defaults to 10. |
A safe wrapper around the std::stoull function that provides a Result<> for error handling instead of exceptions.
[in] | s | - The string represntation of the number. |
[in] | base | - The base of the integer, defaults to 10. |