62 static constexpr std::chrono::milliseconds
DefaultTimeout = std::chrono::milliseconds(10);
113 using namespace std::chrono_literals;
117 constexpr
int NumTries = 2;
119 if (
OwnerID != std::this_thread::get_id())
125 bool Success =
false;
126 auto TimeoutPerTry =
Timeout / NumTries;
127 for (
auto i = NumTries; i > 0 && !Success; --i)
128 Success =
LockMutex.try_lock_for(TimeoutPerTry);
134 OwnerID = std::this_thread::get_id();
168 template <
typename T>
190 : LockableObject(LockableObject) {
if (LockableObject) LockableObject->AcquireLock(
Timeout); }
208 Other.LockableObject =
nullptr;
220 template <
typename U>
223 if (!Other.LockableObject)
224 LockableObject =
nullptr;
227 LockableObject =
dynamic_cast<T*
>(Other.LockableObject);
231 Other.LockableObject =
nullptr;
241 auto get() const noexcept {
return LockableObject; }
243 bool operator==(
const T* rhs)
const noexcept {
return LockableObject == rhs; }
244 bool operator!=(
const T* rhs)
const noexcept {
return LockableObject != rhs; }
247 explicit operator bool() const noexcept {
return LockableObject !=
nullptr; }
250 auto&
operator*() const noexcept {
return *LockableObject; }
267 OneToOneNotifier() : EventOccurred(false), SomeoneIsWaiting(false), MutexCanBeDestroyed(true) {}
279 bool Wait(
const std::chrono::milliseconds
Timeout = std::chrono::milliseconds(0));
296 template <
typename T,
typename... ListTs>
302 template <
typename T,
typename... ListTs>
311 template <
typename CallableT>
317 template <
typename ReturnT,
typename ObjectT,
typename... ArgumentTs>
328 template <
typename ReturnT,
typename ObjectT,
typename... ArgumentTs>
339 template <
typename ReturnT,
typename ObjectT,
typename... ArgumentTs>
350 template <
typename ReturnT,
typename ObjectT,
typename... ArgumentTs>
361 template <
typename CallableT>
367 template <
typename CallableT>
373 template <
typename CallableT>
379 template <
typename TupleT>
385 template <
typename FirstElementT,
typename... ElementTs>
391 template <
typename TupleT>
401 template <
size_t Offset,
typename IndexSequence>
407 template <
size_t Offset,
size_t... Indices>
413 using type = std::index_sequence<Indices + Offset...>;
419 template <
size_t Offset,
typename IndexSequence>
427 template <
size_t From,
size_t To>
436 template <
size_t From,
size_t To>
446 template <
typename ObjectT,
typename CallableT>
460 : Object(Object), Callable(Callable), DefaultArgs(std::move(DefaultArgs)) {}
469 template <
typename... ArgTs>
472 return Invoke(
RangeIndexSequence_t<
sizeof...(ArgTs), std::tuple_size_v<ArgumentTs>>(), std::forward<ArgTs>(Args)...);
476 template <
size_t... Indices,
typename... ArgTs>
477 auto Invoke(std::integer_sequence<size_t, Indices...>, ArgTs&& ...Args)
const
479 return (Object.*Callable)(std::forward<ArgTs>(Args)..., std::get<Indices>(DefaultArgs)...);
492 template <
typename ObjectT,
typename CallableT>
503 template <
typename... ArgTs>
505 : CallableWrapper(Object, std::move(Callable), { std::forward<ArgTs>(Args)... }) {}
532 void Reserve(
size_t Size);
533 void Assign(
size_t Size,
const DataType Data);
535 DataPtrType::element_type* Release() noexcept;
536 auto GetPtr() noexcept {
return DataPtr.get(); }
537 auto Size() const noexcept {
return DataSize; }
554 enum class Values { Unknown, False, True };
558 constexpr
OptionalBool(
bool b) noexcept : Value(b ? Values::True : Values::False) {}
568 constexpr
operator bool() const noexcept {
return Value == Values::True; }
587 template <
typename T>
588 std::ostream&
operator<<(std::ostream& stream,
const std::chrono::time_point<T>& TimePoint)
590 const auto ZonedTime = std::chrono::zoned_time(std::chrono::current_zone(), std::chrono::round<std::chrono::seconds>(TimePoint));
591 stream << std::format(
"{:%T %d.%m.%Y}", ZonedTime);
603 template <
typename T>
606 std::stringstream ss(String);
611 throw InvalidDataException(
"String cannot be converted to " + std::string(
typeid(T).name()) +
".");
624 template <
typename T>
625 std::string
ToStr(
const T& Value,
int Precision = -1)
627 std::stringstream ss;
630 ss << std::fixed << std::setprecision(Precision);
642 template <
typename T>
643 std::string
ToStr(
const std::chrono::time_point<T>& TimePoint)
645 std::stringstream ss;
656 inline std::string
ToStr(
const char Value) {
return ToStr(
static_cast<int>(Value)); }
661 inline std::string
ToStr(
const uint8_t Value) {
return ToStr(
static_cast<int>(Value)); }
668 inline std::string
ToStr(
const QString& Str) {
return Str.toStdString(); }
683 template <
typename ToT,
typename FromT, std::enable_if_t<
684 std::is_integral_v<ToT> && std::is_integral_v<FromT> &&
685 std::is_same_v<std::remove_cv_t<ToT>, std::remove_cv_t<FromT>>,
int> = 0
695 template <
typename ToT,
typename FromT, std::enable_if_t<
696 std::is_integral_v<ToT> && std::is_integral_v<FromT> &&
697 !std::is_same_v<std::remove_cv_t<ToT>, std::remove_cv_t<FromT>> &&
698 ((std::is_signed_v<ToT> && std::is_signed_v<FromT>) || (std::is_unsigned_v<ToT> && std::is_unsigned_v<FromT>)),
int> = 0
700 ToT
NumToT(
const FromT Value)
702 if (Value < std::numeric_limits<ToT>::lowest() || Value > std::numeric_limits<ToT>::max())
703 throw OutOfRangeException(
"Cannot convert Value into destiny type since this would cause an underflow or an overflow.");
705 return static_cast<ToT
>(Value);
711 template <
typename ToT,
typename FromT, std::enable_if_t<
712 std::is_integral_v<ToT> && std::is_integral_v<FromT> &&
713 !std::is_same_v<std::remove_cv_t<ToT>, std::remove_cv_t<FromT>> &&
714 std::is_signed_v<ToT> && std::is_unsigned_v<FromT>,
int> = 0
716 ToT
NumToT(
const FromT Value)
718 if (Value >
static_cast<std::make_unsigned_t<ToT>
>(std::numeric_limits<ToT>::max()))
719 throw OverflowException(
"Cannot convert Value into destiny type since this would cause an overflow.");
721 return static_cast<ToT
>(Value);
727 template <
typename ToT,
typename FromT, std::enable_if_t<
728 std::is_integral_v<ToT> && std::is_integral_v<FromT> &&
729 !std::is_same_v<std::remove_cv_t<ToT>, std::remove_cv_t<FromT>> &&
730 std::is_unsigned_v<ToT> && std::is_signed_v<FromT>,
int> = 0
732 ToT
NumToT(
const FromT Value)
735 throw UnderflowException(
"Cannot convert Value into destiny type since this would cause an underflow.");
736 if (
static_cast<std::make_unsigned_t<FromT>
>(Value) > std::numeric_limits<ToT>::max())
737 throw OverflowException(
"Cannot convert Value into destiny type since this would cause an overflow.");
739 return static_cast<ToT
>(Value);
745 template <
typename ToT, std::enable_if_t<
746 std::is_integral_v<ToT> &&
747 !std::is_same_v<std::remove_cv_t<ToT>,
double>,
int> = 0
751 const double RoundedValue = std::round(Value);
753 if (RoundedValue <
static_cast<double>(std::numeric_limits<ToT>::lowest()))
754 throw UnderflowException(
"Cannot convert Value into double since this would cause an underflow.");
755 if (RoundedValue >
static_cast<double>(std::numeric_limits<ToT>::max()))
756 throw OverflowException(
"Cannot convert Value into double since this would cause an overflow.");
758 return static_cast<ToT
>(RoundedValue);
761 using seconds = std::chrono::duration<double>;
770 template <
typename T>
777 inline std::string ToUnitStr<std::chrono::seconds>()
786 inline std::string ToUnitStr<std::chrono::milliseconds>()
795 inline std::string ToUnitStr<std::chrono::microseconds>()
804 inline std::string ToUnitStr<std::chrono::nanoseconds>()
833 inline std::string
TrimTrailingZeros(
const std::string& Str) {
return Str.substr(0, Str.find(
'\0')); }
846 inline auto FilenameFromPath(std::string Path) {
return Path.substr(Path.find_last_of(
"\\") + 1, Path.length() - Path.find_last_of(
"\\") - 1); }
853 inline auto RemoveExtFromPath(std::string Path) {
return Path.substr(0, Path.find_last_of(
".")); }
860 unsigned int Major{};
861 unsigned int Minor{};
862 unsigned int Patch{};
871 std::strong_ordering
operator<=>(
const VersionType& lhs,
const VersionType& rhs);
897 template <
typename... Ts>
898 std::vector<std::tuple<Ts...>>
ParseCSV(
const std::string& CSVData,
const char Delimiter =
';',
const size_t SkipLines = 0)
900 std::vector<std::tuple<Ts...>> ParsedLines;
901 std::istringstream CSVDataStream(CSVData);
904 for (
auto i = SkipLines; i > 0; --i)
905 CSVDataStream.ignore(std::numeric_limits<std::streamsize>::max(), CSVDataStream.widen(
'\n'));
908 const auto GetValue = [Delimiter]<
typename T>(std::istringstream& LineStream) {
909 std::string ValueStr;
910 std::getline(LineStream, ValueStr, Delimiter);
911 std::istringstream ValueStream(ValueStr);
912 ValueStream.exceptions(std::istringstream::failbit | std::istringstream::badbit);
915 ValueStream >> Value;
922 while (std::getline(CSVDataStream, Line))
924 std::istringstream LineStream(Line);
925 LineStream.exceptions(std::istringstream::failbit | std::istringstream::badbit);
929 ParsedLines.push_back({ GetValue.template operator()<Ts>(LineStream)... });
941 std::string
ExceptionToStr(
const std::exception_ptr ExceptionPtr);
948 std::string
ToLower(std::string_view Str);
959 std::vector<std::complex<double>>
FFT(
const std::vector<std::complex<double>>& Data,
bool InverseTransform =
false);
980 const std::source_location Location = std::source_location::current())
981 : Description(std::move(Description)), ErrorCode(ErrorCode),
982 Line(Location.line()), Function(Location.function_name()), File(Location.file_name()) {}
984 const size_t Line = 0, std::string Function =
"", std::string File =
"")
985 : Description(std::move(Description)), ErrorCode(ErrorCode),
986 Line(Line), Function(std::move(Function)), File(std::move(File)) {}
1009 const std::source_location Location = std::source_location::current())
1010 : Data(std::make_unique<
WarningData>(std::move(Description), ErrorCode, Location)) {}
1017 : Data(std::make_unique<
WarningData>(e.what(), e.ErrorCode, e.Line, e.Function, e.File)) {}
1047 : Message(std::move(Message)), Type(Type), TimePoint(TimePoint) {}
1097 const size_t Line = 0,
const std::string& Function =
"",
const std::string& File =
"",
const int ErrorCode = 0
1099 ,
const std::stacktrace& Trace = {}
1107 void Log(
const Exception& E) noexcept;
1113 void Log(
const Warning& W) noexcept;
1126 static std::string FormatLog(
const std::string& Message,
const size_t Line = 0,
1127 const std::string& Function =
"",
const std::string& Filename =
"",
const int ErrorCode = 0,
const bool PrefixMessage =
true);
1142 const size_t Line = 0,
const std::string& Function =
"",
const std::string& Filename =
"",
const int ErrorCode = 0
1144 ,
const std::stacktrace& Trace = {}
1152 void OpenLogFile(std::string Filename);
1182 std::vector<LogEntry> GetLog(
size_t FirstElement = 0)
const;
1197 void CloseLogFileUnsafe();
1205 static constexpr
auto LogOperationTimeout = std::chrono::milliseconds(100);
1227 template <
typename EnumType, std::enable_if_t<
1228 std::is_enum_v<EnumType>,
int> = 0
1246 for (
const auto Flag : Flags)
1257 bool Test(
const std::array<EnumType, N>& Flags)
const
1259 for (
const auto Flag : Flags)
1261 auto Result = Features.test(
static_cast<size_t>(Flag));
1275 bool Test(EnumType Flag)
const {
return Features.test(
static_cast<size_t>(Flag)); }
1281 void Set(EnumType Flag) { Features.set(
static_cast<size_t>(Flag)); }
1287 std::bitset<static_cast<size_t>(EnumType::NUM_ELEMENTS)>
Features;
1302 std::enable_if_t<std::is_enum_v<return_of_t<CallableT>>,
int> = 0
1318 : State(State), StateFunction(StateFunction), Description(Description), Final(IsFinal)
1323 constexpr
bool IsFinal() const noexcept {
return Final; }
1333 template <
typename... ArgTs>
1336 return (Instance.*StateFunction)(std::forward<ArgTs>(Args)...);
1360 template <
typename StateMachineStateT>
1384 std::initializer_list<const StateMachineContext*> BaseContexts = {})
1385 : ReplacementList(std::move(ReplacementList)), Description(Description)
1387 for (
auto BaseContext : BaseContexts)
1389 this->ReplacementList.insert(BaseContext->ReplacementList.cbegin(), BaseContext->ReplacementList.cend());
1406 auto AdaptedState = ReplacementList.find(State);
1408 return AdaptedState == ReplacementList.cend() ? State : AdaptedState->second;
1433 template <
typename StateMachineStateT>
1449 template <
typename... StateMachineStateTs>
1451 : StatesList{ { InitialState.GetState(), &InitialState }, { States.GetState(), &States }... },
1452 CurrentState(&InitialState), CurrentContext(
nullptr)
1466 CurrentState = StatesList.at(CurrentContext.load()->AdaptState(NewState));
1468 CurrentState = StatesList.at(NewState);
1491 template <
typename... ArgTs>
1497 if (CurrentState.load()->IsFinal())
1498 CurrentState.load()->Invoke(Instance, std::forward<ArgTs>(Args)...);
1500 SetCurrentState(CurrentState.load()->Invoke(Instance, std::forward<ArgTs>(Args)...));
1508 const std::unordered_map<StateEnumType, const StateType*>
StatesList;
Provides exception type and error definitions used by DynExp.
Data type which manages a binary large object. The reserved memory is freed upon destruction.
unsigned char[] DataType
Type of the buffer's data.
std::unique_ptr< DataType > DataPtrType
Type of the underlying smart pointer managing the buffer.
DataPtrType DataPtr
Pointer to the buffer.
auto Size() const noexcept
Returns the size of the stored data in bytes.
BlobDataType()=default
Constructs an empty object.
Wraps a member function of some object and stores its default arguments. Moving from CallableMemberWr...
auto operator()(ArgTs &&...Args) const
Invokes the stored member function. If arguments are passed, they are are forwarded instead of the st...
argument_of_t< CallableT > ArgumentTs
constexpr CallableMemberWrapper(ObjectT &Object, const CallableT Callable, ArgumentTs DefaultArgs={}) noexcept
Constructs a CallableMemberWrapper instance.
ObjectT & Object
Instance of class Callable belongs to. Callable is invoked on this instance.
auto Invoke(std::integer_sequence< size_t, Indices... >, ArgTs &&...Args) const
const ArgumentTs DefaultArgs
Default arguments to be passed when invoking operator() with less arguments Callable expects.
const CallableT Callable
Pointer to class member function to be invoked.
Logs events like errors and writes them immediately to a HTML file in a human-readable format....
bool IsOpenUnsafe() const
void CloseLogFile()
Closes the log file on disk and writes terminating HTML tags.
EventLogger(std::string Filename)
Constructs the event logger with opening a log file on disk.
std::string GetLogFilename() const
Determines the full file path to the currently openend log file.
auto GetLogSize() const
Determines the number of entries in the internal event log.
std::ofstream LogFile
Stream object to write to the log file on disk.
std::string Filename
Filename and path to the log file on disk.
~EventLogger()
Destructor closes the log file on disk.
void ClearLog()
Clears the internal event log.
std::vector< LogEntry > LogEntries
Internally stored log entries.
bool IsOpen() const
Determines whether the log file has been openend on disk.
DynExp exceptions are derived from this class. It contains basic information about the cause of the e...
Holds a bitset containing flags to indicate which features a certain instrument/ module etc....
constexpr FeatureTester() noexcept=default
Constructs a FeatureTester instance with no flags set.
void Set(EnumType Flag)
Sets a flag.
bool Test(const std::array< EnumType, N > &Flags) const
Tests whether all of the flags passed as an array are set.
std::bitset< static_cast< size_t >EnumType::NUM_ELEMENTS)> Features
Bitset containing the flags and their states.
bool Test(EnumType Flag) const
Tests whether a single flag is set.
Interface to allow synchronizing the access to derived classes between different threads by providing...
LockType AcquireLock(const std::chrono::milliseconds Timeout=DefaultTimeout) const
Locks the internal mutex. Blocks until the mutex is locked or until the timeout duration is exceeded.
std::timed_mutex MutexType
std::unique_lock< MutexType > LockType
MutexType LockMutex
Internal mutex used for locking.
static constexpr std::chrono::milliseconds DefaultTimeout
Duration which is used as a default timeout within all methods of this class if no different duration...
Interface to delete copy constructor and copy assignment operator and thus make derived classes non-c...
constexpr INonCopyable()=default
INonCopyable & operator=(const INonCopyable &)=delete
INonCopyable(const INonCopyable &)=delete
Interface to delete move constructor and move assignment operator and thus make derived classes non-m...
INonMovable(const INonMovable &)=default
INonMovable(INonMovable &&)=delete
constexpr INonMovable()=default
INonMovable & operator=(const INonMovable &)=default
INonMovable & operator=(INonMovable &&)=delete
Interface to allow synchronizing the access to derived classes between different threads by making th...
std::timed_mutex LockMutex
Internal mutex used for locking.
void ReleaseLock() const
Releases the internal mutex. Does nothing if the mutex was not locked or if the calling thread is not...
~ISynchronizedPointerLockable()
Object should never be destroyed before completely unlocked.
ISynchronizedPointerLockable()
std::atomic< size_t > OwnedCount
Counts the lock requests of the current owning thread.
std::atomic< std::thread::id > OwnerID
ID of the thread which currently owns the internal mutex.
void AcquireLock(const std::chrono::milliseconds Timeout) const
Locks the internal mutex. Blocks until the mutex is locked or until the timeout duration is exceeded....
Data to operate on is invalid for a specific purpose. This indicates a corrupted data structure or fu...
An operation cannot be performed currently since the related object is in an invalid state like an er...
Holds a CallableMemberWrapper and invokes its callable when being destroyed.
CallableMemberWrapper< ObjectT, CallableT > CallableWrapper
OnDestruction(ObjectT &Object, const CallableT Callable, ArgTs &&...Args)
Constructs a OnDestruction instance which calls Callable upon destruction of this instance.
Helper class to communicate flags between different threads based on a condition variable and a mutex...
std::condition_variable ConditionVariable
std::atomic< bool > MutexCanBeDestroyed
Data type which stores an optional bool value (unknown, false, true). The type evaluates to bool whil...
Values
Possible values. Values::Unknown evaluates to false.
constexpr OptionalBool(bool b) noexcept
Contructs an instance holding b.
constexpr OptionalBool(const OptionalBool &Other) noexcept
Contructs a copy of Other.
constexpr OptionalBool(Values Value) noexcept
Contructs an instance holding Value.
constexpr bool operator!=(Values Value) const noexcept
Returns false when Value matches stored value, true otherwise.
constexpr bool operator==(Values Value) const noexcept
Returns true when Value matches stored value, false otherwise.
constexpr OptionalBool & operator=(OptionalBool &Other) noexcept
Assigns value of Other, returns reference to this.
constexpr OptionalBool() noexcept
Contructs an instance holding Values::Unknown.
constexpr OptionalBool & operator=(Values Value) noexcept
Assigns Value, returns reference to this.
constexpr OptionalBool & operator=(bool b) noexcept
Assigns b, returns reference to this.
Values Value
Internal value.
constexpr Values Get() const noexcept
Returns internal value.
Thrown when a numeric operation would result in an overflow (e.g. due to incompatible data types)
State machine context as used by class StateMachine. A state machine context holds a map with keys an...
typename StateType::StateEnumType StateEnumType
Refer to class StateMachineState.
StateEnumType AdaptState(StateEnumType State) const
Checks whether the context contains a replacement entry for the state identified by State and returns...
std::unordered_map< StateEnumType, StateEnumType > ReplacementListType
constexpr auto GetDescription() const noexcept
Returns the context's description.
StateMachineStateT StateType
ReplacementListType ReplacementList
Within this context, the map's key states are replaced by the corresponding value states....
StateMachineContext()=default
Default constructor constructs an empty context not performing any state replacement.
StateMachineContext(ReplacementListType &&ReplacementList, const char *Description="", std::initializer_list< const StateMachineContext * > BaseContexts={})
Constructs a StateMachineContext from a replacement list appending the replacement lists of each cont...
State machine state as used by class StateMachine. A state mainly wraps a state function of the membe...
const StateEnumType State
StateEnumType Invoke(instance_of_t< CallableT > &Instance, ArgTs &&... Args) const
Invokes the state function associated with this state on an instance of the class the state function ...
const bool Final
For final states, it is ensured that the state's state function can delete the state machine....
return_of_t< CallableT > StateEnumType
constexpr StateEnumType GetState() const noexcept
Returns the state's unique identifier.
const std::decay_t< CallableT > StateFunction
constexpr auto GetDescription() const noexcept
Returns the state's description.
constexpr StateMachineState(StateEnumType State, CallableT StateFunction, const char *Description="", const bool IsFinal=false) noexcept
Constructs a state machine state and assigns fixed parameters to it.
constexpr bool IsFinal() const noexcept
Returns whether this is a final state.
This class models a state machine. It keeps track of the current state and allows to invoke its assoc...
std::atomic< const StateType * > CurrentState
void Invoke(instance_of_t< typename StateType::CallableType > &Instance, ArgTs &&... Args)
Invokes the state function associated with the current state machine state on an instance of the clas...
void SetContext(const ContextType *NewContext)
Sets the current state machine context.
StateMachineStateT StateType
void ResetContext()
Removes the current state machine context.
void SetCurrentState(StateEnumType NewState)
Sets the current state as identified by an element from StateEnumType.
StateMachine(const StateType &InitialState, const StateMachineStateTs &... States)
Constructs a state machine assigning possible states to it. Automatically also adds InitialState,...
typename StateType::StateEnumType StateEnumType
Refer to class StateMachineState.
std::atomic< const ContextType * > CurrentContext
const std::unordered_map< StateEnumType, const StateType * > StatesList
Map of possible states. All states are uniquely identified by an element from StateEnumType....
const ContextType * GetContext() const noexcept
Returns a pointer to the current context.
const StateType * GetCurrentState() const noexcept
Returns a pointer to the current state.
Pointer to lock a class derived from ISynchronizedPointerLockable for synchronizing between threads....
auto & operator*() const noexcept
bool operator!=(const T *rhs) const noexcept
SynchronizedPointer(SynchronizedPointer< U > &&Other)
Moves the LockableObject from a SynchronizedPointer<U> of another type U to a new instance of Synchro...
SynchronizedPointer(T *const LockableObject, const std::chrono::milliseconds Timeout=ILockable::DefaultTimeout)
Constructs a pointer locking LockableObject. Blocks until LockableObject's mutex is locked or until t...
bool operator==(const SynchronizedPointer &rhs) const noexcept
SynchronizedPointer() noexcept
Contructs an instance with an empty pointer.
SynchronizedPointer & operator=(SynchronizedPointer &&Other) noexcept
Move-assigns the LockableObject from another SynchronizedPointer instance Other to this instance....
SynchronizedPointer(SynchronizedPointer &&Other) noexcept
Moves the LockableObject from another SynchronizedPointer instance Other to a new instance....
auto operator->() const noexcept
bool operator!=(const SynchronizedPointer &rhs) const noexcept
T * LockableObject
Pointer to the locakable object managed by this class.
auto get() const noexcept
Returns the managed (locked) object.
bool operator==(const T *rhs) const noexcept
Thrown when an operation timed out before it could be completed, especially used for locking shared d...
Thrown when an attempt was made to convert two incompatible types into each other.
Thrown when a numeric operation would result in an underflow (e.g. due to incompatible data types)
Class to store information about warnings in a thread-safe manner (deriving from ILockable)....
Warning()
Constructs an empty Warning.
virtual ~Warning()=default
Warning(std::string Description, const int ErrorCode=DynExpErrorCodes::GeneralError, const std::source_location Location=std::source_location::current())
Constructs a Warning from specified information.
Warning(const Exception &e)
Constructs a Warning retrieving the warning data from an exception e.
std::unique_ptr< WarningData > Data
Pointer to warning data. Must never be nullptr.
DynExpErrorCodes
DynExp's error codes
DynExp's Util namespace contains commonly used functions and templates as well as extensions to Qt an...
std::string ToStr(const T &Value, int Precision=-1)
Converts a (numeric) value of type T to a std::string using operator<< of std::stringstream.
typename member_fn_ptr_traits< CallableT >::instance_type instance_of_t
Alias for the class type a member function callable of type CallableT is member of.
constexpr bool is_contained_in_v
Value type of is_contained_in.
std::index_sequence< Indices+Offset... > type
Alias for offset index sequence.
auto FilenameFromPath(std::string Path)
Extracts the filename from a path.
std::string ExceptionToStr(const std::exception_ptr ExceptionPtr)
Returns the what() information of an exception derived from std::exception and stored in an exception...
std::tuple< ArgumentTs... > argument_types
T StrToT(const std::string &String)
Converts a std::string to a value of type T using operator<< of std::stringstream.
std::tuple< ElementTs... > type
std::vector< std::tuple< Ts... > > ParseCSV(const std::string &CSVData, const char Delimiter=';', const size_t SkipLines=0)
Parses a string containing comma-separated values (csv) and inserts each row as one tuple containing ...
std::string ToUnitStr< picoseconds >()
Returns a string describing the physical unit associated with type T. For example,...
std::tuple< ArgumentTs... > argument_types
auto CurrentTimeAndDateString()
Returns a human-readable string describing the current time and date in the current time zone.
typename remove_first_from_tuple< TupleT >::type remove_first_from_tuple_t
Alias for a tuple of types where the first type of the input tuple TupleT is removed.
VersionType VersionFromString(std::string_view Str)
Extracts a program version from a string.
typename OffsetIndexSequence< Offset, IndexSequence >::type OffsetIndexSequence_t
Alias for type contained in OffsetIndexSequence.
EventLogger & EventLog()
This function holds a static EventLogger instance and returns a reference to it. DynExp uses only one...
std::tuple< ArgumentTs... > argument_types
typename member_fn_ptr_traits< CallableT >::return_type return_of_t
Alias for the return type of a member function callable of type CallableT.
std::string ToUnitStr()
Returns a string describing the physical unit associated with type T. For example,...
std::chrono::duration< double, std::pico > picoseconds
Extends std::chrono by a duration data type for picoseconds.
std::strong_ordering operator<=>(const VersionType &lhs, const VersionType &rhs)
Compares two program version types with each other.
std::vector< std::complex< double > > FFT(const std::vector< std::complex< double >> &Data, bool InverseTransform)
Computes the Fast Fourier Transform (FFT) a vector of complex values.
std::string ToLower(std::string_view Str)
Transforms a string into lower case.
std::chrono::duration< double > seconds
Extends std::chrono by a duration data type for seconds capable of storing fractions of seconds.
auto RemoveExtFromPath(std::string Path)
Removes the filename's extension from a path.
std::string TrimTrailingZeros(const std::string &Str)
Removes trailing zeros ('\0') from a string.
std::tuple< ArgumentTs... > argument_types
typename RangeIndexSequence< From, To >::type RangeIndexSequence_t
Alias for type contained in RangeIndexSequence.
ToT NumToT(const FromT Value)
Converts a value of a numeric type to a value of another numeric type checking the conversion for its...
std::ostream & operator<<(std::ostream &stream, const Exception &e)
Writes a DynExp exception in a user-readable way to a stream.
ErrorType
DynExp's error types
typename member_fn_ptr_traits< CallableT >::argument_types argument_of_t
Alias for a tuple of argument types the member function callable of type CallableT expects.
std::string ToUnitStr< seconds >()
Returns a string describing the physical unit associated with type T. For example,...
OffsetIndexSequence_t< From, std::make_index_sequence< To - From > > type
Holds an alias for a std::index_sequence where all indices are shifted by an offset.
Holds an alias for a std::index_sequence spanning a certain range.
Data type describing DynExp's program version in the form Major.Minor.Patch.
Extracts the return value type, the class type the callable is member of, and the argument types of a...
Removes first type from a tuple of types TupleT.
#define DYNEXP_HAS_STACKTRACE
Data type of a single entry in DynExp's log.
LogEntry(std::string Message, ErrorType Type, std::chrono::system_clock::time_point TimePoint)
const std::string Message
String describing the log entry including reasons and consequences of the message.
const ErrorType Type
DynExp error code from DynExpErrorCodes::DynExpErrorCodes associated with the log enty
const std::chrono::system_clock::time_point TimePoint
Time point associated with the log enty.
Data associated with a warning. The class is convertible to bool (true if it describes an error/warni...
const std::string Function
Function in source code where the warning occurred.
const std::string Description
String describing the reason and consequences of the warning.
const std::string File
Source code file where the warning occurred.
const size_t Line
Line in source code where the warning occurred.
WarningData(std::string Description, const int ErrorCode=DynExpErrorCodes::GeneralError, const size_t Line=0, std::string Function="", std::string File="")
WarningData()
Default constructor sets ErrorCode to a non-error code.
const int ErrorCode
DynExp error code from DynExpErrorCodes::DynExpErrorCodes
WarningData(std::string Description, const int ErrorCode=DynExpErrorCodes::GeneralError, const std::source_location Location=std::source_location::current())
Checks whether a type T is contained in a template parameter pack of types ListTs.