⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 kwqstring.h

📁 khtml在gtk上的移植版本
💻 H
📖 第 1 页 / 共 2 页
字号:
/* * Copyright (C) 2004 Apple Computer, Inc.  All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: * 1. Redistributions of source code must retain the above copyright *    notice, this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright *    notice, this list of conditions and the following disclaimer in the *    documentation and/or other materials provided with the distribution. * * THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE COMPUTER, INC. OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.  */#ifndef QSTRING_H_#define QSTRING_H_#if !KWIQ#include <CoreFoundation/CoreFoundation.h>#endif#include "KWQCString.h"#include "WebCoreUnicode.h"// Make htmltokenizer.cpp happy#define QT_VERSION 300class QRegExp;#ifdef __OBJC__@class NSString;#elseclass NSString;#endifclass QChar {public:    enum Direction {        DirL = 0, DirR, DirEN, DirES, DirET, DirAN, DirCS, DirB, DirS, DirWS, DirON,        DirLRE, DirLRO, DirAL, DirRLE, DirRLO, DirPDF, DirNSM, DirBN    };#if !KWIQ    static const char null = 0; // not a QChar as in Qt (can't have static constructor), but close enough to be compatible in most cases#else    static const char null; // ANSI c++ forbids inclass initalization of non-integral type#endif        QChar();    QChar(char);    QChar(uchar);    QChar(short);    QChar(ushort);    QChar(int);    QChar(uint);    ushort unicode() const;    uchar cell() const;    uchar row() const;    char latin1() const;    bool isNull() const;    bool isSpace() const;    bool isDigit() const;    bool isLetter() const;    bool isNumber() const;    bool isLetterOrNumber() const;    bool isPunct() const;    int digitValue() const;    QChar lower() const;    QChar upper() const;    Direction direction() const;        bool mirrored() const;    QChar mirroredChar() const;    operator char() const;    friend bool operator==(QChar, QChar);    friend bool operator==(QChar, char);    friend bool operator==(char, QChar);    friend bool operator!=(QChar, QChar);    friend bool operator!=(QChar, char);    friend bool operator!=(char, QChar);    friend bool operator>(QChar, QChar);    friend bool operator>(QChar, char);    friend bool operator>(char, QChar);    friend bool operator>=(QChar, QChar);    friend bool operator>=(QChar, char);    friend bool operator>=(char, QChar);    friend bool operator<(QChar, QChar);    friend bool operator<(QChar, char);    friend bool operator<(char, QChar);    friend bool operator<=(QChar, QChar);    friend bool operator<=(QChar, char);    friend bool operator<=(char, QChar);private:    UniChar c;    friend class QString;    friend class QConstString;    static bool isDigitNonASCII(UniChar c);    static bool isLetterNonASCII(UniChar c);    static bool isNumberNonASCII(UniChar c);    static bool isLetterOrNumberNonASCII(UniChar c);    static int digitValueNonASCII(UniChar c);    static UniChar lowerNonASCII(UniChar c);    static UniChar upperNonASCII(UniChar c);#if KWIQ} Q_PACKED;#else};#endifinline QChar::QChar() : c(0){}inline QChar::QChar(char ch) : c((uchar) ch){}inline QChar::QChar(uchar uch) : c(uch){}inline QChar::QChar(short n) : c(n){}inline QChar::QChar(ushort n) : c(n){}inline QChar::QChar(uint n) : c(n){}inline QChar::QChar(int n) : c(n){}inline ushort QChar::unicode() const{    return c;}inline uchar QChar::cell() const{    return c;}inline bool QChar::isNull() const{    return c == 0;}inline bool QChar::isSpace() const{    // Use isspace() for basic latin1.  This will include newlines, which    // aren't included in unicode DirWS.    return c <= 0x7F ? isspace(c) : direction() == DirWS;}inline bool QChar::isDigit() const{    return c <= 0x7F ? isdigit(c) : isDigitNonASCII(c);}inline bool QChar::isLetter() const{    return c <= 0x7F ? isalpha(c) : isLetterNonASCII(c);}inline bool QChar::isNumber() const{    return c <= 0x7F ? isdigit(c) : isNumberNonASCII(c);}inline bool QChar::isLetterOrNumber() const{    return c <= 0x7F ? isalnum(c) : isLetterOrNumberNonASCII(c);}inline int QChar::digitValue() const{    return c <= '9' ? c - '0' : digitValueNonASCII(c);}inline QChar QChar::lower() const{    return c <= 0x7F ? tolower(c) : lowerNonASCII(c);}inline QChar QChar::upper() const{    return c <= 0x7F ? toupper(c) : upperNonASCII(c);}inline QChar::Direction QChar::direction() const{    return static_cast<Direction>(WebCoreUnicodeDirectionFunction(c));}inline uchar QChar::row() const{    return c >> 8;}inline char QChar::latin1() const{    return c > 0xff ? 0 : c;}inline QChar::operator char() const{    return c > 0xff ? 0 : c;}inline bool operator==(QChar qc1, QChar qc2){    return qc1.c == qc2.c;}inline bool operator==(QChar qc, char ch){    return qc.c == (uchar) ch;}inline bool operator==(char ch, QChar qc){    return (uchar) ch == qc.c;}inline bool operator!=(QChar qc1, QChar qc2){    return qc1.c != qc2.c;}inline bool operator!=(QChar qc, char ch){    return qc.c != (uchar) ch;}inline bool operator!=(char ch, QChar qc){    return (uchar) ch != qc.c;}inline bool operator>=(QChar qc1, QChar qc2){    return qc1.c >= qc2.c;}inline bool operator>=(QChar qc, char ch){    return qc.c >= (uchar) ch;}inline bool operator>=(char ch, QChar qc){    return (uchar) ch >= qc.c;}inline bool operator>(QChar qc1, QChar qc2){    return qc1.c > qc2.c;}inline bool operator>(QChar qc, char ch){    return qc.c > (uchar) ch;}inline bool operator>(char ch, QChar qc){    return (uchar) ch > qc.c;}inline bool operator<=(QChar qc1, QChar qc2){    return qc1.c <= qc2.c;}inline bool operator<=(QChar qc, char ch){    return qc.c <= (uchar) ch;}inline bool operator<=(char ch, QChar qc){    return (uchar) ch <= qc.c;}inline bool operator<(QChar qc1, QChar qc2){    return qc1.c < qc2.c;}inline bool operator<(QChar qc, char ch){    return qc.c < (uchar) ch;}inline bool operator<(char ch, QChar qc){    return (uchar) ch < qc.c;}// Keep this struct to <= 46 bytes, that's what the system will allocate.// Will be rounded up to a multiple of 4, so we're stuck at 44.#define QS_INTERNAL_BUFFER_SIZE 20#define QS_INTERNAL_BUFFER_CHARS QS_INTERNAL_BUFFER_SIZE-1#define QS_INTERNAL_BUFFER_UCHARS QS_INTERNAL_BUFFER_SIZE/2struct KWQStringData {    // Uses shared null data.    KWQStringData();    void initialize();        // No copy.    KWQStringData(QChar *u, uint l, uint m);    void initialize(QChar *u, uint l, uint m);        // Copy bytes.    KWQStringData(const QChar *u, uint l);    void initialize(const QChar *u, uint l);    // Copy bytes.    KWQStringData(const char *u, uint l);    void initialize(const char *u, uint l);    // Move from destination to source.    KWQStringData(KWQStringData &);    ~KWQStringData();#ifdef QSTRING_DEBUG_ALLOCATIONS    void* operator new(size_t s);    void operator delete(void*p);#endif    inline void ref() { refCount++; }    inline void deref() { if (--refCount == 0 && _isHeapAllocated) delete this; }            char *ascii();    char *makeAscii();    void increaseAsciiSize(uint size);    QChar *unicode();    QChar *makeUnicode();        void increaseUnicodeSize(uint size);        bool isUnicodeInternal() const { return (char *)_unicode == _internalBuffer; }    bool isAsciiInternal() const { return _ascii == _internalBuffer; }        uint refCount;    uint _length;    mutable QChar *_unicode;    mutable char *_ascii;    uint _maxUnicode:30;    uint _isUnicodeValid:1;    uint _isHeapAllocated:1;	// Fragile, but the only way we can be sure the instance was created with 'new'.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -