diff options
Diffstat (limited to 'python/pyqt/sip/qt/qstring.sip')
-rw-r--r-- | python/pyqt/sip/qt/qstring.sip | 1079 |
1 files changed, 0 insertions, 1079 deletions
diff --git a/python/pyqt/sip/qt/qstring.sip b/python/pyqt/sip/qt/qstring.sip deleted file mode 100644 index 85a163fe..00000000 --- a/python/pyqt/sip/qt/qstring.sip +++ /dev/null @@ -1,1079 +0,0 @@ -// This is the SIP interface definition for QChar and QString. -// -// Copyright (c) 2007 -// Riverbank Computing Limited <info@riverbankcomputing.co.uk> -// -// This file is part of PyQt. -// -// This copy of PyQt is free software; you can redistribute it and/or modify it -// under the terms of the GNU General Public License as published by the Free -// Software Foundation; either version 2, or (at your option) any later -// version. -// -// PyQt is supplied in the hope that it will be useful, but WITHOUT ANY -// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -// FOR A PARTICULAR PURPOSE. See the GNU General Public License for more -// details. -// -// You should have received a copy of the GNU General Public License along with -// PyQt; see the file LICENSE. If not, write to the Free Software Foundation, -// Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. - - -%ExportedDoc -<Sect2><Title>QChar (Qt v2+)</Title> -<FuncSynopsis> - <FuncDef>uchar &<Function>cell</Function> const</FuncDef> - <ParamDef></ParamDef> -</FuncSynopsis> -<Para> -Not implemented. -</Para> - -<FuncSynopsis> - <FuncDef>uchar &<Function>row</Function> const</FuncDef> - <ParamDef></ParamDef> -</FuncSynopsis> -<Para> -Not implemented. -</Para> -</Sect2> - -<Sect2><Title>QString</Title> -<Para> -A Python string object (or Unicode object) can be used whenever a -<Literal>QString</Literal> can be used. A <Literal>QString</Literal> can be -converted to a Python string object using the Python <Literal>str()</Literal> -function, and to a Python Unicode object using the Python -<Literal>unicode()</Literal> function. -</Para> - -<Para> -The Python <Literal>+</Literal>, <Literal>+=</Literal>, <Literal>*</Literal>, -<Literal>*=</Literal>, <Literal>len</Literal>, <Literal>[]</Literal> -(for reading slices and individual characters), <Literal>in</Literal> and -comparison operators are supported. -</Para> - -<FuncSynopsis> - <FuncDef>QCharRef <Function>at</Function></FuncDef> - <ParamDef>uint <Parameter>i</Parameter></ParamDef> -</FuncSynopsis> -<Para> -Not yet implemented. (Qt v2+) -</Para> - -<FuncSynopsis> - <FuncDef>QChar <Function>constref</Function> const</FuncDef> - <ParamDef>uint <Parameter>i</Parameter></ParamDef> -</FuncSynopsis> -<Para> -Not yet implemented. (Qt v2+) -</Para> - -<FuncSynopsis> - <FuncDef>QChar &<Function>ref</Function></FuncDef> - <ParamDef>uint <Parameter>i</Parameter></ParamDef> -</FuncSynopsis> -<Para> -Not yet implemented. (Qt v2+) -</Para> - -<FuncSynopsis> - <FuncDef>QString &<Function>setUnicodeCodes</Function></FuncDef> - <ParamDef>const ushort *<Parameter>unicode_as_shorts</Parameter></ParamDef> - <ParamDef>uint <Parameter>len</Parameter></ParamDef> -</FuncSynopsis> -<Para> -Not yet implemented. (Qt v2.1+) -</Para> - -<FuncSynopsis> - <FuncDef>QString &<Function>sprintf</Function></FuncDef> - <ParamDef>const char *<Parameter>format</Parameter></ParamDef> - <ParamDef>...</ParamDef> -</FuncSynopsis> -<Para> -Not implemented. -</Para> - -<FuncSynopsis> - <FuncDef>short <Function>toShort</Function></FuncDef> - <ParamDef>bool *<Parameter>ok</Parameter> = 0</ParamDef> -</FuncSynopsis> -<Para> -This returns a tuple of the <Literal>short</Literal> result and the -<Literal>ok</Literal> value. -</Para> - -<FuncSynopsis> - <FuncDef>ushort <Function>toUShort</Function></FuncDef> - <ParamDef>bool *<Parameter>ok</Parameter> = 0</ParamDef> -</FuncSynopsis> -<Para> -This returns a tuple of the <Literal>ushort</Literal> result and the -<Literal>ok</Literal> value. -</Para> - -<FuncSynopsis> - <FuncDef>int <Function>toInt</Function></FuncDef> - <ParamDef>bool *<Parameter>ok</Parameter> = 0</ParamDef> -</FuncSynopsis> -<Para> -This returns a tuple of the <Literal>int</Literal> result and the -<Literal>ok</Literal> value. -</Para> - -<FuncSynopsis> - <FuncDef>uint <Function>toUInt</Function></FuncDef> - <ParamDef>bool *<Parameter>ok</Parameter> = 0</ParamDef> -</FuncSynopsis> -<Para> -This returns a tuple of the <Literal>uint</Literal> result and the -<Literal>ok</Literal> value. -</Para> - -<FuncSynopsis> - <FuncDef>long <Function>toLong</Function></FuncDef> - <ParamDef>bool *<Parameter>ok</Parameter> = 0</ParamDef> -</FuncSynopsis> -<Para> -This returns a tuple of the <Literal>long</Literal> result and the -<Literal>ok</Literal> value. -</Para> - -<FuncSynopsis> - <FuncDef>ulong <Function>toULong</Function></FuncDef> - <ParamDef>bool *<Parameter>ok</Parameter> = 0</ParamDef> -</FuncSynopsis> -<Para> -This returns a tuple of the <Literal>ulong</Literal> result and the -<Literal>ok</Literal> value. -</Para> - -<FuncSynopsis> - <FuncDef>float <Function>toFloat</Function></FuncDef> - <ParamDef>bool *<Parameter>ok</Parameter> = 0</ParamDef> -</FuncSynopsis> -<Para> -This returns a tuple of the <Literal>float</Literal> result and the -<Literal>ok</Literal> value. -</Para> - -<FuncSynopsis> - <FuncDef>double <Function>toDouble</Function></FuncDef> - <ParamDef>bool *<Parameter>ok</Parameter> = 0</ParamDef> -</FuncSynopsis> -<Para> -This returns a tuple of the <Literal>double</Literal> result and the -<Literal>ok</Literal> value. -</Para> -</Sect2> -%End - - -%If (Qt_2_00 -) - -class QChar -{ -%TypeHeaderCode -#include <qstring.h> -%End - -public: - QChar(); - QChar(char); -// QChar(uchar); - QChar(uchar,uchar); - QChar(const QChar &); -// QChar(ushort); -// QChar(short); -// QChar(uint); - QChar(int); - - static const QChar null; - static const QChar replacement; - static const QChar byteOrderMark; - static const QChar byteOrderSwapped; -%If (Qt_2_2_0 -) - static const QChar nbsp; -%End - -%If (- Qt_3_0_0) - enum Category { - NoCategory, - - Mark_NonSpacing, - Mark_SpacingCombining, - Mark_Enclosing, - - Number_DecimalDigit, - Number_Letter, - Number_Other, - - Separator_Space, - Separator_Line, - Separator_Paragraph, - - Other_Control, - Other_Format, - Other_Surrogate, - Other_PrivateUse, - Other_NotAssigned, - - Letter_Uppercase, - Letter_Lowercase, - Letter_Titlecase, - Letter_Modifier, - Letter_Other, - - Punctuation_Connector, - Punctuation_Dask, - Punctuation_Open, - Punctuation_Close, - Punctuation_InitialQuote, - Punctuation_FinalQuote, - Punctuation_Other, - - Symbol_Math, - Symbol_Currency, - Symbol_Modifier, - Symbol_Other - }; -%End -%If (Qt_3_0_0 -) - enum Category { - NoCategory, - - Mark_NonSpacing, - Mark_SpacingCombining, - Mark_Enclosing, - - Number_DecimalDigit, - Number_Letter, - Number_Other, - - Separator_Space, - Separator_Line, - Separator_Paragraph, - - Other_Control, - Other_Format, - Other_Surrogate, - Other_PrivateUse, - Other_NotAssigned, - - Letter_Uppercase, - Letter_Lowercase, - Letter_Titlecase, - Letter_Modifier, - Letter_Other, - - Punctuation_Connector, - Punctuation_Dash, - Punctuation_Open, - Punctuation_Close, - Punctuation_InitialQuote, - Punctuation_FinalQuote, - Punctuation_Other, - - Symbol_Math, - Symbol_Currency, - Symbol_Modifier, - Symbol_Other - }; -%End - -%If (- Qt_3_0_0) - enum Direction { - DirL, - DirR, - DirEN, - DirES, - DirET, - DirAN, - DirCS, - DirB, - DirS, - DirWS, - DirON - }; -%End -%If (Qt_3_0_0 -) - enum Direction { - DirL, - DirR, - DirEN, - DirES, - DirET, - DirAN, - DirCS, - DirB, - DirS, - DirWS, - DirON, - DirLRE, - DirLRO, - DirAL, - DirRLE, - DirRLO, - DirPDF, - DirNSM, - DirBN - }; -%End - - enum Decomposition { - Single, - Canonical, - Font, - NoBreak, - Initial, - Medial, - Final, - Isolated, - Circle, - Super, - Sub, - Vertical, - Wide, - Narrow, - Small, - Square, - Compat, - Fraction - }; - - enum Joining { - OtherJoining, - Dual, - Right, - Center - }; - -%If (Qt_3_0_0 -) - enum CombiningClass { - Combining_BelowLeftAttached, - Combining_BelowAttached, - Combining_BelowRightAttached, - Combining_LeftAttached, - Combining_RightAttached, - Combining_AboveLeftAttached, - Combining_AboveAttached, - Combining_AboveRightAttached, - - Combining_BelowLeft, - Combining_Below, - Combining_BelowRight, - Combining_Left, - Combining_Right, - Combining_AboveLeft, - Combining_Above, - Combining_AboveRight, - - Combining_DoubleBelow, - Combining_DoubleAbove, - Combining_IotaSubscript - }; -%End - - int digitValue() const; - QChar lower() const; - QChar upper() const; - - Category category() const; - Direction direction() const; - Joining joining() const; - bool mirrored() const; -%If (Qt_2_1_0 -) - QChar mirroredChar() const; -%End -%If (- Qt_3_0_0) - QString decomposition() const; -%End -%If (Qt_3_0_0 -) - const QString &decomposition() const; -%End - Decomposition decompositionTag() const; -%If (Qt_3_0_0 -) - unsigned char combiningClass() const; -%End - - char latin1() const; - ushort unicode() const; - - bool isNull() const; - bool isPrint() const; - bool isPunct() const; - bool isSpace() const; - bool isMark() const; - bool isLetter() const; - bool isNumber() const; -%If (Qt_2_1_0 -) - bool isLetterOrNumber() const; -%End - bool isDigit() const; -%If (Qt_3_0_0 -) - bool isSymbol() const; -%End - -// uchar& cell(); -// uchar& row(); - uchar cell() const; - uchar row() const; -%If (Qt_3_0_0 -) - void setCell(uchar); - void setRow(uchar); -%End - - static bool networkOrdered(); - - bool operator==(char); - bool operator==(QChar); - bool operator!=(QChar); - bool operator!=(char); - bool operator<=(char); - bool operator<=(QChar); - bool operator>=(char); - bool operator>=(QChar); - bool operator<(char); - bool operator<(QChar); - bool operator>(char); - bool operator>(QChar); -}; - - -class QString -{ -%TypeHeaderCode -#include <qstring.h> -%End - -public: - QString(); - QString(QChar); - QString(const QString &); - QString(const QByteArray &); -// QString(const QChar *,uint); -// QString(const char *); - -%If (Qt_2_1_0 -) - // This is how we implement QUrl::operator QString() const. - QString(const QUrl &); -%End - -%If (Qt_3_0_0 -) - // This is how we implement QKeySequence::operator QString() const. - QString(const QKeySequence &); - - // This is how we implement QUuid::operator QString() const. - QString(const QUuid &); -%End - - static const QString null; - - bool isNull() const; - bool isEmpty() const; - uint length() const; - void truncate(uint); -%If (- Qt_3_0_0) - void fill(QChar,int = -1); -%End -%If (Qt_3_0_0 -) - QString &fill(QChar,int = -1); -%End - QString copy() const; - - QString arg(int /Constrained/,int = 0,int = 10) const; - QString arg(double /Constrained/,int = 0,char = 'g',int = -1) const; -%If (Qt_3_2_0 -) -// QString arg(Q_LLONG,int = 0,int = 10) const; -// QString arg(Q_ULLONG,int = 0,int = 10) const; -%End - QString arg(long,int = 0,int = 10) const; - QString arg(ulong,int = 0,int = 10) const; -// QString arg(uint,int = 0,int = 10) const; -// QString arg(short,int = 0,int = 10) const; -// QString arg(ushort,int = 0,int = 10) const; - QString arg(char,int = 0) const; - QString arg(QChar,int = 0) const; - QString arg(const QString&,int = 0) const; -%If (Qt_3_2_0 -) - QString arg(const QString &,const QString &) const; - QString arg(const QString &,const QString &,const QString &) const; - QString arg(const QString &,const QString &,const QString &, - const QString &) const; -%End - -// QString &sprintf(const char *,...); - - int find(QChar,int = 0,bool = 1) const; - int find(char,int = 0,bool = 1) const; - int find(const QString &,int = 0,bool = 1) const; - int find(const QRegExp &,int = 0) const; -// int find(const char *,int = 0) const; - int findRev(QChar,int = -1,bool = 1) const; - int findRev(char,int = -1,bool = 1) const; - int findRev(const QString &,int = -1,bool = 1) const; - int findRev(const QRegExp &,int = -1) const; -// int findRev(const char *,int = -1) const; - int contains(QChar,bool = 1) const; - int contains(char,bool = 1) const; -// int contains(const char *,bool = 1) const; - int contains(const QString &,bool = 1) const; - int contains(const QRegExp &) const; - -%If (Qt_3_0_0 -) - enum SectionFlags { - SectionDefault, - SectionSkipEmpty, - SectionIncludeLeadingSep, - SectionIncludeTrailingSep, - SectionCaseInsensitiveSeps - }; - - QString section(QChar,int,int = 0xffffffff,int = SectionDefault) const; -// QString section(char,int,int = 0xffffffff,int = SectionDefault) const; -// QString section(const char *,int,int = 0xffffffff, -// int = SectionDefault) const; - QString section(const QString &,int,int = 0xffffffff, - int = SectionDefault) const; - QString section(const QRegExp &,int,int = 0xffffffff, - int = SectionDefault) const; -%End - - QString left(uint) const; - QString right(uint) const; - QString mid(uint,uint = 0xffffffff) const; - QString leftJustify(uint,QChar = ' ',bool = 0) const; - QString rightJustify(uint,QChar = ' ',bool = 0) const; - QString lower() const; - QString upper() const; - QString stripWhiteSpace() const; - QString simplifyWhiteSpace() const; - - QString &insert(uint,const QString &); -%If (Qt_3_2_0 -) - QString &insert(uint,const QByteArray &); -// QString &insert(uint,const char *); -%End - QString &insert(uint,QChar *,uint); - QString &insert(uint,QChar); - QString &insert(uint,char); - - QString &append(char); -%If (Qt_2_2_0 -) - QString &append(QChar); -%End - QString &append(const QString &); - QString &prepend(char); -%If (Qt_2_2_0 -) - QString &prepend(QChar); -%End - QString &prepend(const QString &); - QString &remove(uint,uint); -%If (Qt_3_1_0 -) - QString &remove(const QString &); -%If (Qt_3_2_0 -) - QString &remove(const QString &,bool); -%End - QString &remove(QChar); - QString &remove(char); - QString &remove(const QRegExp &); -%End - QString &replace(uint,uint,const QString &); - QString &replace(uint,uint,const QChar *,uint); -%If (Qt_3_1_0 -) - QString &replace(uint,uint,QChar); - QString &replace(uint,uint,char); - QString &replace(QChar,const QString &); -%If (Qt_3_2_0 -) - QString &replace(QChar,const QString &,bool); -%End - QString &replace(char,const QString &); -%If (Qt_3_2_0 -) - QString &replace(char,const QString &,bool); -%End - QString &replace(const QString &,const QString &); -%If (Qt_3_2_0 -) - QString &replace(const QString &,const QString &,bool); -%End -%End - QString &replace(const QRegExp &,const QString &); -%If (Qt_3_1_0 -) - QString &replace(QChar,QChar); -%End - - short toShort(bool * = 0,int = 10) const; - ushort toUShort(bool * = 0,int = 10) const; - int toInt(bool * = 0,int = 10) const; - uint toUInt(bool * = 0,int = 10) const; - long toLong(bool * = 0,int = 10) const; - ulong toULong(bool * = 0,int = 10) const; -%If (Qt_3_2_0 -) -// Q_LLONG toLongLong(bool * = 0,int = 10) const; -// Q_ULLONG toULongLong(bool * = 0,int = 10) const; -%End - float toFloat(bool * = 0) const; - double toDouble(bool * = 0) const; - - QString &setNum(int /Constrained/,int = 10); - QString &setNum(double /Constrained/,char = 'g',int = 6); -// QString &setNum(short,int = 10); -// QString &setNum(ushort,int = 10); -// QString &setNum(uint,int = 10); - QString &setNum(long,int = 10); - QString &setNum(ulong,int = 10); -%If (Qt_3_2_0 -) -// QString &setNum(Q_LLONG,int = 10); -// QString &setNum(Q_ULLONG,int = 10); -%End -// QString &setNum(float,char = 'g',int = 6); - - static QString number(int /Constrained/,int = 10); - static QString number(double /Constrained/,char = 'g',int = 6); - static QString number(long,int = 10); - static QString number(ulong,int = 10); -%If (Qt_3_2_0 -) -// static QString number(Q_LLONG,int = 10); -// static QString number(Q_ULLONG,int = 10); -%End -// static QString number(uint,int = 10); - - void setExpand(uint,QChar); - - QString &operator+=(const QString &); -%If (Qt_3_3_0 -) - QString &operator+=(const QByteArray &); -%End - QString &operator+=(QChar); - //QString &operator+=(char); - - QString operator*(int); -%MethodCode - sipRes = new QString(); - - while (a0-- > 0) - *sipRes += *sipCpp; -%End - - QString &operator*=(int); -%MethodCode - QString orig(*sipCpp); - - sipCpp -> truncate(0); - - while (a0-- > 0) - *sipCpp += orig; -%End - - QChar at(uint) const; -// QCharRef at(uint); -// QChar constref(uint) const; -// QChar &ref(uint); -// const QChar *unicode() const; - const char *ascii() const; -%If (Qt_3_1_0 -) - static QString fromAscii(const char *,int = -1); -%End - const char *latin1() const; - static QString fromLatin1(const char *,int = -1); - QCString utf8() const; - static QString fromUtf8(const char *,int = -1); - QCString local8Bit() const; - static QString fromLocal8Bit(const char *,int = -1); - -%If (Qt_3_1_0 -) -// static QString fromUcs2(const unsigned short *); -// const unsigned short *ucs2() const; -%End - -%If (Qt_2_1_0 -) -// QString &setUnicode(const QChar *,uint); -// QString &setUnicodeCodes(const ushort *,uint); -%End -%If (Qt_3_1_0 -) - QString &setAscii(const char *,int = -1); -%End -%If (Qt_2_1_0 -) - QString &setLatin1(const char *,int = -1); -%End - - int compare(const QString &) const; - static int compare(const QString &,const QString &); - -%If (Qt_3_0_0 -) - int localeAwareCompare(const QString &) const; - static int localeAwareCompare(const QString &,const QString &); -%End - - void compose(); -%If (- Qt_3_0_0) - QChar::Direction basicDirection(); - QString visual(int = 0,int = -1); -%End -%If (Qt_2_2_0 -) - bool startsWith(const QString &) const; -%End -%If (Qt_3_2_0 -) - bool startsWith(const QString &,bool) const; -%End -%If (Qt_3_0_0 -) - bool endsWith(const QString &) const; -%End -%If (Qt_3_2_0 -) - bool endsWith(const QString &,bool) const; -%End - -%If (Qt_3_0_0 -) - void setLength(uint); -%End - -%If (Qt_3_2_0 -) - uint capacity() const; - void reserve(uint); - void squeeze(); -%End - -%If (Qt_3_0_0 -) - bool simpleText() const; - bool isRightToLeft() const; -%End - - bool operator==(const QString &) const; - bool operator!=(const QString &) const; - bool operator<(const QString &) const; - bool operator<=(const QString &) const; - bool operator>(const QString &) const; - bool operator>=(const QString &) const; - - // Force the numeric interpretation so that str + QString gets handled - // as we want. - const QString operator+(const QString &) /Numeric/; - - QString operator[](int) const; -%MethodCode - int len; - - len = sipCpp -> length(); - - if ((a0 = (int)sipConvertFromSequenceIndex(a0,len)) < 0) - sipIsErr = 1; - else - sipRes = new QString(sipCpp -> at(a0)); -%End - - QString operator[](SIP_PYSLICE) const; -%MethodCode -#if PY_VERSION_HEX >= 0x02050000 - Py_ssize_t len, start, stop, step, slicelength, i; -#else - int len, start, stop, step, slicelength, i; -#endif - - len = sipCpp -> length(); - - if (sipConvertFromSliceObject(a0,len,&start,&stop,&step,&slicelength) < 0) - sipIsErr = 1; - else - { - sipRes = new QString(); - - for (i = 0; i < slicelength; ++i) - { - sipRes -> append(sipCpp -> at(start)); - start += step; - } - } -%End - - int __len__() const; -%MethodCode - sipRes = sipCpp -> length(); -%End - - int __contains__(const QString &) const; -%MethodCode - sipRes = (sipCpp -> contains(*a0) > 0); -%End - - SIP_PYOBJECT __unicode__(); -%MethodCode -#if PY_VERSION_HEX >= 0x01060000 - sipRes = QStringToPyUnicode(sipCpp); -#else - Py_INCREF(Py_None); - sipRes = Py_None; -#endif -%End - - SIP_PYOBJECT __str__(); -%MethodCode -#if PY_VERSION_HEX >= 0x01060000 - sipRes = QStringToPyUnicode(sipCpp); -#else - const char *s; - - Py_BEGIN_ALLOW_THREADS - s = *sipCpp; - Py_END_ALLOW_THREADS - - if (s == NULL) - s = ""; - - sipRes = PyString_FromString(s); -#endif -%End - -%TypeCode -#include <qtextcodec.h> - -#if PY_VERSION_HEX >= 0x01060000 -// Convenience function for converting a QString to a Python Unicode object. -static PyObject *QStringToPyUnicode(QString *qs) -{ - PyObject *uobj; - - if ((uobj = PyUnicode_FromUnicode(NULL,qs -> length())) == NULL) - return NULL; - - Py_UNICODE *pyu = PyUnicode_AS_UNICODE(uobj); - - for (uint i = 0; i < qs -> length(); ++i) - *pyu++ = (qs -> at(i)).unicode(); - - return uobj; -} -#endif - -// Convenience function for converting a Python unicode or string object to a -// QString on the heap. -static QString *PyUnicodeStringToQString(PyObject *py) -{ -#if PY_VERSION_HEX >= 0x01060000 - if (PyUnicode_Check(py)) - { - QString *qs = new QString; - -#if defined(Py_UNICODE_WIDE) - PY_UNICODE_TYPE *ucode = PyUnicode_AS_UNICODE(py); - int len = PyUnicode_GET_SIZE(py); - - for (int i = 0; i < len; ++i) - qs->ref(i) = (uint)ucode[i]; -#else - qs -> setUnicodeCodes((ushort *)PyUnicode_AS_UNICODE(py),PyUnicode_GET_SIZE(py)); -#endif - - return qs; - } -#endif - - if (PyString_Check(py)) - return new QString(PyString_AS_STRING(py)); - - return 0; -} -%End - -%ConvertToTypeCode - // Allow a Python string (or a unicode string) whenever a QString is - // expected. - - if (sipIsErr == NULL) - return (PyString_Check(sipPy) || -#if PY_VERSION_HEX >= 0x01060000 - PyUnicode_Check(sipPy) || -#endif - sipCanConvertToInstance(sipPy,sipClass_QString,SIP_NO_CONVERTORS)); - - *sipCppPtr = PyUnicodeStringToQString(sipPy); - - if (*sipCppPtr) - return sipGetState(sipTransferObj); - - *sipCppPtr = reinterpret_cast<QString *>(sipConvertToInstance(sipPy,sipClass_QString,sipTransferObj,SIP_NO_CONVERTORS,0,sipIsErr)); - - return 0; -%End - -%BIGetReadBufferCode - if (sipSegment != 0) - { - PyErr_SetString(PyExc_SystemError, "accessing non-existent QString segment"); - sipRes = -1; - } - else - { - *sipPtrPtr = (void *)sipCpp->ucs2(); - sipRes = sipCpp->length() * sizeof (ushort); - } -%End - -%BIGetSegCountCode - if (sipLenPtr) - *sipLenPtr = sipCpp->length() * sizeof (ushort); - - sipRes = 1; -%End - -%BIGetCharBufferCode - if (sipSegment != 0) - { - PyErr_SetString(PyExc_SystemError, "accessing non-existent QString segment"); - sipRes = -1; - } - else - { - static QTextCodec *codec = 0; - static bool check_codec = TRUE; - - // For the first time only, try and find a Qt codec that - // corresponds to the default Python codec. If one wasn't - // found then fall back to ASCII (which is actually the codec - // returned by QTextCodec::codecForCStrings()). - if (check_codec) - { - codec = QTextCodec::codecForName(PyUnicode_GetDefaultEncoding()); - check_codec = FALSE; - } - - if (codec) - { - // A Python string is the most convenient method to - // save the encoded version on the heap. - PyObject *encobj = ((sipWrapper *)sipSelf)->user; - QCString enc; - - Py_XDECREF(encobj); - - enc = codec->fromUnicode(*sipCpp); - - if ((encobj = PyString_FromString(enc.data())) != NULL) - { - *sipPtrPtr = (void *)PyString_AS_STRING(encobj); - sipRes = PyString_GET_SIZE(encobj); - - ((sipWrapper *)sipSelf)->user = encobj; - } - else - sipRes = -1; - } - else - { - const char *asc = sipCpp->ascii(); - - *sipPtrPtr = (void *)asc; - sipRes = qstrlen(asc); - } - } -%End -}; - -%End - - -%If (- Qt_2_00) - -class QString : QByteArray -{ -%TypeHeaderCode -#include <qstring.h> -%End - -public: - QString(); - QString(int); - QString(const QString &); - QString(const char *); - QString(const char *,uint); - - bool isNull() const; - bool isEmpty() const; - uint length() const; - bool resize(uint); - bool truncate(uint); - bool fill(char,int = -1); - QString copy() const; -// QString &sprintf(const char *,...); - int find(char,int = 0,bool = 1) const; - int find(const char *,int = 0,bool = 1) const; - int find(const QRegExp &,int = 0) const; - int findRev(char,int = -1,bool = 1) const; - int findRev(const char *,int = -1,bool = 1) const; - int findRev(const QRegExp &,int = -1) const; - int contains(char,bool = 1) const; - int contains(const char *,bool = 1) const; - int contains(const QRegExp &) const; - QString left(uint) const; - QString right(uint) const; - QString mid(uint,uint) const; - QString leftJustify(uint,char = ' ',bool = 0) const; - QString rightJustify(uint,char = ' ',bool = 0) const; - QString lower() const; - QString upper() const; - QString stripWhiteSpace() const; - QString simplifyWhiteSpace() const; - QString &insert(uint,const char *); - QString &insert(uint,char); - QString &append(const char *); - QString &prepend(const char *); - QString &remove(uint,uint); - QString &replace(uint,uint,const char *); - QString &replace(const QRegExp &,const char *); - - short toShort(bool * = 0) const; - ushort toUShort(bool * = 0) const; - int toInt(bool * = 0) const; - uint toUInt(bool * = 0) const; - long toLong(bool * = 0) const; - ulong toULong(bool * = 0) const; - float toFloat(bool * = 0) const; - double toDouble(bool * = 0) const; - - QString &setStr(const char *); -// QString &setNum(short); -// QString &setNum(ushort); - QString &setNum(int /Constrained/); -// QString &setNum(uint); -// QString &setNum(long); -// QString &setNum(ulong); -// QString &setNum(float,char = 'g',int = 6); - QString &setNum(double,char = 'g',int = 6); - bool setExpand(uint,char); - - SIP_PYOBJECT __str__(); -%MethodCode - const char *s; - - Py_BEGIN_ALLOW_THREADS - s = *sipCpp; - Py_END_ALLOW_THREADS - - if (s == NULL) - s = ""; - - sipRes = PyString_FromString(s); -%End - -%ConvertToTypeCode - // Allow a Python string whenever a QString is expected. - - if (sipIsErr == NULL) - return (PyString_Check(sipPy) || - sipCanConvertToInstance(sipPy,sipClass_QString,SIP_NO_CONVERTORS)); - - if (PyString_Check(sipPy)) - { - *sipCppPtr = new QString(PyString_AS_STRING(sipPy)); - - return sipGetState(sipTransferObj); - } - - *sipCppPtr = reinterpret_cast<QString *>(sipConvertToInstance(sipPy,sipClass_QString,sipTransferObj,SIP_NO_CONVERTORS,0,sipIsErr)); - - return 0; -%End -}; - -%End |