| 1 | // Copyright (C) 2016 The Qt Company Ltd. |
| 2 | // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only |
| 3 | #ifndef WTFSTRING_H |
| 4 | #define WTFSTRING_H |
| 5 | |
| 6 | #include <QString> |
| 7 | #include <wtf/ASCIICType.h> |
| 8 | #include <wtf/unicode/Unicode.h> |
| 9 | #include <memory> |
| 10 | |
| 11 | namespace WTF { |
| 12 | |
| 13 | class PrintStream; |
| 14 | |
| 15 | class String : public QString |
| 16 | { |
| 17 | public: |
| 18 | String() = default; |
| 19 | String(const QString& s) : QString(s) {} |
| 20 | bool is8Bit() const { return false; } |
| 21 | const unsigned char *characters8() const { return 0; } |
| 22 | const UChar *characters16() const { return reinterpret_cast<const UChar*>(constData()); } |
| 23 | |
| 24 | template <typename T> |
| 25 | const T* characters() const; |
| 26 | |
| 27 | bool operator!() const { return isEmpty(); } |
| 28 | |
| 29 | void dump(PrintStream &) const {} |
| 30 | }; |
| 31 | |
| 32 | template <> |
| 33 | inline const unsigned char* String::characters<unsigned char>() const { return characters8(); } |
| 34 | template <> |
| 35 | inline const UChar* String::characters<UChar>() const { return characters16(); } |
| 36 | |
| 37 | } |
| 38 | |
| 39 | // Don't import WTF::String into the global namespace to avoid conflicts with QQmlJS::VM::String |
| 40 | namespace JSC { |
| 41 | using WTF::String; |
| 42 | } |
| 43 | |
| 44 | #define WTFMove(value) std::move(value) |
| 45 | |
| 46 | #endif // WTFSTRING_H |
| 47 | |