1#ifndef _DRAMA2_UTIL_INC
2#define _DRAMA2_UTIL_INC
30#include "drama2_err.h"
41#define D2DEPRECATED __attribute__ ((deprecated))
42#define D2DEPRECATED_EXPLAIN(_a_) __attribute__ ((deprecated(_a_)))
45#define D2DEPRECATED_EXPLAIN(_a_)
68 template <
typename Container>
88 const std::string::size_type
len =
in.length();
89 std::string::size_type
i = 0;
95 if (
i == std::string::npos)
102 if (
j == std::string::npos) {
165 template <
typename T>
239 template <
typename AT,
typename T>
240 class ScopeGuardAtomic {
241 static_assert(std::is_same<AT, std::atomic<T> >
::value,
"Type AT is not of type std::atomic<T> (Where T = initial/exit value type and AT is the type of the item we are guarding)");
269 _exitVal = _item.load();
304 _item.store(_exitVal);
313 template<
class... >
struct voider {
using type =
void; };
328 template <
typename,
typename = drama::
void_t<>>
struct is_stl_container : std::false_type{};
ScopeGuardAtomic(AT &item, const T executionVal, const T exitVal)
Construct a ScopeGuardAtomic for the specified item.
Definition util.hh:324
ScopeGuardAtomic(AT &item, const T executionVal)
Construct a ScopeGuardAtomic for the specified item.
Definition util.hh:295
~ScopeGuardAtomic()
Destroy the ScopeGuardAtomic item, restoring its value to the specified exit value.
Definition util.hh:330
This class implements a simple scope guard class with an std::atomic based type as the underlying typ...
Definition util.hh:267
~ScopeGuard()
Destroy the ScopeGuard item, restoring its value to the specified exit value.
Definition util.hh:249
ScopeGuard(T &item, const T executionVal)
Construct a ScopeGuard for the specified item.
Definition util.hh:217
ScopeGuard(T &item, const T executionVal, const T exitVal)
Construct a ScopeGuard for the specified item.
Definition util.hh:242
This class implements a simple scope guard class.
Definition util.hh:193
void CreateRunDramaTask()
Create and run a DRAMA task, with standard exception handling.
Definition task.hh:1327
constexpr bool is_stl_container_v
A type trait to helper determine if a type is an STL container.
Definition util.hh:371
void stringtok(Container &container, std::string const &in, const char *const delimiters=" \t\n\r")
stringtok is a replacement for C's strtok() function.
Definition util.hh:97
typename voider< T0toN... >::type void_t
Define a void_t equivalent.
Definition util.hh:349
std::string FindFile(const std::string &spec, bool impdir=false)
Find a file using DulFindFile() specifications.
std::string StatusToString(StatusType status)
Convert a DRAMA status code to text.
The drama namespace contains all the classes, types etc of the DRAMA 2 implementation.
Definition drama.hh:93
Type trait returning true of the specified type is NOT a STL container.
Definition util.hh:355