Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qtools_p.h File Reference
#include "QtCore/private/qglobal_p.h"
#include <chrono>
#include <limits.h>
#include <time.h>
+ Include dependency graph for qtools_p.h:

Go to the source code of this file.

Classes

struct  CalculateGrowingBlockSizeResult
 

Namespaces

namespace  QtMiscUtils
 

Functions

constexpr char QtMiscUtils::toHexUpper (char32_t value) noexcept
 
constexpr char QtMiscUtils::toHexLower (char32_t value) noexcept
 
constexpr bool QtMiscUtils::isHexDigit (char32_t c) noexcept
 
constexpr int QtMiscUtils::fromHex (char32_t c) noexcept
 
constexpr char QtMiscUtils::toOct (char32_t value) noexcept
 
constexpr bool QtMiscUtils::isOctalDigit (char32_t c) noexcept
 
constexpr int QtMiscUtils::fromOct (char32_t c) noexcept
 
constexpr bool QtMiscUtils::isAsciiDigit (char32_t c) noexcept
 
constexpr bool QtMiscUtils::isAsciiUpper (char32_t c) noexcept
 
constexpr bool QtMiscUtils::isAsciiLower (char32_t c) noexcept
 
constexpr bool QtMiscUtils::isAsciiLetterOrNumber (char32_t c) noexcept
 
constexpr char QtMiscUtils::toAsciiLower (char ch) noexcept
 
constexpr char QtMiscUtils::toAsciiUpper (char ch) noexcept
 
constexpr int QtMiscUtils::caseCompareAscii (char lhs, char rhs) noexcept
 
constexpr int QtMiscUtils::isAsciiPrintable (char32_t ch) noexcept
 
constexpr int QtMiscUtils::qt_lencmp (qsizetype lhs, qsizetype rhs) noexcept
 
qsizetype Q_CORE_EXPORT Q_DECL_CONST_FUNCTION qCalculateBlockSize (qsizetype elementCount, qsizetype elementSize, qsizetype headerSize=0) noexcept
 
CalculateGrowingBlockSizeResult Q_CORE_EXPORT Q_DECL_CONST_FUNCTION qCalculateGrowingBlockSize (qsizetype elementCount, qsizetype elementSize, qsizetype headerSize=0) noexcept
 

Variables

constexpr qsizetype MaxAllocSize = (std::numeric_limits<qsizetype>::max)()
 

Function Documentation

◆ qCalculateBlockSize()

qsizetype Q_CORE_EXPORT Q_DECL_CONST_FUNCTION qCalculateBlockSize ( qsizetype  elementCount,
qsizetype  elementSize,
qsizetype  headerSize 
)
noexcept
Since
5.7

Returns the memory block size for a container containing elementCount elements, each of elementSize bytes, plus a header of headerSize bytes. That is, this function returns {elementCount * elementSize + headerSize}

but unlike the simple calculation, it checks for overflows during the multiplication and the addition.

Both elementCount and headerSize can be zero, but elementSize cannot.

This function returns -1 on overflow or if the memory block size would not fit a qsizetype.

Definition at line 52 of file qarraydata.cpp.

References headerSize, Q_ASSERT, Q_UNLIKELY, qAddOverflow(), and qMulOverflow().

Referenced by calculateBlockSize(), and qCalculateGrowingBlockSize().

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

◆ qCalculateGrowingBlockSize()

CalculateGrowingBlockSizeResult Q_CORE_EXPORT Q_DECL_CONST_FUNCTION qCalculateGrowingBlockSize ( qsizetype  elementCount,
qsizetype  elementSize,
qsizetype  headerSize 
)
noexcept
Since
5.7

Returns the memory block size and the number of elements that will fit in that block for a container containing elementCount elements, each of elementSize bytes, plus a header of headerSize bytes. This function assumes the container will grow and pre-allocates a growth factor.

Both elementCount and headerSize can be zero, but elementSize cannot.

This function returns -1 on overflow or if the memory block size would not fit a qsizetype.

Note
The memory block may contain up to elementSize - 1 bytes more than needed.

Definition at line 85 of file qarraydata.cpp.

References headerSize, Q_UNLIKELY, qCalculateBlockSize(), and qNextPowerOfTwo().

Referenced by calculateBlockSize().

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

Variable Documentation

◆ MaxAllocSize

constexpr qsizetype MaxAllocSize = (std::numeric_limits<qsizetype>::max)()
constexpr

Definition at line 119 of file qtools_p.h.