6 #ifndef IFW_CORE_UTILS_TOOLS_HPP_
7 #define IFW_CORE_UTILS_TOOLS_HPP_
23 std::string
Write(
const char* format, ...);
27 #define IFW_LOCATION {\
28 std::string(__FILE__), \
29 std::string(__FUNCTION__), \
30 std::to_string(__LINE__)}
35 std::string
ResolvePath(
const std::string& filename);
38 std::string
GenUniqueId(
const std::string& prefix =
"");
44 std::vector<TYPE>& clean_vect) {
46 for (
const TYPE& el : vect) {
48 clean_vect.insert(el);
66 std::vector<TYPE>& valid_values);
73 for (
auto it = vect.begin(); it != vect.end(); it++, i++) {
84 const std::string& separator =
"\n") {
85 std::stringstream tmp_buf;
87 for (
auto it = vector.begin(); it != vector.end(); it++, i++) {
88 tmp_buf << *it << separator;
94 template <
class MAP_TYPE>
96 const MAP_TYPE& map) {
97 return (map.find(key) != map.end());
105 std::string
GetResDir(
const std::string& module_path,
106 const std::string& test_res_dir);
111 const std::string& test_res_dir,
112 const std::vector<std::string>& cfgpath_dirs);
void SetRootEnvVars(const std::string &module_path, const std::string &test_res_dir, const std::vector< std::string > &cfgpath_dirs)
Set the root environment variables: CFGPATH, INTROOT, DATAROOT.
Definition: tools.cpp:114
std::string GetResDir(const std::string &module_path, const std::string &test_res_dir)
Derives the "resource" directory from the current working point.
Definition: tools.cpp:81
std::string ResolvePath(const std::string &filename)
Resolve the filename if it contains env. variables, "~" and relative paths.
Definition: tools.cpp:30
std::string DumpVector(const std::vector< TYPE > &vector, const std::string &separator="\n")
Dump contents of a list into a string buffer.
Definition: tools.hpp:83
void CleanVector(const std::vector< TYPE > &vect, const TYPE &pattern, std::vector< TYPE > &clean_vect)
Remove elements from list, which are equal to "pattern".
Definition: tools.hpp:42
void CheckRange(const std::string &par, TYPE value, TYPE lower_limit, TYPE upper_limit)
Check if a value is within a given range.
std::string GenUniqueId(const std::string &prefix="")
Generate a unique UUID based ID. A prefix may be prepended, if requested.
Definition: tools.cpp:58
bool ElInMap(const std::string &key, const MAP_TYPE &map)
Check if a given key is contained in an STL map.
Definition: tools.hpp:95
int32_t ElInVector(const std::vector< TYPE > &vect, const TYPE &value)
Check for specific element in the list. Return index if found, otherwise -1.
Definition: tools.hpp:70
std::string Write(const char *format,...)
Create formatted string, return formatted string (C formatting convention).
Definition: testutils.py:1