6#ifndef IFW_CORE_UTILS_TOOLS_HPP_
7#define IFW_CORE_UTILS_TOOLS_HPP_
17#include <ciiLogManager.hpp>
26 std::string
Write(
const char* format, ...);
30#define IFW_LOCATION {\
31 std::string(__FILE__), \
32 std::string(__FUNCTION__), \
33 std::to_string(__LINE__)}
39 std::string
ResolvePath(
const std::string& filename);
42 std::string
GenUniqueId(
const std::string& prefix =
"");
48 std::vector<TYPE>& clean_vect) {
50 for (
const TYPE& el : vect) {
52 clean_vect.insert(el);
70 std::vector<TYPE>& valid_values);
77 for (
auto it = vect.begin(); it != vect.end(); it++, i++) {
88 const std::string& separator =
"\n") {
89 std::stringstream tmp_buf;
91 for (
auto it = vector.begin(); it != vector.end(); it++, i++) {
92 tmp_buf << *it << separator;
98 template <
class MAP_TYPE>
100 const MAP_TYPE& map) {
101 return (map.find(key) != map.end());
104 namespace testutils {
109 std::string
GetResDir(
const std::string& module_path,
110 const std::string& test_res_dir);
115 const std::string& test_res_dir,
116 const std::vector<std::string>& cfgpath_dirs);
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:80
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:113
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:46
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:57
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:87
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:74
bool ElInMap(const std::string &key, const MAP_TYPE &map)
Check if a given key is contained in an STL map.
Definition tools.hpp:99
std::string ResolvePath(const std::string &filename)
Resolve the filename if it contains env. variables, "~" and relative paths.
Definition tools.cpp:29
Definition defines.cpp:12
std::string Write(const char *format,...)
Create formatted string, return formatted string (C formatting convention).