6#include "private/qlocale_tools_p.h"
7#include "private/qtools_p.h"
25 const auto *
const ubegin =
reinterpret_cast<const char16_t *
>(
begin);
26 const auto *
const uend =
reinterpret_cast<const char16_t *
>(
end);
29 buffer.resize(uend - ubegin + 1);
34 return reinterpret_cast<const QChar *
>(
src);
58 while (dotCount < 4) {
59 if (!acceptLeadingZero && *
ptr ==
'0' &&
60 ptr[1] !=
'.' &&
ptr[1] !=
'\0')
65 if (used <= 0 || ll !=
x)
68 if (
ptr[used] ==
'.' || dotCount == 3) {
72 }
else if (dotCount == 2) {
76 }
else if (dotCount == 1) {
83 if (dotCount == 3 ||
ptr[used] ==
'\0')
84 return ptr[used] ==
'\0';
123 const char *
const stop =
ptr +
buffer.size();
136 if (dotCount != 0 && dotCount != 3)
140 if (colonCount == 2 &&
end -
begin == 2)
149 if ((
ptr[0] ==
':' &&
ptr[1] ==
':') ||
151 zeroWordsToFill = 9 - colonCount;
152 }
else if (colonCount < 2 || colonCount > 7) {
155 zeroWordsToFill = 8 - colonCount;
164 if (zeroWordsToFill < 1)
166 if (
pos == 0 ||
pos == colonCount * 2) {
167 if (
ptr[0] ==
'\0' ||
ptr[1] !=
':')
171 pos += zeroWordsToFill * 2;
183 if (used <= 0 || used > 4)
186 if (
ptr[used] ==
'.') {
206 if (
ptr[used] ==
'\0')
208 if (
ptr[used] !=
':')
229 static const int Ip6AddressMaxLen =
sizeof "1111:2222:3333:4444:5555:6666:7777:8888";
230 static const int Ip6WithIp4AddressMaxLen =
sizeof "::ffff:255.255.255.255";
233 const quint64 zeroes[] = { 0, 0 };
234 bool embeddedIp4 =
false;
239 if (memcmp(
address, zeroes, 10) == 0) {
254 (embeddedIp4 ? Ip6WithIp4AddressMaxLen : Ip6AddressMaxLen));
257 int zeroRunLength = 0;
258 int zeroRunOffset = 0;
259 for (
int i = 0;
i < 16;
i += 2) {
263 for (
j =
i;
j < 16;
j += 2) {
268 if (
j -
i > zeroRunLength) {
269 zeroRunLength =
j -
i;
276 const QChar colon = u
':';
277 if (zeroRunLength < 4)
279 else if (zeroRunOffset == 0)
282 for (
int i = 0;
i < 16;
i += 2) {
283 if (
i == zeroRunOffset) {
285 i += zeroRunLength - 2;
289 if (
i == 12 && embeddedIp4) {
static constexpr QChar fromLatin1(char c) noexcept
Converts the Latin-1 character c to its equivalent QChar.
\macro QT_RESTRICTED_CAST_FROM_ASCII
void reserve(qsizetype size)
Ensures the string has space for at least size characters.
qsizetype size() const
Returns the number of characters in this string.
QString & append(QChar c)
static bool parseIp4Internal(IPv4Address &address, const char *ptr, bool acceptLeadingZero)
void toString(QString &appendTo, IPv4Address address)
bool parseIp4(IPv4Address &address, const QChar *begin, const QChar *end)
static QChar toHex(uchar c)
QVarLengthArray< char, 64 > Buffer
const QChar * parseIp6(IPv6Address &address, const QChar *begin, const QChar *end)
static const QChar * checkedToAscii(Buffer &buffer, const QChar *begin, const QChar *end)
Combined button and popup list for selecting options.
constexpr char toHexLower(char32_t value) noexcept
size_t qstrlen(const char *str)
static ControlElement< T > * ptr(QWidget *widget)
GLint GLint GLint GLint GLint x
[0]
GLuint GLuint64EXT address
QtPrivate::QRegularExpressionMatchIteratorRangeBasedForIterator begin(const QRegularExpressionMatchIterator &iterator)
#define QStringLiteral(str)
unsigned long long quint64