1 /*
2  * DQt - D bindings for the Qt Toolkit
3  *
4  * GNU Lesser General Public License Usage
5  * This file may be used under the terms of the GNU Lesser
6  * General Public License version 3 as published by the Free Software
7  * Foundation and appearing in the file LICENSE.LGPL3 included in the
8  * packaging of this file. Please review the following information to
9  * ensure the GNU Lesser General Public License version 3 requirements
10  * will be met: https://www.gnu.org/licenses/lgpl-3.0.html.
11  */
12 module qt.core.bytearrayalgorithms;
13 extern(C++):
14 
15 import qt.config;
16 import qt.core.bytearrayview;
17 import qt.core.global;
18 import qt.core.namespace;
19 import qt.helpers;
20 
21 /+ #if 0
22 #pragma qt_class(QByteArrayAlgorithms)
23 #endif +/
24 
25 
26 
27 extern(C++, "QtPrivate") {
28 
29 /+ [[nodiscard]] +/ /+ Q_CORE_EXPORT +/ /+ Q_DECL_PURE_FUNCTION +/
30 bool startsWith(QByteArrayView haystack, QByteArrayView needle)/+ noexcept+/;
31 
32 /+ [[nodiscard]] +/ /+ Q_CORE_EXPORT +/ /+ Q_DECL_PURE_FUNCTION +/
33 bool endsWith(QByteArrayView haystack, QByteArrayView needle)/+ noexcept+/;
34 
35 /+ [[nodiscard]] +/ /+ Q_CORE_EXPORT +/ /+ Q_DECL_PURE_FUNCTION +/
36 qsizetype findByteArray(QByteArrayView haystack, qsizetype from, QByteArrayView needle)/+ noexcept+/;
37 
38 /+ [[nodiscard]] +/ /+ Q_CORE_EXPORT +/ /+ Q_DECL_PURE_FUNCTION +/
39 qsizetype lastIndexOf(QByteArrayView haystack, qsizetype from, QByteArrayView needle)/+ noexcept+/;
40 
41 /+ [[nodiscard]] +/ /+ Q_CORE_EXPORT +/ /+ Q_DECL_PURE_FUNCTION +/
42 qsizetype count(QByteArrayView haystack, QByteArrayView needle)/+ noexcept+/;
43 
44 /+ [[nodiscard]] +/ /+ Q_CORE_EXPORT +/ int compareMemory(QByteArrayView lhs, QByteArrayView rhs);
45 
46 } // namespace QtPrivate
47 
48 /*****************************************************************************
49   Safe and portable C string functions; extensions to standard string.h
50  *****************************************************************************/
51 
52 /+ Q_CORE_EXPORT +/ char* qstrdup(const(char)* );
53 
54 pragma(inline, true) size_t qstrlen(const(char)* str)
55 {
56     import core.stdc.string;
57 
58     /+ QT_WARNING_PUSH
59 #if defined(Q_CC_GNU) && Q_CC_GNU >= 900 && Q_CC_GNU < 1000
60     // spurious compiler warning (https://gcc.gnu.org/bugzilla/show_bug.cgi?id=91490#c6)
61     // when Q_DECLARE_METATYPE_TEMPLATE_1ARG is used
62     QT_WARNING_DISABLE_GCC("-Wstringop-overflow")
63 #endif +/
64     return str ? strlen(str) : 0;
65     /+ QT_WARNING_POP +/
66 }
67 
68 pragma(inline, true) size_t qstrnlen(const(char)* str, size_t maxlen)
69 {
70     size_t length = 0;
71     if (str) {
72         while (length < maxlen && *str++)
73             length++;
74     }
75     return length;
76 }
77 
78 // implemented in qbytearray.cpp
79 /+ Q_CORE_EXPORT +/ char* qstrcpy(char* dst, const(char)* src);
80 /+ Q_CORE_EXPORT +/ char* qstrncpy(char* dst, const(char)* src, size_t len);
81 
82 /+ Q_CORE_EXPORT +/ int qstrcmp(const(char)* str1, const(char)* str2);
83 
84 pragma(inline, true) int qstrncmp(const(char)* str1, const(char)* str2, size_t len)
85 {
86     import core.stdc.string;
87 
88     return (str1 && str2) ? strncmp(str1, str2, len)
89         : (str1 ? 1 : (str2 ? -1 : 0));
90 }
91 /+ Q_CORE_EXPORT +/ int qstricmp(const(char)* , const(char)* );
92 /+ Q_CORE_EXPORT +/ int qstrnicmp(const(char)* , const(char)* , size_t len);
93 /+ Q_CORE_EXPORT +/ int qstrnicmp(const(char)* , qsizetype, const(char)* , qsizetype /+ = -1 +/);
94 
95 // implemented in qvsnprintf.cpp
96 // /+ Q_CORE_EXPORT +/ int qvsnprintf(char* str, size_t n, const(char)* fmt, va_list ap);
97 // /+ Q_CORE_EXPORT +/ int qsnprintf(char* str, size_t n, const(char)* fmt, ...);
98 
99 // qChecksum: Internet checksum
100 /+ Q_CORE_EXPORT +/ quint16 qChecksum(QByteArrayView data, /+ Qt:: +/qt.core.namespace.ChecksumType standard = /+ Qt:: +/qt.core.namespace.ChecksumType.ChecksumIso3309);
101