8#ifndef QU_GLOBAL_UTILS_H
9#define QU_GLOBAL_UTILS_H
28 static_assert(std::is_enum<T>::value,
29 "template parameter is not an enum type");
31 return static_cast<T
>(
static_cast<int>(lhs) |
static_cast<int>(rhs));
45 static_assert(std::is_enum<T>::value,
46 "template parameter is not an enum type");
48 return static_cast<T
>(
static_cast<int>(lhs) &
static_cast<int>(rhs));
62 static_assert(std::is_enum<T>::value,
63 "template parameter is not an enum type");
65 return static_cast<T
>(
static_cast<int>(lhs) >>
static_cast<int>(rhs));
79 static_assert(std::is_enum<T>::value,
80 "template parameter is not an enum type");
82 return static_cast<T
>(
static_cast<int>(lhs) <<
static_cast<int>(rhs));
95 static_assert(std::is_enum<T>::value,
96 "template parameter is not an enum type");
98 return static_cast<T
>(~static_cast<int>(lhs));
112 static_assert(std::is_enum<T>::value,
113 "template parameter is not an enum type");
115 return static_cast<T
>(
static_cast<int>(lhs) ^
static_cast<int>(rhs));
126 return typeid (T).hash_code();
137 return typeid (T).hash_code() % 0xFFFF;
148 return typeid (T).hash_code() % 0xFF;
158 return typeid (object).hash_code();
168 return typeid (object).hash_code() % 0xFFFF;
178 return typeid (object).hash_code() % 0xFF;
182#define H_8 static_type_hash_8
185#define H_16 static_type_hash_16
188#define H_32 static_type_hash_32
197#define debug_assert(C, M) Q_ASSERT(C && M)
228template <
class QHashType>
229QHashType &
subtract(QHashType &left,
const QHashType& right) {
230 if (left.isSharedWith(right)) {
233 for (
auto&& it = right.begin(); it != right.end(); ++it)
234 left.remove(it.key());
260template <
class QHashType>
261QHashType &
unite(QHashType &left,
const QHashType& right) {
262 if (!left.isSharedWith(right)) {
263 for (
auto&& it = right.begin(); it != right.end(); ++it)
264 left.insert(it.key(), it.value());
290template <
class QHashType>
291QHashType &
match(QHashType &left,
const QHashType& right) {
292 if (!left.isSharedWith(right)) {
293 for (
auto&& it = left.begin(); it != left.end(); ) {
294 if (!right.contains(it.key())) {
void randomArray(int size, QByteArray &result)
randomArray This function return random arrat with size size
constexpr T operator>>(T lhs, T rhs)
operator >> This operator returns the right shift of an enum value of type T by rhs positions.
QHashType & unite(QHashType &left, const QHashType &right)
Simplified union operation for QHash.
QHashType & match(QHashType &left, const QHashType &right)
Simplified match (intersection) operation for QHash.
constexpr T operator^(T lhs, T rhs)
operator ^ This operator returns the bitwise XOR of two enum values of type T.
constexpr T operator&(T lhs, T rhs)
operator & This operator returns the bitwise AND of two enum values of type 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 s...
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 st...
constexpr T operator~(T lhs)
operator ~ This operator returns the bitwise complement of an enum value of type 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.
constexpr T operator|(T lhs, T rhs)
operator | This operator returns the bitwise OR of two enum values of type T.
QHashType & subtract(QHashType &left, const QHashType &right)
Simplified subtraction operation for QHash.
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 s...
#define QUASARAPPSHARED_EXPORT