diff options
| author | Ahmad Samir <a.samirh78@gmail.com> | 2023-01-17 20:54:52 +0200 |
|---|---|---|
| committer | Ahmad Samir <a.samirh78@gmail.com> | 2023-02-07 20:04:11 +0200 |
| commit | 498f3452285aa44580e1d03baeec126d475f8401 (patch) | |
| tree | 6307934b58045f6b6761023f769844d87cdc63ca /src/corelib/serialization/qxmlutils.cpp | |
| parent | 9a8b9473d5f0fd4639193481ba9b344d91f3f00a (diff) | |
QtMiscUtils: add some more character helpers
isHexDigit, isOctalDigit, isAsciiDigit, isAsciiLower, isAsciiUpper,
isAsciiLetterOrNumber.
This de-duplicates some code through out.
Rename two local lambdas that were called "isAsciiLetterOrNumber" to not
conflict with the method in QtMiscUtils.
Change-Id: I5b631f95b9f109136d19515f7e20b8e2fbca3d43
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/serialization/qxmlutils.cpp')
| -rw-r--r-- | src/corelib/serialization/qxmlutils.cpp | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/src/corelib/serialization/qxmlutils.cpp b/src/corelib/serialization/qxmlutils.cpp index 778e8de72de..00a1121280d 100644 --- a/src/corelib/serialization/qxmlutils.cpp +++ b/src/corelib/serialization/qxmlutils.cpp @@ -5,8 +5,12 @@ #include "qxmlutils_p.h" +#include <private/qtools_p.h> + QT_BEGIN_NAMESPACE +using namespace QtMiscUtils; + /* TODO: * - isNameChar() doesn't have to be public, it's only needed in * qdom.cpp -- refactor fixedXmlName() to use isNCName() @@ -197,16 +201,12 @@ bool QXmlUtils::isEncName(QStringView encName) if (encName.isEmpty()) return false; const auto first = encName.front().unicode(); - if (!((first >= 'a' && first <= 'z') || (first >= 'A' && first <= 'Z'))) + if (!(isAsciiLower(first) || isAsciiUpper(first))) return false; for (QChar ch : encName.mid(1)) { const auto cp = ch.unicode(); - if ((cp >= 'a' && cp <= 'z') - || (cp >= 'A' && cp <= 'Z') - || (cp >= '0' && cp <= '9') - || cp == '.' || cp == '_' || cp == '-') { + if (isAsciiLetterOrNumber(cp) || cp == '.' || cp == '_' || cp == '-') continue; - } return false; } return true; @@ -285,12 +285,8 @@ bool QXmlUtils::isPublicID(QStringView candidate) for (QChar ch : candidate) { const ushort cp = ch.unicode(); - if ((cp >= 'a' && cp <= 'z') - || (cp >= 'A' && cp <= 'Z') - || (cp >= '0' && cp <= '9')) - { + if (isAsciiLetterOrNumber(cp)) continue; - } switch (cp) { |
