include/ignition/common/Util.hh File Reference
#include <cassert>
#include <memory>
#include <string>
#include <future>
#include <vector>
#include <ignition/common/Export.hh>
#include <ignition/common/Filesystem.hh>
Go to the source code of this file.
Namespaces | |
ignition | |
Forward declarations for the common classes. | |
ignition::common | |
Macros | |
#define | IGN_ASSERT(_expr, _msg) assert((_msg, _expr)) |
This macro defines the standard way of launching an exception inside ignition. More... | |
#define | IGN_HOMEDIR "HOME" |
#define | IGN_MS_TO_NANO 1000000 |
Nano seconds in one millisecond. More... | |
#define | IGN_NANO_TO_SEC 1e-9 |
Seconds in one nano second. More... | |
#define | IGN_SEC_TO_NANO 1000000000 |
Nano seconds in one second. More... | |
#define | IGN_SLEEP_MS(_ms) |
Sleep for the specifed number of milliseconds. More... | |
#define | IGN_SLEEP_NS(_ns) |
Sleep for the specifed number of nanoseconds. More... | |
#define | IGN_SLEEP_S(_s) |
Sleep for the specifed number of seconds. More... | |
#define | IGN_SLEEP_US(_us) |
Sleep for the specifed number of microseconds. More... | |
#define | IGN_SPEED_OF_LIGHT = 299792458.0 |
Speed of light. More... | |
#define | IGN_SYSTEM_TIME() (std::chrono::system_clock::now()) |
Get the system time. More... | |
#define | IGN_SYSTEM_TIME_MS() |
Get the system time in milliseconds since epoch. More... | |
#define | IGN_SYSTEM_TIME_NS() |
Get the system time in nanoseconds since epoch. More... | |
#define | IGN_SYSTEM_TIME_S() |
Get the system time in seconds since epoch. More... | |
#define | IGN_SYSTEM_TIME_US() |
Get the system time in microseconds since epoch. More... | |
#define | IGN_US_TO_NANO 1000 |
Nano seconds in one microsecond. More... | |
Typedefs | |
typedef std::runtime_error | exception |
A runtime error. More... | |
Enumerations | |
enum | NodeTransformType { TRANSLATE, ROTATE, SCALE, MATRIX } |
Enumeration of the transform types. More... | |
Functions | |
void | addSearchPathSuffix (const std::string &_suffix) |
add path sufix to common::SystemPaths More... | |
bool | env (const std::string &_name, std::string &_value) |
Find the environment variable '_name' and return its value. More... | |
std::string | findFile (const std::string &_file) |
search for file in common::SystemPaths More... | |
std::string | findFile (const std::string &_file, bool _searchLocalPath) |
search for file in common::SystemPaths More... | |
std::string | findFilePath (const std::string &_file) |
search for a file in common::SystemPaths More... | |
constexpr uint64_t | hash64 (std::string_view _key) |
fnv1a algorithm for 64-bit platforms. More... | |
std::string | logPath () |
Get the log path. More... | |
std::string | lowercase (const std::string &_in) |
Transforms a string to its lowercase equivalent. More... | |
std::string | lowercase (const char *_in) |
Transforms a string to its lowercase equivalent. More... | |
void | ltrim (std::string &_s) |
In place left trim. More... | |
std::string | ltrimmed (std::string _s) |
Copying left trim. More... | |
void | replaceAll (std::string &_result, const std::string &_orig, const std::string &_key, const std::string &_replacement) |
Replace all occurances of _key with _replacement. More... | |
std::string | replaceAll (const std::string &_orig, const std::string &_key, const std::string &_replacement) |
Replace all occurances of _key with _replacement. More... | |
void | rtrim (std::string &_s) |
In place right trim. More... | |
std::string | rtrimmed (std::string _s) |
Copying right trim. More... | |
template<typename T > | |
std::string | sha1 (const T &_buffer) |
Compute the SHA1 hash of an array of bytes. More... | |
std::string | sha1 (void const *_buffer, std::size_t _byteCount) |
Compute the SHA1 hash of an array of bytes. Use std::string sha1(const T &_buffer) instead of this function. More... | |
template<typename T > | |
std::string | sha1 (const T &_buffer) |
Compute the SHA1 hash of an array of bytes. More... | |
std::vector< std::string > | split (const std::string &_str, const std::string &_delim) |
Splits a string into tokens. More... | |
std::string | systemTimeISO () |
Get the wall time as an ISO string: YYYY-MM-DDTHH:MM:SS.NS. More... | |
void | trim (std::string &_s) |
In place trim from both ends. More... | |
std::string | trimmed (std::string _s) |
Copying trim from both ends. More... | |
std::string | uuid () |
Get a UUID. More... | |
Macro Definition Documentation
◆ IGN_ASSERT
#define IGN_ASSERT | ( | _expr, | |
_msg | |||
) | assert((_msg, _expr)) |
This macro defines the standard way of launching an exception inside ignition.
◆ IGN_HOMEDIR
#define IGN_HOMEDIR "HOME" |
◆ IGN_MS_TO_NANO
#define IGN_MS_TO_NANO 1000000 |
Nano seconds in one millisecond.
◆ IGN_NANO_TO_SEC
#define IGN_NANO_TO_SEC 1e-9 |
Seconds in one nano second.
◆ IGN_SEC_TO_NANO
#define IGN_SEC_TO_NANO 1000000000 |
Nano seconds in one second.
◆ IGN_SLEEP_MS
#define IGN_SLEEP_MS | ( | _ms | ) |
Value:
std::chrono::milliseconds(_ms)))
T sleep_for(T... args)
Sleep for the specifed number of milliseconds.
◆ IGN_SLEEP_NS
#define IGN_SLEEP_NS | ( | _ns | ) |
Value:
std::chrono::nanoseconds(_ns)))
T sleep_for(T... args)
Sleep for the specifed number of nanoseconds.
◆ IGN_SLEEP_S
#define IGN_SLEEP_S | ( | _s | ) |
Value:
std::chrono::seconds(_s)))
T sleep_for(T... args)
Sleep for the specifed number of seconds.
◆ IGN_SLEEP_US
#define IGN_SLEEP_US | ( | _us | ) |
Value:
std::chrono::microseconds(_us)))
T sleep_for(T... args)
Sleep for the specifed number of microseconds.
◆ IGN_SPEED_OF_LIGHT
#define IGN_SPEED_OF_LIGHT = 299792458.0 |
Speed of light.
◆ IGN_SYSTEM_TIME
#define IGN_SYSTEM_TIME | ( | ) | (std::chrono::system_clock::now()) |
Get the system time.
◆ IGN_SYSTEM_TIME_MS
#define IGN_SYSTEM_TIME_MS | ( | ) |
Value:
(\
std::chrono::duration_cast<std::chrono::milliseconds>(\
std::chrono::system_clock::now().time_since_epoch()).count())
T count(T... args)
T now(T... args)
Get the system time in milliseconds since epoch.
◆ IGN_SYSTEM_TIME_NS
#define IGN_SYSTEM_TIME_NS | ( | ) |
Value:
(\
std::chrono::duration_cast<std::chrono::nanoseconds>(\
std::chrono::system_clock::now().time_since_epoch()).count())
T count(T... args)
T now(T... args)
Get the system time in nanoseconds since epoch.
◆ IGN_SYSTEM_TIME_S
#define IGN_SYSTEM_TIME_S | ( | ) |
Value:
std::chrono::system_clock::now().time_since_epoch()).count())
T duration_cast(T... args)
T count(T... args)
T now(T... args)
Get the system time in seconds since epoch.
◆ IGN_SYSTEM_TIME_US
#define IGN_SYSTEM_TIME_US | ( | ) |
Value:
(\
std::chrono::duration_cast<std::chrono::microseconds>(\
std::chrono::system_clock::now().time_since_epoch()).count())
T count(T... args)
T now(T... args)
Get the system time in microseconds since epoch.
◆ IGN_US_TO_NANO
#define IGN_US_TO_NANO 1000 |
Nano seconds in one microsecond.
Function Documentation
◆ sha1()
std::string sha1 | ( | const T & | _buffer | ) |
Compute the SHA1 hash of an array of bytes.
- Parameters
-
[in] _buffer Input sequence. The permitted data types for this function are std::string and any STL container.
- Returns
- The string representation (40 character) of the SHA1 hash.
References ignition::common::sha1().
Referenced by sha1().