17 #ifndef IGNITION_COMMON_UTIL_HH_ 18 #define IGNITION_COMMON_UTIL_HH_ 25 #include <ignition/common/Export.hh> 32 # define IGN_HOMEDIR "HOMEPATH" 34 # define IGN_HOMEDIR "HOME" 38 #define IGN_NANO_TO_SEC 1e-9 41 #define IGN_SEC_TO_NANO 1000000000 44 #define IGN_MS_TO_NANO 1000000 47 #define IGN_US_TO_NANO 1000 50 #define IGN_SPEED_OF_LIGHT = 299792458.0 53 #define IGN_SLEEP_S(_s) (std::this_thread::sleep_for(\ 54 std::chrono::seconds(_s))) 57 #define IGN_SLEEP_US(_us) (std::this_thread::sleep_for(\ 58 std::chrono::microseconds(_us))) 61 #define IGN_SLEEP_MS(_ms) (std::this_thread::sleep_for(\ 62 std::chrono::milliseconds(_ms))) 65 #define IGN_SLEEP_NS(_ns) (std::this_thread::sleep_for(\ 66 std::chrono::nanoseconds(_ns))) 69 #define IGN_SYSTEM_TIME() (std::chrono::system_clock::now()) 72 #define IGN_SYSTEM_TIME_S() (std::chrono::duration_cast<std::chrono::seconds>(\ 73 std::chrono::system_clock::now().time_since_epoch()).count()) 76 #define IGN_SYSTEM_TIME_US() (\ 77 std::chrono::duration_cast<std::chrono::microseconds>(\ 78 std::chrono::system_clock::now().time_since_epoch()).count()) 81 #define IGN_SYSTEM_TIME_MS() (\ 82 std::chrono::duration_cast<std::chrono::milliseconds>(\ 83 std::chrono::system_clock::now().time_since_epoch()).count()) 86 #define IGN_SYSTEM_TIME_NS() (\ 87 std::chrono::duration_cast<std::chrono::nanoseconds>(\ 88 std::chrono::system_clock::now().time_since_epoch()).count()) 92 #define IGN_ASSERT(_expr, _msg) assert((_msg, _expr)) 129 bool _searchLocalPath);
153 #pragma warning(disable:4307) 160 constexpr uint64_t IGNITION_COMMON_VISIBLE
hash64(std::string_view _key)
162 const char *data = _key.data();
163 const auto len = _key.size();
164 const uint64_t prime = 0x100000001b3;
165 uint64_t hash = 0xcbf29ce484222325;
167 for (
auto i = 0u; i < len; ++i)
169 uint8_t value = data[i];
185 bool IGNITION_COMMON_VISIBLE
env(
268 if (_buffer.size() == 0)
273 &(_buffer[0]), _buffer.size() *
sizeof(_buffer[0]));
std::string sha1(const T &_buffer)
Compute the SHA1 hash of an array of bytes.
Definition: include/ignition/common/Util.hh:266
std::string findFilePath(const std::string &_file)
search for a file in common::SystemPaths
std::string uuid()
Get a UUID.
void addSearchPathSuffix(const std::string &_suffix)
add path sufix to common::SystemPaths
std::string systemTimeISO()
Get the wall time as an ISO string: YYYY-MM-DDTHH:MM:SS.NS.
void replaceAll(std::string &_result, const std::string &_orig, const std::string &_key, const std::string &_replacement)
Replace all occurances of _key with _replacement.
std::string ltrimmed(std::string _s)
Copying left trim.
std::runtime_error exception
A runtime error.
Definition: include/ignition/common/Util.hh:103
void rtrim(std::string &_s)
In place right trim.
bool env(const std::string &_name, std::string &_value)
Find the environment variable '_name' and return its value.
std::string logPath()
Get the log path.
Definition: include/ignition/common/Util.hh:100
Definition: include/ignition/common/Util.hh:100
constexpr uint64_t hash64(std::string_view _key)
fnv1a algorithm for 64-bit platforms.
Definition: include/ignition/common/Util.hh:160
std::string lowercase(const std::string &_in)
Transforms a string to its lowercase equivalent.
NodeTransformType
Enumeration of the transform types.
Definition: include/ignition/common/Util.hh:100
std::string findFile(const std::string &_file)
search for file in common::SystemPaths
std::vector< std::string > split(const std::string &_str, const std::string &_delim)
Splits a string into tokens.
std::string rtrimmed(std::string _s)
Copying right trim.
std::string trimmed(std::string _s)
Copying trim from both ends.
Forward declarations for the common classes.
void trim(std::string &_s)
In place trim from both ends.
Definition: include/ignition/common/Util.hh:100
Definition: include/ignition/common/Util.hh:100
void ltrim(std::string &_s)
In place left trim.