coral
A C++ library for distributed co-simulation
Namespaces | Functions
util.hpp File Reference

Main header file for coral::util. More...

#include <cstdint>
#include <string>
#include <utility>
#include <vector>
#include "coral/config.h"
#include "boost/filesystem/path.hpp"
#include "boost/noncopyable.hpp"

Go to the source code of this file.

Namespaces

 coral::util
 Misc. utilities (i.e., stuff that didn't really fit anywhere else).
 

Functions

void coral::util::EncodeUint16 (std::uint16_t source, char target[2])
 Encodes a 16-bit unsigned integer using little-endian byte order.
 
void coral::util::EncodeUint32 (std::uint32_t source, char target[4])
 Encodes a 32-bit unsigned integer using little-endian byte order.
 
void coral::util::EncodeUint64 (std::uint64_t source, char target[8])
 Encodes a 64-bit unsigned integer using little-endian byte order.
 
std::uint16_t coral::util::DecodeUint16 (const char source[2])
 Decodes a 16-bit unsigned integer using little-endian byte order.
 
std::uint32_t coral::util::DecodeUint32 (const char source[4])
 Decodes a 32-bit unsigned integer using little-endian byte order.
 
std::uint64_t coral::util::DecodeUint64 (const char source[8])
 Decodes a 64-bit unsigned integer using little-endian byte order.
 
int coral::util::ArrayStringCmp (const char *array, size_t length, const char *stringz)
 Given a character array and its length, compares it lexicographically to a zero-terminated string. More...
 
std::string coral::util::RandomUUID ()
 Returns a string that contains a random UUID.
 
std::string coral::util::RandomString (size_t size, const char *charSet)
 Creates a random string. More...
 
std::string coral::util::Timestamp ()
 Returns the current UTC time in the ISO 8601 "basic" format. More...
 
template<typename T1 , typename T2 >
T1 coral::util::MoveAndReplace (T1 &variable, const T2 &replacement)
 Moves a value, replacing it with another one. More...
 
template<typename T >
coral::util::MoveAndReplace (T &variable)
 Overload of MoveAndReplace() that replaces variable with a default-constructed value.
 
template<typename F >
void coral::util::LastCall (F &f)
 Calls the given function(-like object), but only after swapping it with a default-constructed one. More...
 
template<typename Action >
ScopeGuard< Action > coral::util::OnScopeExit (Action action)
 Scope guard. More...
 
void coral::util::SpawnProcess (const std::string &program, const std::vector< std::string > &args)
 Starts a new process. More...
 
boost::filesystem::path coral::util::ThisExePath ()
 Returns the path of the current executable. More...
 

Detailed Description

Main header file for coral::util.