DynExp
Highly flexible laboratory automation for dynamically changing experiments.
Util Namespace Reference

DynExp's Util namespace contains commonly used functions and templates as well as extensions to Qt and its widgets. More...

Namespaces

 DynExpErrorCodes
 

Classes

class  circularbuf
 Circular stream buffer to be used with the standard library's stream classes. Reading from or writing behind the buffer's end continues at the buffer's beginning. More...
 
class  Exception
 DynExp exceptions are derived from this class. It contains basic information about the cause of the exception as well as a stacktrace. More...
 
class  ForwardedException
 Class to forward an Exception instance from one DynExp::Object instance to another DynExp::Object instance. Refer to class DynExp::LinkedObjectWrapperContainer. More...
 
class  InvalidArgException
 An invalid argument like a null pointer has been passed to a function. More...
 
class  InvalidStateException
 An operation cannot be performed currently since the related object is in an invalid state like an error state. More...
 
class  InvalidDataException
 Data to operate on is invalid for a specific purpose. This indicates a corrupted data structure or function calls not returning data in the expected format. More...
 
class  InvalidCallException
 Thrown when a function call is not allowed to a specific thread in a multi-threading context. More...
 
class  UnderflowException
 Thrown when a numeric operation would result in an underflow (e.g. due to incompatible data types) More...
 
class  OverflowException
 Thrown when a numeric operation would result in an overflow (e.g. due to incompatible data types) More...
 
class  OutOfRangeException
 Thrown when an argument passed to a function exceeds the valid range. More...
 
class  EmptyException
 Thrown when a list is expected to contain entries and when a query results in an empty answer or an empty argument has been passed to a function, or a stored list is empty. More...
 
class  NotFoundException
 Thrown when a requested ressource does not exist. More...
 
class  TypeErrorException
 Thrown when an attempt was made to convert two incompatible types into each other. More...
 
class  TimeoutException
 Thrown when an operation timed out before it could be completed, especially used for locking shared data in a multi-threading context. More...
 
class  ThreadDidNotRespondException
 Thrown in a multi-threading context when an answer is expected from another thread an when the communication timed out. More...
 
class  NotAvailableException
 Thrown when some operation or feature is temporarily or permanently not available. More...
 
class  NotImplementedException
 Thrown when a requested feature is either under development and thus not implemented yet or when a specific instrument does not support certain operation. More...
 
class  FileIOErrorException
 Thrown when reading from or writing to a file failed. More...
 
class  LinkedObjectNotLockedException
 Thrown when RunnableInstance::LockObject() has not been called on an object link parameter to establish the relation between the object using another object and the used object. More...
 
class  InvalidObjectLinkException
 Thrown when RunnableInstance cannot lock an object to be used by another object due to an invalid link between the objects. This happens when the used object the link points to has been removed from the project. More...
 
class  ServiceFailedException
 Denotes that e.g. a remote gRPC service failed. More...
 
class  PyStdoutLoggerWrapper
 Forwards Python's stdout to Util::EventLogger instance defined in Util::EventLog(). More...
 
class  PyGilReleasedInterpreter
 Initialize Python interpreter and directly release the GIL after construction. More...
 
class  PyObject
 Wraps a class derived from pybind11::object and ensures that the GIL is acquired when the PyObject is destroyed. For any other operation on this wrapper, the GIL still needs to be acquired manually before! More...
 
class  QWorker
 Implements a QObject belonging to a hardware adapter (derived from DynExp::HardwareAdapterBase) that operates in DynExpCore's worker thread, not in the main user interface thread. This is useful to move e.g. ethernet/serial communication operations from the user interface thread to a worker thread. After construction, QWorker instances have to be moved to the worker thread calling QWorker::MoveToWorkerThread(). More...
 
class  MarkerGraphicsView
 Implements a QGraphicsView the user can interact with to insert graphical markers. Furthermore, the graphics view enables zooming into its content. More...
 
class  QSortingListWidget
 Implements a QListWidget that sorts its items after inserting an item by drag & drop. More...
 
class  NumericSortingTableWidgetItem
 Implements a QTableWidgetItem which contains numeric content such that table widget items can be numerically compared with each other. More...
 
class  NumericOnlyItemDelegate
 Implements a QItemDelegate which forces e.g. a QTableWidgetItem's content to be numeric (double-precision). More...
 
class  DigitalOnlyItemDelegate
 Implements a QItemDelegate which forces e.g. a QTableWidgetItem's content to be boolean (0 or 1). More...
 
class  INonCopyable
 Interface to delete copy constructor and copy assignment operator and thus make derived classes non-copyable. More...
 
class  INonMovable
 Interface to delete move constructor and move assignment operator and thus make derived classes non-movable. More...
 
class  ILockable
 Interface to allow synchronizing the access to derived classes between different threads by providing a mutex and a method to lock that mutex. Recursive locking is not allowed. More...
 
class  SynchronizedPointer
 Pointer to lock a class derived from ISynchronizedPointerLockable for synchronizing between threads. Instances of this class are not intended to be stored somewhere since they make other threads block. Only use as temporary objects. More...
 
class  ISynchronizedPointerLockable
 Interface to allow synchronizing the access to derived classes between different threads by making the class lockable by SynchronizedPointer smart pointer objects. Recursive locking is allowed. More...
 
class  OneToOneNotifier
 Helper class to communicate flags between different threads based on a condition variable and a mutex. Two threads make use of the same instance of this class. One of the thread awaits a flag to be set by the other thread. More...
 
struct  is_contained_in
 Checks whether a type T is contained in a template parameter pack of types ListTs. More...
 
struct  member_fn_ptr_traits
 Extracts the return value type, the class type the callable is member of, and the argument types of a callable type CallableT which is a member function of some class. The extracted types are stored using type aliases return_type and instance_type and an alias of a tuple of types argument_types. More...
 
struct  member_fn_ptr_traits< ReturnT(ObjectT::*)(ArgumentTs...) const >
 Extracts the return value type, the class type the callable is member of, and the argument types of a callable type CallableT which is a member function of some class. The extracted types are stored using type aliases return_type and instance_type and an alias of a tuple of types argument_types. More...
 
struct  member_fn_ptr_traits< ReturnT(ObjectT::*)(ArgumentTs...) noexcept >
 Extracts the return value type, the class type the callable is member of, and the argument types of a callable type CallableT which is a member function of some class. The extracted types are stored using type aliases return_type and instance_type and an alias of a tuple of types argument_types. More...
 
struct  member_fn_ptr_traits< ReturnT(ObjectT::*)(ArgumentTs...) const noexcept >
 Extracts the return value type, the class type the callable is member of, and the argument types of a callable type CallableT which is a member function of some class. The extracted types are stored using type aliases return_type and instance_type and an alias of a tuple of types argument_types. More...
 
struct  member_fn_ptr_traits< ReturnT(ObjectT::*)(ArgumentTs...)>
 Extracts the return value type, the class type the callable is member of, and the argument types of a callable type CallableT which is a member function of some class. The extracted types are stored using type aliases return_type and instance_type and an alias of a tuple of types argument_types. More...
 
struct  remove_first_from_tuple
 Removes first type from a tuple of types TupleT. More...
 
struct  remove_first_from_tuple< std::tuple< FirstElementT, ElementTs... > >
 Removes first type from a tuple of types TupleT. More...
 
struct  OffsetIndexSequence
 Holds an alias for a std::index_sequence where all indices are shifted by an offset. More...
 
struct  OffsetIndexSequence< Offset, std::index_sequence< Indices... > >
 Holds an alias for a std::index_sequence where all indices are shifted by an offset. More...
 
struct  RangeIndexSequence
 Holds an alias for a std::index_sequence spanning a certain range. More...
 
class  CallableMemberWrapper
 Wraps a member function of some object and stores its default arguments. Moving from CallableMemberWrapper does not work since this class holds const members and a reference to the object the member function is invoked on. Copy instead. More...
 
class  OnDestruction
 Holds a CallableMemberWrapper and invokes its callable when being destroyed. More...
 
class  BlobDataType
 Data type which manages a binary large object. The reserved memory is freed upon destruction. More...
 
class  OptionalBool
 Data type which stores an optional bool value (unknown, false, true). The type evaluates to bool while an unknown value is considered false. More...
 
struct  VersionType
 Data type describing DynExp's program version in the form Major.Minor.Patch. More...
 
class  Warning
 Class to store information about warnings in a thread-safe manner (deriving from ILockable). All function calls are thread-safe. More...
 
struct  LogEntry
 Data type of a single entry in DynExp's log. More...
 
class  EventLogger
 Logs events like errors and writes them immediately to a HTML file in a human-readable format. The logger also stores the events in an internal event log to be displayed within DynExp. The class is designed such that instances can be shared between different threads. Member function calls are synchronized. More...
 
class  FeatureTester
 Holds a bitset containing flags to indicate which features a certain instrument/ module etc. supports. More...
 
class  StateMachineState
 State machine state as used by class StateMachine. A state mainly wraps a state function of the member function pointer type CallableT to be invoked by the state machine. More...
 
class  StateMachineContext
 State machine context as used by class StateMachine. A state machine context holds a map with keys and values of unique state identifiers of type StateEnumType (refer to class StateMachineState). Each map entry indicates a state (key) to be replaced by another state (value). StateMachine::Invoke checks the state identifiers returned by StateMachineState::Invoke and possibly replaces them according to the current context before setting the new state machine state. Contexts can be derived from base contexts unifying and including their replacement lists. More...
 
class  StateMachine
 This class models a state machine. It keeps track of the current state and allows to invoke its associated state function. The return value of the state function determines the new state to transition into. Additionally, a context of type StateMachineContext can be assigned to the state machine. Contexts allow for replacing states with other states. This makes sense to write inner protocols BeginState -> StateA -> ... -> StateN -> EndState and to embed them into outer protocols. The outer protocol can transition into BeginState and take control back by replacing EndState with one of its own states by setting a respective context. All states (of type StateMachineState) have to be registered upon construction of the StateMachine instance. More...
 

Typedefs

using TextType = std::string
 String type of text-type parameters (DynExp::ParamsBase::Param) More...
 
using TextRefType = std::string_view
 Reference-to-string type of text-type parameters (DynExp::ParamsBase::Param) More...
 
using TextListType = std::vector< TextType >
 List type of text-type parameters. More...
 
using TextListIndexType = size_t
 List index type of Util::TextListType. More...
 
template<typename ValueType >
using TextValueListType = std::vector< std::pair< TextType, ValueType > >
 Type of a list containing key-value pairs where key is a text of type Util::TextType. More...
 
template<typename CallableT >
using return_of_t = typename member_fn_ptr_traits< CallableT >::return_type
 Alias for the return type of a member function callable of type CallableT. More...
 
template<typename CallableT >
using instance_of_t = typename member_fn_ptr_traits< CallableT >::instance_type
 Alias for the class type a member function callable of type CallableT is member of. More...
 
template<typename CallableT >
using argument_of_t = typename member_fn_ptr_traits< CallableT >::argument_types
 Alias for a tuple of argument types the member function callable of type CallableT expects. More...
 
template<typename TupleT >
using remove_first_from_tuple_t = typename remove_first_from_tuple< TupleT >::type
 Alias for a tuple of types where the first type of the input tuple TupleT is removed. More...
 
template<size_t Offset, typename IndexSequence >
using OffsetIndexSequence_t = typename OffsetIndexSequence< Offset, IndexSequence >::type
 Alias for type contained in OffsetIndexSequence. More...
 
template<size_t From, size_t To>
using RangeIndexSequence_t = typename RangeIndexSequence< From, To >::type
 Alias for type contained in RangeIndexSequence. More...
 

Enumerations

enum class  ErrorType { Info , Warning , Error , Fatal }
 DynExp's error types More...
 

Functions

std::ostream & operator<< (std::ostream &stream, const Exception &e)
 Writes a DynExp exception in a user-readable way to a stream. More...
 
void ForwardException (std::exception_ptr e)
 Wraps the exception passed to the function in a ForwardedException and throws the ForwardedException. Does nothing if e is not an exception. More...
 
const QLocale & GetDefaultQtLocale ()
 Returns the default locale properties to be assigned to Qt widgets. More...
 
void ActivateWindow (QWidget &Widget)
 Renders a window active and brings it to the front. More...
 
template<typename EnumType >
auto QtEnumToTextValueList (unsigned short SkipEntriesFront=0, unsigned short SkipEntriesEnd=0, unsigned short SkipCharsFront=0, unsigned short SkipCharsEnd=0)
 Returns a TextValueListType containing entries which reflect the items (names and values) of an enumeration registered to Qt's meta-object system. More...
 
std::strong_ordering operator<=> (const VersionType &lhs, const VersionType &rhs)
 Compares two program version types with each other. More...
 
VersionType VersionFromString (std::string_view Str)
 Extracts a program version from a string. More...
 
std::string ExceptionToStr (const std::exception_ptr ExceptionPtr)
 Returns the what() information of an exception derived from std::exception and stored in an exception pointer. More...
 
std::string ToLower (std::string_view Str)
 Transforms a string into lower case. More...
 
std::vector< std::complex< double > > FFT (const std::vector< std::complex< double >> &Data, bool InverseTransform=false)
 Computes the Fast Fourier Transform (FFT) a vector of complex values. More...
 
EventLoggerEventLog ()
 This function holds a static EventLogger instance and returns a reference to it. DynExp uses only one EventLogger instance to log events from any thread. A local static object instead of a global object is employed to avoid initialization order problems. More...
 
std::string TrimTrailingZeros (const std::string &Str)
 Removes trailing zeros ('\0') from a string. More...
 
auto CurrentTimeAndDateString ()
 Returns a human-readable string describing the current time and date in the current time zone. More...
 
auto FilenameFromPath (std::string Path)
 Extracts the filename from a path. More...
 
auto RemoveExtFromPath (std::string Path)
 Removes the filename's extension from a path. More...
 
std::string ToStr (const VersionType &Version)
 Converts a program version to a string in the form specified by VersionType. More...
 
template<typename... Ts>
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 column data into a vector of tuples. More...
 
DOM functions

These functions can be used to walk through an (XML-)DOM tree.

std::vector< QDomNode > GetChildDOMNodes (const QDomElement &Parent, const QString &ChildTagName)
 Finds child nodes with a certain tag name. More...
 
QDomNode GetSingleChildDOMNode (const QDomElement &Parent, const QString &ChildTagName)
 Finds a single child node with a certain tag name. More...
 
QDomElement GetSingleChildDOMElement (const QDomElement &Parent, const QString &ChildTagName)
 Behaves like GetSingleChildDOMNode() but returns the node converted to a DOM element. More...
 
std::string GetStringFromDOMElement (const QDomElement &Parent, const QString &ChildTagName)
 Behaves like GetSingleChildDOMElement() but returns the text from a DOM element. More...
 
template<>
std::string GetTFromDOMElement (const QDomElement &Parent, const QString &ChildTagName)
 Behaves like GetSingleChildDOMElement() but returns the content from a DOM element converted to a certain type using Util::StrToT(). More...
 
QDomAttr GetDOMAttribute (const QDomElement &Element, const QString &AttributeName)
 Extracts an attribute from a DOM element. More...
 
std::string GetStringFromDOMAttribute (const QDomElement &Element, const QString &AttributeName)
 Behaves like GetDOMAttribute() but returns the text from the attribute. More...
 
template<>
std::string GetTFromDOMAttribute (const QDomElement &Element, const QString &AttributeName)
 Behaves like GetDOMAttribute() but returns the content from an attribute converted to a certain type using Util::StrToT(). More...
 
File open and save dialogs
QString PromptOpenFilePath (QWidget *Parent, const QString &Title, const QString &DefaultSuffix, const QString &NameFilter, const QString &InitialDirectory="")
 Opens a file dialog to ask the user to select a single existing file. More...
 
QString PromptSaveFilePath (QWidget *Parent, const QString &Title, const QString &DefaultSuffix, const QString &NameFilter, const QString &InitialDirectory="")
 Works as PromptOpenFilePath() but asks the user to select a single file which does not need to exist. More...
 
QString PromptSaveFilePathModule (DynExp::QModuleWidget *Parent, const QString &Title, const QString &DefaultSuffix, const QString &NameFilter)
 Works as PromptOpenFilePath() but asks the user to select a single file which does not need to exist. Furthermore, the dialog automatically derives the initial directory using QModuleWidget::GetDataSaveDirectory() and sets the new global directory for saving data to the folder containing the selected file when the user accepts the dialog. More...
 
Reading and writing files
bool SaveToFile (const QString &Filename, std::string_view Text)
 Saves a std::string_view to a file (using QFile). Creates a new file or truncates an existing file's content. More...
 
std::string ReadFromFile (const QString &Filename)
 Reads the entire content from a text file. More...
 
std::string ReadFromFile (const std::string &Filename)
 Reads the entire content from a text file. More...
 
std::string ReadFromFile (const std::filesystem::path &Filename)
 Reads the entire content from a text file. More...
 

Variables

static constexpr auto PyTab = " "
 Character sequence to indent a Python instruction by one level. More...
 
template<typename T , typename... ListTs>
constexpr bool is_contained_in_v = is_contained_in<T, ListTs...>::value
 Value type of is_contained_in. More...
 

Image manipulation

using ImageHistogramType = std::array< unsigned long long, 256 >
 Alias which represents a histogram as a std::array with 256 numeric bins. The lowest (highest) index represents the darkest (brightest) intensity. More...
 
using ImageRGBHistogramType = std::tuple< ImageHistogramType, ImageHistogramType, ImageHistogramType >
 Alias which represents a RGB histogram as a std::tuple of three ImageHistogramType elements. The first tuple element represents the histogram for red, the second for green, the third for blue. More...
 
QImage QImageFromBlobData (BlobDataType &&BlobData, int Width, int Height, int BytesPerLine, QImage::Format Format)
 Converts raw pixel data stored in a Util::BlobDataType object to a QImage transfering the ownership of BlobData's content. More...
 
ImageHistogramType ComputeIntensityHistogram (const QImage &Image)
 Computes an intensity (grayscale) histogram from a QImage object. More...
 
ImageRGBHistogramType ComputeRGBHistogram (const QImage &Image)
 Computes a RGB histogram from a QImage object. More...
 
ImageHistogramType ConvertRGBToIntensityHistogram (const ImageRGBHistogramType &RGBHistogram)
 Computes an intensity (grayscale) histogram from a RGB histogram. More...
 
QPolygonF MakeCrossPolygon (QPointF Center, unsigned int ArmLength)
 Returns a QPolygonF representing a cross-style marker. More...
 

Conversion functions

These functions can be used to convert between different number and string types.

using seconds = std::chrono::duration< double >
 Extends std::chrono by a duration data type for seconds capable of storing fractions of seconds. More...
 
using picoseconds = std::chrono::duration< double, std::pico >
 Extends std::chrono by a duration data type for picoseconds. More...
 
template<typename T >
std::ostream & operator<< (std::ostream &stream, const std::chrono::time_point< T > &TimePoint)
 Formats a time point to a human-readable string describing the time in the current time zone and writes the string to a stream. More...
 
template<typename T >
StrToT (const std::string &String)
 Converts a std::string to a value of type T using operator<< of std::stringstream. More...
 
template<typename T >
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. More...
 
template<typename T >
std::string ToStr (const std::chrono::time_point< T > &TimePoint)
 Converts a time point to a human-readable string describing the time in the current time zone. More...
 
std::string ToStr (const char Value)
 Converts Value to a std::string using operator<< of std::stringstream. More...
 
std::string ToStr (const uint8_t Value)
 Converts Value to a std::string using operator<< of std::stringstream. More...
 
std::string ToStr (const QString &Str)
 Converts the Qt QString Str to a std::string. More...
 
template<typename ToT , typename FromT , std::enable_if_t< std::is_integral_v< ToT > &&std::is_integral_v< FromT > &&std::is_same_v< std::remove_cv_t< ToT >, std::remove_cv_t< FromT >>, int > = 0>
ToT NumToT (const FromT Value)
 Converts a value of a numeric type to a value of another numeric type checking the conversion for its bounds. More...
 
template<typename ToT , std::enable_if_t< std::is_integral_v< ToT > &&!std::is_same_v< std::remove_cv_t< ToT >, double >, int > = 0>
ToT NumToT (const double Value)
 Converts a value of a numeric type to a value of another numeric type checking the conversion for its bounds. More...
 
template<typename T >
std::string ToUnitStr ()
 Returns a string describing the physical unit associated with type T. For example, if T is std::chrono::milliseconds, the function returns the string "ms". More...
 
template<>
std::string ToUnitStr< std::chrono::seconds > ()
 Returns a string describing the physical unit associated with type T. For example, if T is std::chrono::milliseconds, the function returns the string "ms". More...
 
template<>
std::string ToUnitStr< std::chrono::milliseconds > ()
 Returns a string describing the physical unit associated with type T. For example, if T is std::chrono::milliseconds, the function returns the string "ms". More...
 
template<>
std::string ToUnitStr< std::chrono::microseconds > ()
 Returns a string describing the physical unit associated with type T. For example, if T is std::chrono::milliseconds, the function returns the string "ms". More...
 
template<>
std::string ToUnitStr< std::chrono::nanoseconds > ()
 Returns a string describing the physical unit associated with type T. For example, if T is std::chrono::milliseconds, the function returns the string "ms". More...
 
template<>
std::string ToUnitStr< seconds > ()
 Returns a string describing the physical unit associated with type T. For example, if T is std::chrono::milliseconds, the function returns the string "ms". More...
 
template<>
std::string ToUnitStr< picoseconds > ()
 Returns a string describing the physical unit associated with type T. For example, if T is std::chrono::milliseconds, the function returns the string "ms". More...
 

Detailed Description

DynExp's Util namespace contains commonly used functions and templates as well as extensions to Qt and its widgets.


Class Documentation

◆ Util::member_fn_ptr_traits

struct Util::member_fn_ptr_traits

template<typename CallableT>
struct Util::member_fn_ptr_traits< CallableT >

Extracts the return value type, the class type the callable is member of, and the argument types of a callable type CallableT which is a member function of some class. The extracted types are stored using type aliases return_type and instance_type and an alias of a tuple of types argument_types.

Definition at line 312 of file Util.h.

◆ Util::member_fn_ptr_traits< ReturnT(ObjectT::*)(ArgumentTs...) const >

struct Util::member_fn_ptr_traits< ReturnT(ObjectT::*)(ArgumentTs...) const >

template<typename ReturnT, typename ObjectT, typename... ArgumentTs>
struct Util::member_fn_ptr_traits< ReturnT(ObjectT::*)(ArgumentTs...) const >

Extracts the return value type, the class type the callable is member of, and the argument types of a callable type CallableT which is a member function of some class. The extracted types are stored using type aliases return_type and instance_type and an alias of a tuple of types argument_types.

Definition at line 318 of file Util.h.

Class Members
argument_types
typedef ObjectT instance_type
typedef ReturnT return_type

◆ Util::member_fn_ptr_traits< ReturnT(ObjectT::*)(ArgumentTs...) noexcept >

struct Util::member_fn_ptr_traits< ReturnT(ObjectT::*)(ArgumentTs...) noexcept >

template<typename ReturnT, typename ObjectT, typename... ArgumentTs>
struct Util::member_fn_ptr_traits< ReturnT(ObjectT::*)(ArgumentTs...) noexcept >

Extracts the return value type, the class type the callable is member of, and the argument types of a callable type CallableT which is a member function of some class. The extracted types are stored using type aliases return_type and instance_type and an alias of a tuple of types argument_types.

Definition at line 329 of file Util.h.

Class Members
argument_types
typedef ObjectT instance_type
typedef ReturnT return_type

◆ Util::member_fn_ptr_traits< ReturnT(ObjectT::*)(ArgumentTs...) const noexcept >

struct Util::member_fn_ptr_traits< ReturnT(ObjectT::*)(ArgumentTs...) const noexcept >

template<typename ReturnT, typename ObjectT, typename... ArgumentTs>
struct Util::member_fn_ptr_traits< ReturnT(ObjectT::*)(ArgumentTs...) const noexcept >

Extracts the return value type, the class type the callable is member of, and the argument types of a callable type CallableT which is a member function of some class. The extracted types are stored using type aliases return_type and instance_type and an alias of a tuple of types argument_types.

Definition at line 340 of file Util.h.

Class Members
argument_types
typedef ObjectT instance_type
typedef ReturnT return_type

◆ Util::member_fn_ptr_traits< ReturnT(ObjectT::*)(ArgumentTs...)>

struct Util::member_fn_ptr_traits< ReturnT(ObjectT::*)(ArgumentTs...)>

template<typename ReturnT, typename ObjectT, typename... ArgumentTs>
struct Util::member_fn_ptr_traits< ReturnT(ObjectT::*)(ArgumentTs...)>

Extracts the return value type, the class type the callable is member of, and the argument types of a callable type CallableT which is a member function of some class. The extracted types are stored using type aliases return_type and instance_type and an alias of a tuple of types argument_types.

Definition at line 351 of file Util.h.

Class Members
argument_types
typedef ObjectT instance_type
typedef ReturnT return_type

◆ Util::remove_first_from_tuple

struct Util::remove_first_from_tuple

template<typename TupleT>
struct Util::remove_first_from_tuple< TupleT >

Removes first type from a tuple of types TupleT.

Definition at line 380 of file Util.h.

◆ Util::remove_first_from_tuple< std::tuple< FirstElementT, ElementTs... > >

struct Util::remove_first_from_tuple< std::tuple< FirstElementT, ElementTs... > >

template<typename FirstElementT, typename... ElementTs>
struct Util::remove_first_from_tuple< std::tuple< FirstElementT, ElementTs... > >

Removes first type from a tuple of types TupleT.

Definition at line 386 of file Util.h.

Class Members
type

◆ Util::OffsetIndexSequence

struct Util::OffsetIndexSequence

template<size_t Offset, typename IndexSequence>
struct Util::OffsetIndexSequence< Offset, IndexSequence >

Holds an alias for a std::index_sequence where all indices are shifted by an offset.

Template Parameters
IndexSequenceIndices passes as template arguments to std::index_sequence
OffsetOffset added to all indices

Definition at line 402 of file Util.h.

◆ Util::OffsetIndexSequence< Offset, std::index_sequence< Indices... > >

struct Util::OffsetIndexSequence< Offset, std::index_sequence< Indices... > >

template<size_t Offset, size_t... Indices>
struct Util::OffsetIndexSequence< Offset, std::index_sequence< Indices... > >

Holds an alias for a std::index_sequence where all indices are shifted by an offset.

Template Parameters
IndexSequenceIndices passes as template arguments to std::index_sequence
OffsetOffset added to all indices

Definition at line 408 of file Util.h.

Class Members
type Alias for offset index sequence.

◆ Util::RangeIndexSequence

struct Util::RangeIndexSequence

template<size_t From, size_t To>
struct Util::RangeIndexSequence< From, To >

Holds an alias for a std::index_sequence spanning a certain range.

Template Parameters
FromStart value the index sequency begins with
ToLast value contained in the index sequence

Definition at line 428 of file Util.h.

Class Members
typedef OffsetIndexSequence_t< From, make_index_sequence< To - From > > type

◆ Util::VersionType

struct Util::VersionType

Data type describing DynExp's program version in the form Major.Minor.Patch.

Definition at line 858 of file Util.h.

Class Members
unsigned int Major
unsigned int Minor
unsigned int Patch

Typedef Documentation

◆ argument_of_t

template<typename CallableT >
using Util::argument_of_t = typedef typename member_fn_ptr_traits<CallableT>::argument_types

Alias for a tuple of argument types the member function callable of type CallableT expects.

Definition at line 374 of file Util.h.

◆ ImageHistogramType

using Util::ImageHistogramType = typedef std::array<unsigned long long, 256>

Alias which represents a histogram as a std::array with 256 numeric bins. The lowest (highest) index represents the darkest (brightest) intensity.

Definition at line 244 of file QtUtil.h.

◆ ImageRGBHistogramType

Alias which represents a RGB histogram as a std::tuple of three ImageHistogramType elements. The first tuple element represents the histogram for red, the second for green, the third for blue.

Definition at line 250 of file QtUtil.h.

◆ instance_of_t

template<typename CallableT >
using Util::instance_of_t = typedef typename member_fn_ptr_traits<CallableT>::instance_type

Alias for the class type a member function callable of type CallableT is member of.

Definition at line 368 of file Util.h.

◆ OffsetIndexSequence_t

template<size_t Offset, typename IndexSequence >
using Util::OffsetIndexSequence_t = typedef typename OffsetIndexSequence<Offset, IndexSequence>::type

Alias for type contained in OffsetIndexSequence.

Definition at line 420 of file Util.h.

◆ picoseconds

using Util::picoseconds = typedef std::chrono::duration<double, std::pico>

Extends std::chrono by a duration data type for picoseconds.

Definition at line 762 of file Util.h.

◆ RangeIndexSequence_t

template<size_t From, size_t To>
using Util::RangeIndexSequence_t = typedef typename RangeIndexSequence<From, To>::type

Alias for type contained in RangeIndexSequence.

Definition at line 437 of file Util.h.

◆ remove_first_from_tuple_t

template<typename TupleT >
using Util::remove_first_from_tuple_t = typedef typename remove_first_from_tuple<TupleT>::type

Alias for a tuple of types where the first type of the input tuple TupleT is removed.

Definition at line 392 of file Util.h.

◆ return_of_t

template<typename CallableT >
using Util::return_of_t = typedef typename member_fn_ptr_traits<CallableT>::return_type

Alias for the return type of a member function callable of type CallableT.

Definition at line 362 of file Util.h.

◆ seconds

using Util::seconds = typedef std::chrono::duration<double>

Extends std::chrono by a duration data type for seconds capable of storing fractions of seconds.

Definition at line 761 of file Util.h.

◆ TextListIndexType

using Util::TextListIndexType = typedef size_t

List index type of Util::TextListType.

Definition at line 30 of file QtUtil.h.

◆ TextListType

using Util::TextListType = typedef std::vector<TextType>

List type of text-type parameters.

Definition at line 29 of file QtUtil.h.

◆ TextRefType

using Util::TextRefType = typedef std::string_view

Reference-to-string type of text-type parameters (DynExp::ParamsBase::Param)

Definition at line 28 of file QtUtil.h.

◆ TextType

using Util::TextType = typedef std::string

String type of text-type parameters (DynExp::ParamsBase::Param)

Definition at line 27 of file QtUtil.h.

◆ TextValueListType

template<typename ValueType >
using Util::TextValueListType = typedef std::vector<std::pair<TextType, ValueType> >

Type of a list containing key-value pairs where key is a text of type Util::TextType.

Template Parameters
ValueTypeValue-type assocaited with a text-type key

Definition at line 37 of file QtUtil.h.

Enumeration Type Documentation

◆ ErrorType

enum Util::ErrorType
strong

DynExp's error types

Enumerator
Info 
Warning 
Error 
Fatal 

Definition at line 15 of file Exception.h.

Function Documentation

◆ ActivateWindow()

void Util::ActivateWindow ( QWidget &  Widget)

Renders a window active and brings it to the front.

Parameters
Widgetrepresenting a Qt (dialog) window

Definition at line 229 of file QtUtil.cpp.

◆ ComputeIntensityHistogram()

ImageHistogramType Util::ComputeIntensityHistogram ( const QImage &  Image)

Computes an intensity (grayscale) histogram from a QImage object.

Parameters
ImageImage to compute histogram from
Returns
Returns the histogram as an std::array.

Definition at line 171 of file QtUtil.cpp.

◆ ComputeRGBHistogram()

ImageRGBHistogramType Util::ComputeRGBHistogram ( const QImage &  Image)

Computes a RGB histogram from a QImage object.

Parameters
ImageImage to compute histogram from
Returns
Returns the RGB histogram as a std::tuple of three intensity histograms.

Definition at line 186 of file QtUtil.cpp.

◆ ConvertRGBToIntensityHistogram()

ImageHistogramType Util::ConvertRGBToIntensityHistogram ( const ImageRGBHistogramType RGBHistogram)

Computes an intensity (grayscale) histogram from a RGB histogram.

Parameters
RGBHistogramRGB histogram to compute the grayscale histogram from
Returns
Returns the grayscale histogram as an std::array.

Definition at line 204 of file QtUtil.cpp.

◆ CurrentTimeAndDateString()

auto Util::CurrentTimeAndDateString ( )
inline

Returns a human-readable string describing the current time and date in the current time zone.

Returns
Time and date string

Definition at line 839 of file Util.h.

◆ EventLog()

EventLogger & Util::EventLog ( )

This function holds a static EventLogger instance and returns a reference to it. DynExp uses only one EventLogger instance to log events from any thread. A local static object instead of a global object is employed to avoid initialization order problems.

Returns
Reference to DynExp's unique EventLogger instance

Definition at line 509 of file Util.cpp.

◆ ExceptionToStr()

std::string Util::ExceptionToStr ( const std::exception_ptr  ExceptionPtr)

Returns the what() information of an exception derived from std::exception and stored in an exception pointer.

Parameters
ExceptionPtrPointer to an exception derived from std::exception.
Returns
std::exception::what() if ExceptionPtr contains an exception. Empty string if ExceptionPtr does not contain an exception. Placeholder string if the exception stored in ExceptionPtr is not derived from std::exception.

Definition at line 189 of file Util.cpp.

◆ FFT()

std::vector< std::complex< double > > Util::FFT ( const std::vector< std::complex< double >> &  Data,
bool  InverseTransform = false 
)

Computes the Fast Fourier Transform (FFT) a vector of complex values.

Parameters
DataVector of complex values to be transformed
InverseTransformIf true, the inverse FFT is computed. False is default.
Returns
Vector of complex values containing the computed FFT
Exceptions
OverflowExceptionif Data contains more items than half of the maximal value size_t can represent.
NotAvailableExceptionif GSL functions fail reserving memory.
InvalidDataExceptionif GSL fails to perform the FFT on Data.

Definition at line 220 of file Util.cpp.

◆ FilenameFromPath()

auto Util::FilenameFromPath ( std::string  Path)
inline

Extracts the filename from a path.

Parameters
PathPath ending with a filename
Returns
Substring of Path containing the filename

Definition at line 846 of file Util.h.

◆ ForwardException()

void Util::ForwardException ( std::exception_ptr  e)

Wraps the exception passed to the function in a ForwardedException and throws the ForwardedException. Does nothing if e is not an exception.

Parameters
ePointer to an exception

Definition at line 30 of file Exception.cpp.

◆ GetChildDOMNodes()

std::vector< QDomNode > Util::GetChildDOMNodes ( const QDomElement &  Parent,
const QString &  ChildTagName 
)

Finds child nodes with a certain tag name.

Parameters
ParentParent node whose child nodes are searched
ChildTagNameTag name to search for
Returns
Returns a list of matching child nodes.
Exceptions
Util::InvalidDataExceptionis thrown when Parent is a null node.

Definition at line 19 of file QtUtil.cpp.

◆ GetDefaultQtLocale()

const QLocale & Util::GetDefaultQtLocale ( )

Returns the default locale properties to be assigned to Qt widgets.

Returns
QLocale object initialized with DynExp's default locale settings

Definition at line 12 of file QtUtil.cpp.

◆ GetDOMAttribute()

QDomAttr Util::GetDOMAttribute ( const QDomElement &  Element,
const QString &  AttributeName 
)

Extracts an attribute from a DOM element.

Parameters
ElementDOM element containing the attribute
AttributeNameName of the attribute to extract
Returns
Returns the matching attribute.
Exceptions
Util::InvalidDataExceptionis thrown if Element is null or if the requested attribute is invalid or does not exist.

Definition at line 87 of file QtUtil.cpp.

◆ GetSingleChildDOMElement()

QDomElement Util::GetSingleChildDOMElement ( const QDomElement &  Parent,
const QString &  ChildTagName 
)

Behaves like GetSingleChildDOMNode() but returns the node converted to a DOM element.

Parameters
ParentRefer to GetSingleChildDOMNode().
ChildTagNameRefer to GetSingleChildDOMNode().
Returns
Returns the matching child DOM element.
Exceptions
Util::InvalidDataExceptionis additionally thrown if the matching DOM element is null.

Definition at line 62 of file QtUtil.cpp.

◆ GetSingleChildDOMNode()

QDomNode Util::GetSingleChildDOMNode ( const QDomElement &  Parent,
const QString &  ChildTagName 
)

Finds a single child node with a certain tag name.

Parameters
ParentParent node whose child nodes are searched
ChildTagNameTag name to search for
Returns
Returns the matching child node.
Exceptions
Util::InvalidDataExceptionis thrown when Parent is a null node or when multiple child nodes with matching tag name have been found.
Util::NotFoundExceptionis thrown when not any matching node has been found.

Definition at line 36 of file QtUtil.cpp.

◆ GetStringFromDOMAttribute()

std::string Util::GetStringFromDOMAttribute ( const QDomElement &  Element,
const QString &  AttributeName 
)

Behaves like GetDOMAttribute() but returns the text from the attribute.

Parameters
ElementRefer to GetDOMAttribute().
AttributeNameRefer to GetDOMAttribute().
Returns
Text extracted from the matching attribute

Definition at line 99 of file QtUtil.cpp.

◆ GetStringFromDOMElement()

std::string Util::GetStringFromDOMElement ( const QDomElement &  Parent,
const QString &  ChildTagName 
)

Behaves like GetSingleChildDOMElement() but returns the text from a DOM element.

Parameters
ParentRefer to GetSingleChildDOMNode().
ChildTagNameRefer to GetSingleChildDOMNode().
Returns
Text extracted from a DOM element

Definition at line 73 of file QtUtil.cpp.

◆ GetTFromDOMAttribute()

template<>
std::string Util::GetTFromDOMAttribute ( const QDomElement &  Element,
const QString &  AttributeName 
)

Behaves like GetDOMAttribute() but returns the content from an attribute converted to a certain type using Util::StrToT().

Template Parameters
TType to convert the attribute's content to
Parameters
ElementRefer to GetDOMAttribute().
AttributeNameRefer to GetDOMAttribute().
Returns
Value of type T extracted from the matching attribute

Definition at line 108 of file QtUtil.cpp.

◆ GetTFromDOMElement()

template<>
std::string Util::GetTFromDOMElement ( const QDomElement &  Parent,
const QString &  ChildTagName 
)

Behaves like GetSingleChildDOMElement() but returns the content from a DOM element converted to a certain type using Util::StrToT().

Template Parameters
TType to convert the DOM element's content to
Parameters
ParentRefer to GetSingleChildDOMNode().
ChildTagNameRefer to GetSingleChildDOMNode().
Returns
Value of type T extracted from the matching DOM element

Definition at line 82 of file QtUtil.cpp.

◆ MakeCrossPolygon()

QPolygonF Util::MakeCrossPolygon ( QPointF  Center,
unsigned int  ArmLength 
)

Returns a QPolygonF representing a cross-style marker.

Parameters
CenterCenter coordinate of the marker
ArmLengthLength of one of the four arms of the cross.
Returns
Polygon representing the marker

Definition at line 216 of file QtUtil.cpp.

◆ NumToT() [1/2]

template<typename ToT , std::enable_if_t< std::is_integral_v< ToT > &&!std::is_same_v< std::remove_cv_t< ToT >, double >, int > = 0>
ToT Util::NumToT ( const double  Value)

Converts a value of a numeric type to a value of another numeric type checking the conversion for its bounds.

Template Parameters
ToTNumeric type to convert to
FromTNumeric type to convert from
Parameters
ValueValue to be converted
Returns
Converted value
Exceptions
OutOfRangeExceptionis thrown in case Value of type FromT does not fit into type ToT when both integral types, FromT and ToT, are either signed or unsigned.
OverflowExceptionis thrown in case the conversion of Value from type FromT to type ToT would yield an overflow when one of the types, FromT or ToT, is signed and the respective other type is unsigned or when FromT is non-integral.
UnderflowExceptionis thrown in case the conversion of Value from type FromT to type ToT would yield an underflow when one of the types, FromT or ToT, is signed and the respective other type is unsigned or when FromT is non-integral.

Definition at line 749 of file Util.h.

◆ NumToT() [2/2]

template<typename ToT , typename FromT , std::enable_if_t< std::is_integral_v< ToT > &&std::is_integral_v< FromT > &&std::is_same_v< std::remove_cv_t< ToT >, std::remove_cv_t< FromT >>, int > = 0>
ToT Util::NumToT ( const FromT  Value)
inline

Converts a value of a numeric type to a value of another numeric type checking the conversion for its bounds.

Template Parameters
ToTNumeric type to convert to
FromTNumeric type to convert from
Parameters
ValueValue to be converted
Returns
Converted value
Exceptions
OutOfRangeExceptionis thrown in case Value of type FromT does not fit into type ToT when both integral types, FromT and ToT, are either signed or unsigned.
OverflowExceptionis thrown in case the conversion of Value from type FromT to type ToT would yield an overflow when one of the types, FromT or ToT, is signed and the respective other type is unsigned or when FromT is non-integral.
UnderflowExceptionis thrown in case the conversion of Value from type FromT to type ToT would yield an underflow when one of the types, FromT or ToT, is signed and the respective other type is unsigned or when FromT is non-integral.

Definition at line 687 of file Util.h.

◆ operator<<() [1/2]

std::ostream & Util::operator<< ( std::ostream &  stream,
const Exception e 
)

Writes a DynExp exception in a user-readable way to a stream.

Parameters
streamStream to write to
eException to be logged to the stream
Returns
Returns the same stream which was passed to the operator.

Definition at line 17 of file Exception.cpp.

◆ operator<<() [2/2]

template<typename T >
std::ostream& Util::operator<< ( std::ostream &  stream,
const std::chrono::time_point< T > &  TimePoint 
)

Formats a time point to a human-readable string describing the time in the current time zone and writes the string to a stream.

Template Parameters
TTimePoint's clock type
Parameters
streamStream to write to
TimePointTime point to format and to write to stream
Returns
Stream which was passed to the function

Definition at line 588 of file Util.h.

◆ operator<=>()

std::strong_ordering Util::operator<=> ( const VersionType lhs,
const VersionType rhs 
)

Compares two program version types with each other.

Parameters
lhsLeft-hand side of the comparison
rhsRight-hand side of the comparison
Returns
Returns a std::strong_ordering object as the result of the comparison.

Definition at line 149 of file Util.cpp.

◆ ParseCSV()

template<typename... Ts>
std::vector<std::tuple<Ts...> > Util::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 column data into a vector of tuples.

Template Parameters
...TsData types of the columns
Parameters
CSVDatacsv data to parse
DelimiterDelimiter character the csv data is separated with
SkipLinesAmount of header lines (separated by '\n') to skip at the beginning of CSVData
Returns
Vector of parsed csv data

Definition at line 898 of file Util.h.

◆ PromptOpenFilePath()

QString Util::PromptOpenFilePath ( QWidget *  Parent,
const QString &  Title,
const QString &  DefaultSuffix,
const QString &  NameFilter,
const QString &  InitialDirectory = "" 
)

Opens a file dialog to ask the user to select a single existing file.

Parameters
ParentParent widget of this dialog
TitleTitle used for the dialog window
DefaultSuffixDefault file extension (e.g. ".dynp")
NameFilterFilter to select files (e.g. "DynExp project files (*.dynp)")
InitialDirectoryInitial directory to show in the dile dialog. If empty, the default directory is specified.
Returns
Returns the full path to the selected file or an empty string if the user cancels the dialog.

Definition at line 113 of file QtUtil.cpp.

◆ PromptSaveFilePath()

QString Util::PromptSaveFilePath ( QWidget *  Parent,
const QString &  Title,
const QString &  DefaultSuffix,
const QString &  NameFilter,
const QString &  InitialDirectory = "" 
)

Works as PromptOpenFilePath() but asks the user to select a single file which does not need to exist.

Parameters
ParentRefer to PromptOpenFilePath().
TitleRefer to PromptOpenFilePath().
DefaultSuffixRefer to PromptOpenFilePath().
NameFilterRefer to PromptOpenFilePath().
InitialDirectoryRefer to PromptOpenFilePath().
Returns
Refer to PromptOpenFilePath().

Definition at line 128 of file QtUtil.cpp.

◆ PromptSaveFilePathModule()

QString Util::PromptSaveFilePathModule ( DynExp::QModuleWidget Parent,
const QString &  Title,
const QString &  DefaultSuffix,
const QString &  NameFilter 
)

Works as PromptOpenFilePath() but asks the user to select a single file which does not need to exist. Furthermore, the dialog automatically derives the initial directory using QModuleWidget::GetDataSaveDirectory() and sets the new global directory for saving data to the folder containing the selected file when the user accepts the dialog.

Parameters
ParentRefer to PromptOpenFilePath().
TitleRefer to PromptOpenFilePath().
DefaultSuffixRefer to PromptOpenFilePath().
NameFilterRefer to PromptOpenFilePath().
Returns
Refer to PromptOpenFilePath().

Definition at line 143 of file QtUtil.cpp.

◆ QImageFromBlobData()

QImage Util::QImageFromBlobData ( BlobDataType &&  BlobData,
int  Width,
int  Height,
int  BytesPerLine,
QImage::Format  Format 
)

Converts raw pixel data stored in a Util::BlobDataType object to a QImage transfering the ownership of BlobData's content.

Parameters
BlobDataBinary large object containing pixel data
WidthWidth of the image represented by BlobData in pixels
HeightHeight of the image represented by BlobData in pixels
BytesPerLineNumber of bytes which represent a single row of pixels
FormatFormat of the pixel data stored in BlobData.
Returns
Returns the QImage constructed from raw pixel data.
Exceptions
Util::InvalidArgExceptionis thrown if any of Width, Height, or BytesPerLine is 0 or if Format is QImage::Format::Format_Invalid.

Definition at line 153 of file QtUtil.cpp.

◆ QtEnumToTextValueList()

template<typename EnumType >
auto Util::QtEnumToTextValueList ( unsigned short  SkipEntriesFront = 0,
unsigned short  SkipEntriesEnd = 0,
unsigned short  SkipCharsFront = 0,
unsigned short  SkipCharsEnd = 0 
)

Returns a TextValueListType containing entries which reflect the items (names and values) of an enumeration registered to Qt's meta-object system.

Template Parameters
EnumTypeEnumeration type to extract entries from. The enumeration type has to be registered to Qt's meta-object system with the Q_ENUM macro.
Parameters
SkipEntriesFrontNumber of enumeration entries to skip from the beginning of the enum declaration
SkipEntriesEndNumber of enumeration entries to skip from the end of the enum declaration
SkipCharsFrontNumber of characters to remove from the beginning of each enum entry's name
SkipCharsEndNumber of characters to remove from the end of each enum entry's name
Returns
List containing key-value pairs of EnumType's entries with entries skipped according to SkipEntriesFront and SkipEntriesEnd ans entry names trimmed according to SkipCharsFront and SkipCharsEnd.
Exceptions
Util::OutOfRangeExceptionis thrown when SkipEntriesFront and SkipEntriesEnd are incompatible with the actual amount of enum entries in EnumType.

Definition at line 55 of file QtUtil.h.

◆ ReadFromFile() [1/3]

std::string Util::ReadFromFile ( const QString &  Filename)

Reads the entire content from a text file.

Parameters
FilenameFull filename of the file to read from
Returns
Content read from the file
Exceptions
Util::FileIOErrorExceptionis thrown if the specified file cannot be opened.

Definition at line 250 of file QtUtil.cpp.

◆ ReadFromFile() [2/3]

std::string Util::ReadFromFile ( const std::filesystem::path &  Filename)

Reads the entire content from a text file.

Parameters
FilenameFull filename of the file to read from
Returns
Content read from the file
Exceptions
Util::FileIOErrorExceptionis thrown if the specified file cannot be opened.

Definition at line 267 of file QtUtil.cpp.

◆ ReadFromFile() [3/3]

std::string Util::ReadFromFile ( const std::string &  Filename)

Reads the entire content from a text file.

Parameters
FilenameFull filename of the file to read from
Returns
Content read from the file
Exceptions
Util::FileIOErrorExceptionis thrown if the specified file cannot be opened.

Definition at line 262 of file QtUtil.cpp.

◆ RemoveExtFromPath()

auto Util::RemoveExtFromPath ( std::string  Path)
inline

Removes the filename's extension from a path.

Parameters
PathPath ending with a filename
Returns
Substring of Path containing the original path and filename but no file extension

Definition at line 853 of file Util.h.

◆ SaveToFile()

bool Util::SaveToFile ( const QString &  Filename,
std::string_view  Text 
)

Saves a std::string_view to a file (using QFile). Creates a new file or truncates an existing file's content.

Parameters
FilenamePath of the file to write to.
TextContent to be written.
Returns
Returns true in case of success, otherwise false.

Definition at line 236 of file QtUtil.cpp.

◆ StrToT()

template<typename T >
T Util::StrToT ( const std::string &  String)

Converts a std::string to a value of type T using operator<< of std::stringstream.

Template Parameters
TType of the value the string should be converted to
Parameters
StringString to convert
Returns
Returns the converted value of type T.
Exceptions
InvalidDataExceptionis thrown in case of an incompatible conversion.

Definition at line 604 of file Util.h.

◆ ToLower()

std::string Util::ToLower ( std::string_view  Str)

Transforms a string into lower case.

Parameters
StrString to transform
Returns
Copy of the content of Str transformed to lower case

Definition at line 208 of file Util.cpp.

◆ ToStr() [1/6]

std::string Util::ToStr ( const char  Value)
inline

Converts Value to a std::string using operator<< of std::stringstream.

Parameters
ValueValue to convert
Returns
Returns Value converted to a string.

Definition at line 656 of file Util.h.

◆ ToStr() [2/6]

std::string Util::ToStr ( const QString &  Str)
inline

Converts the Qt QString Str to a std::string.

Parameters
StrString to convert
Returns
Returns Str converted to a string.

Definition at line 668 of file Util.h.

◆ ToStr() [3/6]

template<typename T >
std::string Util::ToStr ( const std::chrono::time_point< T > &  TimePoint)

Converts a time point to a human-readable string describing the time in the current time zone.

Template Parameters
TTimePoint's clock type
Parameters
TimePointTime point to format and to convert
Returns
Returns TimePoint converted to a string.

Definition at line 643 of file Util.h.

◆ ToStr() [4/6]

template<typename T >
std::string Util::ToStr ( const T &  Value,
int  Precision = -1 
)

Converts a (numeric) value of type T to a std::string using operator<< of std::stringstream.

Template Parameters
TType of the value to convert
Parameters
ValueValue to convert
PrecisionFixed precision of the numeric conversion for Precision >= 0. For any Precision < 0 (default) the precision is not set.
Returns
Returns Value converted to a string.

Definition at line 625 of file Util.h.

◆ ToStr() [5/6]

std::string Util::ToStr ( const uint8_t  Value)
inline

Converts Value to a std::string using operator<< of std::stringstream.

Parameters
ValueValue to convert
Returns
Returns Value converted to a string.

Definition at line 661 of file Util.h.

◆ ToStr() [6/6]

std::string Util::ToStr ( const VersionType Version)
inline

Converts a program version to a string in the form specified by VersionType.

Parameters
VersionProgram version to convert
Returns
String containing the program version

Definition at line 886 of file Util.h.

◆ ToUnitStr()

template<typename T >
std::string Util::ToUnitStr ( )
inline

Returns a string describing the physical unit associated with type T. For example, if T is std::chrono::milliseconds, the function returns the string "ms".

Template Parameters
TType which has a physical unit associated with
Returns
String describing the abbreviation of a physical unit

◆ ToUnitStr< picoseconds >()

template<>
std::string Util::ToUnitStr< picoseconds > ( )
inline

Returns a string describing the physical unit associated with type T. For example, if T is std::chrono::milliseconds, the function returns the string "ms".

Template Parameters
TType which has a physical unit associated with
Returns
String describing the abbreviation of a physical unit

Definition at line 822 of file Util.h.

◆ ToUnitStr< seconds >()

template<>
std::string Util::ToUnitStr< seconds > ( )
inline

Returns a string describing the physical unit associated with type T. For example, if T is std::chrono::milliseconds, the function returns the string "ms".

Template Parameters
TType which has a physical unit associated with
Returns
String describing the abbreviation of a physical unit

Definition at line 813 of file Util.h.

◆ ToUnitStr< std::chrono::microseconds >()

template<>
std::string Util::ToUnitStr< std::chrono::microseconds > ( )
inline

Returns a string describing the physical unit associated with type T. For example, if T is std::chrono::milliseconds, the function returns the string "ms".

Template Parameters
TType which has a physical unit associated with
Returns
String describing the abbreviation of a physical unit

Definition at line 795 of file Util.h.

◆ ToUnitStr< std::chrono::milliseconds >()

template<>
std::string Util::ToUnitStr< std::chrono::milliseconds > ( )
inline

Returns a string describing the physical unit associated with type T. For example, if T is std::chrono::milliseconds, the function returns the string "ms".

Template Parameters
TType which has a physical unit associated with
Returns
String describing the abbreviation of a physical unit

Definition at line 786 of file Util.h.

◆ ToUnitStr< std::chrono::nanoseconds >()

template<>
std::string Util::ToUnitStr< std::chrono::nanoseconds > ( )
inline

Returns a string describing the physical unit associated with type T. For example, if T is std::chrono::milliseconds, the function returns the string "ms".

Template Parameters
TType which has a physical unit associated with
Returns
String describing the abbreviation of a physical unit

Definition at line 804 of file Util.h.

◆ ToUnitStr< std::chrono::seconds >()

template<>
std::string Util::ToUnitStr< std::chrono::seconds > ( )
inline

Returns a string describing the physical unit associated with type T. For example, if T is std::chrono::milliseconds, the function returns the string "ms".

Template Parameters
TType which has a physical unit associated with
Returns
String describing the abbreviation of a physical unit

Definition at line 777 of file Util.h.

◆ TrimTrailingZeros()

std::string Util::TrimTrailingZeros ( const std::string &  Str)
inline

Removes trailing zeros ('\0') from a string.

Parameters
StrString to remove zeros from
Returns
String with trailing zeros removed

Definition at line 833 of file Util.h.

◆ VersionFromString()

VersionType Util::VersionFromString ( std::string_view  Str)

Extracts a program version from a string.

Parameters
StrString containing a programm version in the form specified by VersionType
Returns
VersionType object containing the extracted program version
Exceptions
InvalidDataExceptionif Str does not contain a valid version number.

Definition at line 162 of file Util.cpp.

Variable Documentation

◆ is_contained_in_v

template<typename T , typename... ListTs>
constexpr bool Util::is_contained_in_v = is_contained_in<T, ListTs...>::value
inlineconstexpr

Value type of is_contained_in.

Definition at line 303 of file Util.h.

◆ PyTab

constexpr auto Util::PyTab = " "
staticconstexpr

Character sequence to indent a Python instruction by one level.

Definition at line 19 of file PyUtil.h.