QuasarAppLib
qaglobalutils.cpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2018-2025 QuasarApp.
3 * Distributed under the lgplv3 software license, see the accompanying
4 * Everyone is permitted to copy and distribute verbatim copies
5 * of this license document, but changing it is not allowed.
6*/
7
8#include "qaglobalutils.h"
9#include <limits>
10
11template<class NUM>
12void gen(int size, QByteArray &result) {
13 for (; size > 0; size -= sizeof(NUM)) {
14 NUM random = (rand() * rand()) % std::numeric_limits<NUM>::max();
15 result.insert(0, reinterpret_cast<char*>(&random), sizeof(random));
16 }
17}
18// to do. The random function should generate 4 bit numbers anywhere except last number
19void randomArray(int size, QByteArray &result) {
20 if (size % sizeof(unsigned long long) == 0) {
22 } else if (size % sizeof(unsigned int) == 0) {
24 } else if (size % sizeof(unsigned short) == 0) {
26 } else {
28 }
29}
void gen(int size, QByteArray &result)
void randomArray(int size, QByteArray &result)
randomArray This function return random arrat with size size