QuasarAppLib 1.0.530.c9fba11
qaglobalutils.h File Reference
#include <type_traits>
#include <typeinfo>
#include <QByteArray>
#include "QtGlobal"
#include "quasarapp_global.h"
Include dependency graph for qaglobalutils.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Macros

#define H_8   static_type_hash_8
 H_8 This is short wrapper of the static_type_hash_8 function.
#define H_16   static_type_hash_16
 H_16 This is short wrapper of the static_type_hash_16 function.
#define H_32   static_type_hash_32
 H_32 This is short wrapper of the static_type_hash_32 function.
#define debug_assert(C, M)
 debug_assert This is a debug macro that asserts the condition C and the message M. The assertion is active only in debug builds and aborts the application if the condition is not met.

Functions

template<typename T>
constexpr T operator| (T lhs, T rhs)
 operator | This operator returns the bitwise OR of two enum values of type T.
template<typename T>
constexpr T operator& (T lhs, T rhs)
 operator & This operator returns the bitwise AND of two enum values of type T.
template<typename T>
constexpr T operator>> (T lhs, T rhs)
 operator >> This operator returns the right shift of an enum value of type T by rhs positions.
template<typename T>
constexpr T operator<< (T lhs, T rhs)
 operator << This operator returns the left shift of an enum value of type T by rhs positions.
template<typename T>
constexpr T operator~ (T lhs)
 operator ~ This operator returns the bitwise complement of an enum value of type T.
template<typename T>
constexpr T operator^ (T lhs, T rhs)
 operator ^ This operator returns the bitwise XOR of two enum values of type T.
template<class T>
uint32_t static_type_hash_32 () noexcept
 static_type_hash_32 This function return hash code of the class T. For get more information see the std documentation.
template<class T>
uint16_t static_type_hash_16 () noexcept
 static_type_hash_16 This function return hash code of the class T. For get more information see the std documentation.
template<class T>
uint8_t static_type_hash_8 () noexcept
 static_type_hash_8 This function return hash code of the class T. For get more information see the std documentation.
template<class T>
uint32_t static_type_hash_32 (T &object) noexcept
 static_type_hash_32 This function return hash code of a T type using object.
template<class T>
uint16_t static_type_hash_16 (T &object) noexcept
 static_type_hash_16 This function return hash code of a T type using object.
template<class T>
uint8_t static_type_hash_8 (T &object) noexcept
 static_type_hash_8 This function return hash code of a T type using object.
void QUASARAPPSHARED_EXPORT randomArray (int size, QByteArray &result)
 randomArray This function return random arrat with size size
template<class QHashType>
QHashType & subtract (QHashType &left, const QHashType &right)
 Simplified subtraction operation for QHash.
template<class QHashType>
QHashType & unite (QHashType &left, const QHashType &right)
 Simplified union operation for QHash.
template<class QHashType>
QHashType & match (QHashType &left, const QHashType &right)
 Simplified match (intersection) operation for QHash.

Macro Definition Documentation

◆ debug_assert

#define debug_assert ( C,
M )
Value:
Q_ASSERT(C && M)

debug_assert This is a debug macro that asserts the condition C and the message M. The assertion is active only in debug builds and aborts the application if the condition is not met.

Parameters
CThis is the checked condition.
MThis is the message that will be printed if the condition is not met.

Definition at line 197 of file qaglobalutils.h.

◆ H_16

#define H_16   static_type_hash_16

H_16 This is short wrapper of the static_type_hash_16 function.

Definition at line 185 of file qaglobalutils.h.

◆ H_32

#define H_32   static_type_hash_32

H_32 This is short wrapper of the static_type_hash_32 function.

Definition at line 188 of file qaglobalutils.h.

◆ H_8

#define H_8   static_type_hash_8

H_8 This is short wrapper of the static_type_hash_8 function.

Definition at line 182 of file qaglobalutils.h.

Function Documentation

◆ match()

template<class QHashType>
QHashType & match ( QHashType & left,
const QHashType & right )

Simplified match (intersection) operation for QHash.

This function provides a convenient way to keep only the elements of one QHash whose keys are also present in another QHash. It's designed to simplify common QHash operations.

The function modifies the left QHash by removing all key-value pairs whose keys are NOT present in the right QHash. After the call left contains only the intersection of the keys of left and right.

If left and right share the same internal data (i.e., left.isSharedWith(right) returns true), the left hash is cleared entirely to prevent unpredictable behavior or unintended modifications to the shared data.

Template Parameters
QHashTypeThe type of the QHash (e.g., QHash<QString, int>).
Parameters
leftA reference to the QHash to be modified. Elements whose keys are not present in right will be removed from this hash.
rightA constant reference to the QHash containing the keys to be matched against.
Returns
A reference to the modified left QHash.

Definition at line 291 of file qaglobalutils.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ operator&()

template<typename T>
T operator& ( T lhs,
T rhs )
inlineconstexpr

operator & This operator returns the bitwise AND of two enum values of type T.

Parameters
lhsThis is the left operand of the bitwise AND operation.
rhsThis is the right operand of the bitwise AND operation.
Returns
bitwise AND result of lhs and rhs as enum value of type T.
Note
The template parameter T must be an enum type, otherwise a static_assert error is triggered.

Definition at line 42 of file qaglobalutils.h.

◆ operator<<()

template<typename T>
T operator<< ( T lhs,
T rhs )
inlineconstexpr

operator << This operator returns the left shift of an enum value of type T by rhs positions.

Parameters
lhsThis is the operand of the left shift operation.
rhsThis is the count of shifted positions.
Returns
left shifted result of lhs as enum value of type T.
Note
The template parameter T must be an enum type, otherwise a static_assert error is triggered.

Definition at line 76 of file qaglobalutils.h.

◆ operator>>()

template<typename T>
T operator>> ( T lhs,
T rhs )
inlineconstexpr

operator >> This operator returns the right shift of an enum value of type T by rhs positions.

Parameters
lhsThis is the operand of the right shift operation.
rhsThis is the count of shifted positions.
Returns
right shifted result of lhs as enum value of type T.
Note
The template parameter T must be an enum type, otherwise a static_assert error is triggered.

Definition at line 59 of file qaglobalutils.h.

◆ operator^()

template<typename T>
T operator^ ( T lhs,
T rhs )
inlineconstexpr

operator ^ This operator returns the bitwise XOR of two enum values of type T.

Parameters
lhsThis is the left operand of the bitwise XOR operation.
rhsThis is the right operand of the bitwise XOR operation.
Returns
bitwise XOR result of lhs and rhs as enum value of type T.
Note
The template parameter T must be an enum type, otherwise a static_assert error is triggered.

Definition at line 109 of file qaglobalutils.h.

◆ operator|()

template<typename T>
T operator| ( T lhs,
T rhs )
inlineconstexpr

operator | This operator returns the bitwise OR of two enum values of type T.

Parameters
lhsThis is the left operand of the bitwise OR operation.
rhsThis is the right operand of the bitwise OR operation.
Returns
bitwise OR result of lhs and rhs as enum value of type T.
Note
The template parameter T must be an enum type, otherwise a static_assert error is triggered.

Definition at line 25 of file qaglobalutils.h.

◆ operator~()

template<typename T>
T operator~ ( T lhs)
inlineconstexpr

operator ~ This operator returns the bitwise complement of an enum value of type T.

Parameters
lhsThis is the operand of the bitwise complement operation.
Returns
bitwise complement result of lhs as enum value of type T.
Note
The template parameter T must be an enum type, otherwise a static_assert error is triggered.

Definition at line 92 of file qaglobalutils.h.

◆ randomArray()

void QUASARAPPSHARED_EXPORT randomArray ( int size,
QByteArray & result )

randomArray This function return random arrat with size size

Parameters
sizeThis is size of needed array.
resultThis is result value of generated array.

Definition at line 19 of file qaglobalutils.cpp.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ static_type_hash_16() [1/2]

template<class T>
uint16_t static_type_hash_16 ( )
noexcept

static_type_hash_16 This function return hash code of the class T. For get more information see the std documentation.

Note
This method will create a T object on stack, so if you have a already created object use the static_type_hash_16(const T&) function.
Returns
uint16_t hash code of the class T

Definition at line 136 of file qaglobalutils.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ static_type_hash_16() [2/2]

template<class T>
uint16_t static_type_hash_16 ( T & object)
noexcept

static_type_hash_16 This function return hash code of a T type using object.

Parameters
objectThis is object of the T type using for generate hash.
Returns
uint16_t hash code of the class T

Definition at line 167 of file qaglobalutils.h.

Here is the call graph for this function:

◆ static_type_hash_32() [1/2]

template<class T>
uint32_t static_type_hash_32 ( )
noexcept

static_type_hash_32 This function return hash code of the class T. For get more information see the std documentation.

Note
This method will create a T object on stack, so if you have a already created object use the static_type_hash_32(const T&) function.
Returns
uint32_t hash code of the class T

Definition at line 125 of file qaglobalutils.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ static_type_hash_32() [2/2]

template<class T>
uint32_t static_type_hash_32 ( T & object)
noexcept

static_type_hash_32 This function return hash code of a T type using object.

Parameters
objectThis is object of the T type using for generate hash.
Returns
uint32_t hash code of the class T

Definition at line 157 of file qaglobalutils.h.

Here is the call graph for this function:

◆ static_type_hash_8() [1/2]

template<class T>
uint8_t static_type_hash_8 ( )
noexcept

static_type_hash_8 This function return hash code of the class T. For get more information see the std documentation.

Note
This method will create a T object on stack, so if you have a already created object use the static_type_hash_8(const T&) function.
Returns
uint8_t hash code of the class T

Definition at line 147 of file qaglobalutils.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ static_type_hash_8() [2/2]

template<class T>
uint8_t static_type_hash_8 ( T & object)
noexcept

static_type_hash_8 This function return hash code of a T type using object.

Parameters
objectThis is object of the T type using for generate hash.
Returns
uint8_t hash code of the class T

Definition at line 177 of file qaglobalutils.h.

Here is the call graph for this function:

◆ subtract()

template<class QHashType>
QHashType & subtract ( QHashType & left,
const QHashType & right )

Simplified subtraction operation for QHash.

This function provides a convenient way to remove elements from one QHash based on keys present in another QHash. It's designed to simplify common QHash operations.

The function modifies the left QHash by removing all key-value pairs whose keys are present in the right QHash.

If left and right share the same internal data (i.e., left.isSharedWith(right) returns true), the left hash is cleared entirely to prevent unpredictable behavior or unintended modifications to the shared data. Otherwise, it iterates through right and removes corresponding keys from left.

Template Parameters
QHashTypeThe type of the QHash (e.g., QHash<QString, int>).
Parameters
leftA reference to the QHash to be modified. Elements present in right will be removed from this hash.
rightA constant reference to the QHash containing keys to be removed from left.
Returns
A reference to the modified left QHash.

Definition at line 229 of file qaglobalutils.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ unite()

template<class QHashType>
QHashType & unite ( QHashType & left,
const QHashType & right )

Simplified union operation for QHash.

This function provides a convenient way to unite the elements of two QHash objects, adding all elements from one to the other. It's designed to simplify common QHash operations.

The function modifies the left QHash by inserting all key-value pairs from the right QHash. If a key from right already exists in left, its corresponding value in left will be updated with the value from right.

This operation is skipped if left and right share the same internal data (i.e., left.isSharedWith(right) returns true) to avoid self-modification or infinite loops in cases of shared data.

Template Parameters
QHashTypeThe type of the QHash (e.g., QHash<QString, int>).
Parameters
leftA reference to the QHash to be modified. Elements from right will be inserted into this hash.
rightA constant reference to the QHash whose elements will be added to left.
Returns
A reference to the modified left QHash.

Definition at line 261 of file qaglobalutils.h.

Here is the call graph for this function:
Here is the caller graph for this function: