You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
912 lines
23 KiB
912 lines
23 KiB
13 years ago
|
// This is the SIP interface definition for TQChar and TQString.
|
||
13 years ago
|
//
|
||
|
// Copyright (c) 2007
|
||
|
// Riverbank Computing Limited <info@riverbankcomputing.co.uk>
|
||
|
//
|
||
13 years ago
|
// This file is part of PyTQt.
|
||
13 years ago
|
//
|
||
13 years ago
|
// This copy of PyTQt is free software; you can redistribute it and/or modify it
|
||
13 years ago
|
// 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.
|
||
|
//
|
||
13 years ago
|
// PyTQt is supplied in the hope that it will be useful, but WITHOUT ANY
|
||
13 years ago
|
// 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
|
||
13 years ago
|
// PyTQt; see the file LICENSE. If not, write to the Free Software Foundation,
|
||
13 years ago
|
// Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||
|
|
||
|
|
||
|
%ExportedDoc
|
||
13 years ago
|
<Sect2><Title>TQChar (TQt v2+)</Title>
|
||
13 years ago
|
<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>
|
||
|
|
||
13 years ago
|
<Sect2><Title>TQString</Title>
|
||
13 years ago
|
<Para>
|
||
|
A Python string object (or Unicode object) can be used whenever a
|
||
13 years ago
|
<Literal>TQString</Literal> can be used. A <Literal>TQString</Literal> can be
|
||
13 years ago
|
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>
|
||
13 years ago
|
<FuncDef>TQCharRef <Function>at</Function></FuncDef>
|
||
13 years ago
|
<ParamDef>uint <Parameter>i</Parameter></ParamDef>
|
||
|
</FuncSynopsis>
|
||
|
<Para>
|
||
13 years ago
|
Not yet implemented. (TQt v2+)
|
||
13 years ago
|
</Para>
|
||
|
|
||
|
<FuncSynopsis>
|
||
13 years ago
|
<FuncDef>TQChar <Function>constref</Function> const</FuncDef>
|
||
13 years ago
|
<ParamDef>uint <Parameter>i</Parameter></ParamDef>
|
||
|
</FuncSynopsis>
|
||
|
<Para>
|
||
13 years ago
|
Not yet implemented. (TQt v2+)
|
||
13 years ago
|
</Para>
|
||
|
|
||
|
<FuncSynopsis>
|
||
13 years ago
|
<FuncDef>TQChar &<Function>ref</Function></FuncDef>
|
||
13 years ago
|
<ParamDef>uint <Parameter>i</Parameter></ParamDef>
|
||
|
</FuncSynopsis>
|
||
|
<Para>
|
||
13 years ago
|
Not yet implemented. (TQt v2+)
|
||
13 years ago
|
</Para>
|
||
|
|
||
|
<FuncSynopsis>
|
||
13 years ago
|
<FuncDef>TQString &<Function>setUnicodeCodes</Function></FuncDef>
|
||
13 years ago
|
<ParamDef>const ushort *<Parameter>unicode_as_shorts</Parameter></ParamDef>
|
||
|
<ParamDef>uint <Parameter>len</Parameter></ParamDef>
|
||
|
</FuncSynopsis>
|
||
|
<Para>
|
||
13 years ago
|
Not yet implemented. (TQt v2.1+)
|
||
13 years ago
|
</Para>
|
||
|
|
||
|
<FuncSynopsis>
|
||
13 years ago
|
<FuncDef>TQString &<Function>sprintf</Function></FuncDef>
|
||
13 years ago
|
<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
|
||
|
|
||
|
|
||
13 years ago
|
class TQChar
|
||
13 years ago
|
{
|
||
|
%TypeHeaderCode
|
||
13 years ago
|
#include <tqstring.h>
|
||
13 years ago
|
%End
|
||
|
|
||
|
public:
|
||
13 years ago
|
TQChar();
|
||
|
TQChar(char);
|
||
|
// TQChar(uchar);
|
||
|
TQChar(uchar,uchar);
|
||
|
TQChar(const TQChar &);
|
||
|
// TQChar(ushort);
|
||
|
// TQChar(short);
|
||
|
// TQChar(uint);
|
||
|
TQChar(int);
|
||
|
|
||
|
static const TQChar null;
|
||
|
static const TQChar replacement;
|
||
|
static const TQChar byteOrderMark;
|
||
|
static const TQChar byteOrderSwapped;
|
||
|
static const TQChar nbsp;
|
||
|
|
||
13 years ago
|
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
|
||
|
};
|
||
|
|
||
|
enum Direction {
|
||
|
DirL,
|
||
|
DirR,
|
||
|
DirEN,
|
||
|
DirES,
|
||
|
DirET,
|
||
|
DirAN,
|
||
|
DirCS,
|
||
|
DirB,
|
||
|
DirS,
|
||
|
DirWS,
|
||
|
DirON,
|
||
|
DirLRE,
|
||
|
DirLRO,
|
||
|
DirAL,
|
||
|
DirRLE,
|
||
|
DirRLO,
|
||
|
DirPDF,
|
||
|
DirNSM,
|
||
|
DirBN
|
||
|
};
|
||
|
|
||
|
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
|
||
|
};
|
||
|
|
||
|
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
|
||
|
};
|
||
|
|
||
|
int digitValue() const;
|
||
13 years ago
|
TQChar lower() const;
|
||
|
TQChar upper() const;
|
||
13 years ago
|
|
||
|
Category category() const;
|
||
|
Direction direction() const;
|
||
|
Joining joining() const;
|
||
|
bool mirrored() const;
|
||
13 years ago
|
TQChar mirroredChar() const;
|
||
|
const TQString &decomposition() const;
|
||
13 years ago
|
Decomposition decompositionTag() const;
|
||
|
unsigned char combiningClass() const;
|
||
|
|
||
|
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;
|
||
|
bool isLetterOrNumber() const;
|
||
|
bool isDigit() const;
|
||
|
bool isSymbol() const;
|
||
|
|
||
|
// uchar& cell();
|
||
|
// uchar& row();
|
||
|
uchar cell() const;
|
||
|
uchar row() const;
|
||
|
void setCell(uchar);
|
||
|
void setRow(uchar);
|
||
|
|
||
|
static bool networkOrdered();
|
||
|
};
|
||
|
|
||
13 years ago
|
bool operator==(TQChar,char);
|
||
|
bool operator==(TQChar,TQChar);
|
||
|
bool operator!=(TQChar,TQChar);
|
||
|
bool operator!=(TQChar,char);
|
||
|
bool operator<=(TQChar,char);
|
||
|
bool operator<=(TQChar,TQChar);
|
||
|
bool operator>=(TQChar,char);
|
||
|
bool operator>=(TQChar,TQChar);
|
||
|
bool operator<(TQChar,char);
|
||
|
bool operator<(TQChar,TQChar);
|
||
|
bool operator>(TQChar,char);
|
||
|
bool operator>(TQChar,TQChar);
|
||
|
|
||
|
|
||
|
class TQString
|
||
13 years ago
|
{
|
||
|
%TypeHeaderCode
|
||
13 years ago
|
#include <tqstring.h>
|
||
3 years ago
|
#include <tqtextcodec.h>
|
||
13 years ago
|
%End
|
||
|
|
||
|
public:
|
||
13 years ago
|
TQString();
|
||
|
TQString(TQChar);
|
||
|
TQString(const TQString &);
|
||
|
TQString(const TQByteArray &);
|
||
|
// TQString(const TQChar *,uint);
|
||
|
// TQString(const char *);
|
||
13 years ago
|
|
||
13 years ago
|
// This is how we implement TQUrl::operator TQString() const.
|
||
|
TQString(const TQUrl &);
|
||
13 years ago
|
|
||
13 years ago
|
// This is how we implement TQKeySequence::operator TQString() const.
|
||
|
TQString(const TQKeySequence &);
|
||
13 years ago
|
|
||
13 years ago
|
// This is how we implement TQUuid::operator TQString() const.
|
||
|
TQString(const TQUuid &);
|
||
13 years ago
|
|
||
13 years ago
|
static const TQString null;
|
||
13 years ago
|
|
||
|
bool isNull() const;
|
||
|
bool isEmpty() const;
|
||
|
uint length() const;
|
||
|
void truncate(uint);
|
||
13 years ago
|
TQString &fill(TQChar,int = -1);
|
||
|
TQString copy() const;
|
||
|
|
||
|
TQString arg(int /Constrained/,int = 0,int = 10) const;
|
||
|
TQString arg(double /Constrained/,int = 0,char = 'g',int = -1) const;
|
||
13 years ago
|
// TQString arg(TQ_LLONG,int = 0,int = 10) const;
|
||
|
// TQString arg(TQ_ULLONG,int = 0,int = 10) const;
|
||
13 years ago
|
TQString arg(long,int = 0,int = 10) const;
|
||
|
TQString arg(ulong,int = 0,int = 10) const;
|
||
|
// TQString arg(uint,int = 0,int = 10) const;
|
||
|
// TQString arg(short,int = 0,int = 10) const;
|
||
|
// TQString arg(ushort,int = 0,int = 10) const;
|
||
|
TQString arg(char,int = 0) const;
|
||
|
TQString arg(TQChar,int = 0) const;
|
||
|
TQString arg(const TQString&,int = 0) const;
|
||
|
TQString arg(const TQString &,const TQString &) const;
|
||
|
TQString arg(const TQString &,const TQString &,const TQString &) const;
|
||
|
TQString arg(const TQString &,const TQString &,const TQString &,
|
||
|
const TQString &) const;
|
||
|
|
||
|
// TQString &sprintf(const char *,...);
|
||
|
|
||
|
int find(TQChar,int = 0,bool = 1) const;
|
||
13 years ago
|
int find(char,int = 0,bool = 1) const;
|
||
13 years ago
|
int find(const TQString &,int = 0,bool = 1) const;
|
||
|
int find(const TQRegExp &,int = 0) const;
|
||
13 years ago
|
// int find(const char *,int = 0) const;
|
||
13 years ago
|
int findRev(TQChar,int = -1,bool = 1) const;
|
||
13 years ago
|
int findRev(char,int = -1,bool = 1) const;
|
||
13 years ago
|
int findRev(const TQString &,int = -1,bool = 1) const;
|
||
|
int findRev(const TQRegExp &,int = -1) const;
|
||
13 years ago
|
// int findRev(const char *,int = -1) const;
|
||
13 years ago
|
int contains(TQChar,bool = 1) const;
|
||
13 years ago
|
int contains(char,bool = 1) const;
|
||
|
// int contains(const char *,bool = 1) const;
|
||
13 years ago
|
int contains(const TQString &,bool = 1) const;
|
||
|
int contains(const TQRegExp &) const;
|
||
13 years ago
|
|
||
|
enum SectionFlags {
|
||
|
SectionDefault,
|
||
|
SectionSkipEmpty,
|
||
|
SectionIncludeLeadingSep,
|
||
|
SectionIncludeTrailingSep,
|
||
|
SectionCaseInsensitiveSeps
|
||
|
};
|
||
|
|
||
13 years ago
|
TQString section(TQChar,int,int = 0xffffffff,int = SectionDefault) const;
|
||
|
// TQString section(char,int,int = 0xffffffff,int = SectionDefault) const;
|
||
|
// TQString section(const char *,int,int = 0xffffffff,
|
||
13 years ago
|
// int = SectionDefault) const;
|
||
13 years ago
|
TQString section(const TQString &,int,int = 0xffffffff,
|
||
13 years ago
|
int = SectionDefault) const;
|
||
13 years ago
|
TQString section(const TQRegExp &,int,int = 0xffffffff,
|
||
13 years ago
|
int = SectionDefault) const;
|
||
|
|
||
13 years ago
|
TQString left(uint) const;
|
||
|
TQString right(uint) const;
|
||
|
TQString mid(uint,uint = 0xffffffff) const;
|
||
|
TQString leftJustify(uint,TQChar = ' ',bool = 0) const;
|
||
|
TQString rightJustify(uint,TQChar = ' ',bool = 0) const;
|
||
|
TQString lower() const;
|
||
|
TQString upper() const;
|
||
|
TQString stripWhiteSpace() const;
|
||
|
TQString simplifyWhiteSpace() const;
|
||
|
|
||
|
TQString &insert(uint,const TQString &);
|
||
|
TQString &insert(uint,const TQByteArray &);
|
||
|
// TQString &insert(uint,const char *);
|
||
|
TQString &insert(uint,TQChar *,uint);
|
||
|
TQString &insert(uint,TQChar);
|
||
|
TQString &insert(uint,char);
|
||
|
|
||
|
TQString &append(char);
|
||
|
TQString &append(TQChar);
|
||
|
TQString &append(const TQString &);
|
||
|
TQString &prepend(char);
|
||
|
TQString &prepend(TQChar);
|
||
|
TQString &prepend(const TQString &);
|
||
|
TQString &remove(uint,uint);
|
||
|
TQString &remove(const TQString &);
|
||
|
TQString &remove(const TQString &,bool);
|
||
|
TQString &remove(TQChar);
|
||
|
TQString &remove(char);
|
||
|
TQString &remove(const TQRegExp &);
|
||
|
TQString &replace(uint,uint,const TQString &);
|
||
|
TQString &replace(uint,uint,const TQChar *,uint);
|
||
|
TQString &replace(uint,uint,TQChar);
|
||
|
TQString &replace(uint,uint,char);
|
||
|
TQString &replace(TQChar,const TQString &);
|
||
|
TQString &replace(TQChar,const TQString &,bool);
|
||
|
TQString &replace(char,const TQString &);
|
||
|
TQString &replace(char,const TQString &,bool);
|
||
|
TQString &replace(const TQString &,const TQString &);
|
||
|
TQString &replace(const TQString &,const TQString &,bool);
|
||
|
TQString &replace(const TQRegExp &,const TQString &);
|
||
|
TQString &replace(TQChar,TQChar);
|
||
13 years ago
|
|
||
|
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;
|
||
13 years ago
|
// TQ_LLONG toLongLong(bool * = 0,int = 10) const;
|
||
|
// TQ_ULLONG toULongLong(bool * = 0,int = 10) const;
|
||
13 years ago
|
float toFloat(bool * = 0) const;
|
||
|
double toDouble(bool * = 0) const;
|
||
|
|
||
13 years ago
|
TQString &setNum(int /Constrained/,int = 10);
|
||
|
TQString &setNum(double /Constrained/,char = 'g',int = 6);
|
||
|
// TQString &setNum(short,int = 10);
|
||
|
// TQString &setNum(ushort,int = 10);
|
||
|
// TQString &setNum(uint,int = 10);
|
||
|
TQString &setNum(long,int = 10);
|
||
|
TQString &setNum(ulong,int = 10);
|
||
13 years ago
|
// TQString &setNum(TQ_LLONG,int = 10);
|
||
|
// TQString &setNum(TQ_ULLONG,int = 10);
|
||
13 years ago
|
// TQString &setNum(float,char = 'g',int = 6);
|
||
13 years ago
|
|
||
13 years ago
|
static TQString number(int /Constrained/,int = 10);
|
||
|
static TQString number(double /Constrained/,char = 'g',int = 6);
|
||
|
static TQString number(long,int = 10);
|
||
|
static TQString number(ulong,int = 10);
|
||
13 years ago
|
// static TQString number(TQ_LLONG,int = 10);
|
||
|
// static TQString number(TQ_ULLONG,int = 10);
|
||
13 years ago
|
// static TQString number(uint,int = 10);
|
||
13 years ago
|
|
||
13 years ago
|
void setExpand(uint,TQChar);
|
||
13 years ago
|
|
||
13 years ago
|
TQString &operator+=(const TQString &);
|
||
|
TQString &operator+=(const TQByteArray &);
|
||
|
TQString &operator+=(TQChar);
|
||
|
//TQString &operator+=(char);
|
||
13 years ago
|
|
||
13 years ago
|
TQString operator*(int);
|
||
13 years ago
|
%MethodCode
|
||
13 years ago
|
sipRes = new TQString();
|
||
13 years ago
|
|
||
|
while (a0-- > 0)
|
||
|
*sipRes += *sipCpp;
|
||
|
%End
|
||
|
|
||
13 years ago
|
TQString &operator*=(int);
|
||
13 years ago
|
%MethodCode
|
||
13 years ago
|
TQString orig(*sipCpp);
|
||
13 years ago
|
|
||
|
sipCpp -> truncate(0);
|
||
|
|
||
|
while (a0-- > 0)
|
||
|
*sipCpp += orig;
|
||
|
%End
|
||
|
|
||
13 years ago
|
TQChar at(uint) const;
|
||
|
// TQCharRef at(uint);
|
||
|
// TQChar constref(uint) const;
|
||
|
// TQChar &ref(uint);
|
||
|
// const TQChar *unicode() const;
|
||
13 years ago
|
const char *ascii() const;
|
||
13 years ago
|
static TQString fromAscii(const char *,int = -1);
|
||
13 years ago
|
const char *latin1() const;
|
||
13 years ago
|
static TQString fromLatin1(const char *,int = -1);
|
||
|
TQCString utf8() const;
|
||
|
static TQString fromUtf8(const char *,int = -1);
|
||
|
TQCString local8Bit() const;
|
||
|
static TQString fromLocal8Bit(const char *,int = -1);
|
||
|
|
||
|
// static TQString fromUcs2(const unsigned short *);
|
||
13 years ago
|
// const unsigned short *ucs2() const;
|
||
|
|
||
13 years ago
|
// TQString &setUnicode(const TQChar *,uint);
|
||
|
// TQString &setUnicodeCodes(const ushort *,uint);
|
||
|
TQString &setAscii(const char *,int = -1);
|
||
|
TQString &setLatin1(const char *,int = -1);
|
||
13 years ago
|
|
||
13 years ago
|
int compare(const TQString &) const;
|
||
|
static int compare(const TQString &,const TQString &);
|
||
13 years ago
|
|
||
13 years ago
|
int localeAwareCompare(const TQString &) const;
|
||
|
static int localeAwareCompare(const TQString &,const TQString &);
|
||
13 years ago
|
|
||
|
void compose();
|
||
13 years ago
|
bool startsWith(const TQString &) const;
|
||
|
bool startsWith(const TQString &,bool) const;
|
||
|
bool endsWith(const TQString &) const;
|
||
|
bool endsWith(const TQString &,bool) const;
|
||
13 years ago
|
|
||
|
void setLength(uint);
|
||
|
|
||
|
uint capacity() const;
|
||
|
void reserve(uint);
|
||
|
void squeeze();
|
||
|
|
||
|
bool simpleText() const;
|
||
|
bool isRightToLeft() const;
|
||
|
|
||
13 years ago
|
// Force the numeric interpretation so that str + TQString gets handled
|
||
13 years ago
|
// as we want.
|
||
13 years ago
|
const TQString operator+(const TQString &) /Numeric/;
|
||
13 years ago
|
|
||
13 years ago
|
TQString operator[](int) const;
|
||
13 years ago
|
%MethodCode
|
||
|
int len;
|
||
|
|
||
|
len = sipCpp -> length();
|
||
|
|
||
|
if ((a0 = (int)sipConvertFromSequenceIndex(a0,len)) < 0)
|
||
|
sipIsErr = 1;
|
||
|
else
|
||
13 years ago
|
sipRes = new TQString(sipCpp -> at(a0));
|
||
13 years ago
|
%End
|
||
|
|
||
13 years ago
|
TQString operator[](SIP_PYSLICE) const;
|
||
13 years ago
|
%MethodCode
|
||
|
Py_ssize_t len, start, stop, step, slicelength, i;
|
||
|
|
||
|
len = sipCpp -> length();
|
||
|
|
||
|
if (sipConvertFromSliceObject(a0,len,&start,&stop,&step,&slicelength) < 0)
|
||
|
sipIsErr = 1;
|
||
|
else
|
||
|
{
|
||
13 years ago
|
sipRes = new TQString();
|
||
13 years ago
|
|
||
|
for (i = 0; i < slicelength; ++i)
|
||
|
{
|
||
|
sipRes -> append(sipCpp -> at(start));
|
||
|
start += step;
|
||
|
}
|
||
|
}
|
||
|
%End
|
||
|
|
||
|
int __len__() const;
|
||
|
%MethodCode
|
||
|
sipRes = sipCpp -> length();
|
||
|
%End
|
||
|
|
||
13 years ago
|
int __contains__(const TQString &) const;
|
||
13 years ago
|
%MethodCode
|
||
|
sipRes = (sipCpp -> contains(*a0) > 0);
|
||
|
%End
|
||
|
|
||
|
SIP_PYOBJECT __unicode__();
|
||
|
%MethodCode
|
||
2 years ago
|
sipRes = PyTQt_tqt_PyObject_FromTQString(sipCpp);
|
||
13 years ago
|
%End
|
||
|
|
||
|
SIP_PYOBJECT __str__();
|
||
|
%MethodCode
|
||
2 years ago
|
sipRes = PyTQt_tqt_PyObject_FromTQString(sipCpp);
|
||
13 years ago
|
%End
|
||
|
|
||
|
%ConvertToTypeCode
|
||
13 years ago
|
// Allow a Python string (or a unicode string) whenever a TQString is
|
||
13 years ago
|
// expected.
|
||
|
|
||
|
if (sipIsErr == NULL)
|
||
2 years ago
|
return (PyBytes_Check(sipPy) ||
|
||
13 years ago
|
PyUnicode_Check(sipPy) ||
|
||
13 years ago
|
sipCanConvertToInstance(sipPy,sipClass_TQString,SIP_NO_CONVERTORS));
|
||
13 years ago
|
|
||
2 years ago
|
*sipCppPtr = PyTQt_tqt_PyObject_AsTQString(sipPy);
|
||
13 years ago
|
|
||
|
if (*sipCppPtr)
|
||
|
return sipGetState(sipTransferObj);
|
||
|
|
||
13 years ago
|
*sipCppPtr = reinterpret_cast<TQString *>(sipConvertToInstance(sipPy,sipClass_TQString,sipTransferObj,SIP_NO_CONVERTORS,0,sipIsErr));
|
||
13 years ago
|
|
||
|
return 0;
|
||
|
%End
|
||
|
|
||
|
%BIGetReadBufferCode
|
||
|
if (sipSegment != 0)
|
||
|
{
|
||
13 years ago
|
PyErr_SetString(PyExc_SystemError, "accessing non-existent TQString segment");
|
||
13 years ago
|
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)
|
||
|
{
|
||
13 years ago
|
PyErr_SetString(PyExc_SystemError, "accessing non-existent TQString segment");
|
||
13 years ago
|
sipRes = -1;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
13 years ago
|
static TQTextCodec *codec = 0;
|
||
13 years ago
|
static bool check_codec = TRUE;
|
||
|
|
||
13 years ago
|
// For the first time only, try and find a TQt codec that
|
||
13 years ago
|
// corresponds to the default Python codec. If one wasn't
|
||
|
// found then fall back to ASCII (which is actually the codec
|
||
13 years ago
|
// returned by TQTextCodec::codecForCStrings()).
|
||
13 years ago
|
if (check_codec)
|
||
|
{
|
||
13 years ago
|
codec = TQTextCodec::codecForName(PyUnicode_GetDefaultEncoding());
|
||
13 years ago
|
check_codec = FALSE;
|
||
|
}
|
||
|
|
||
|
if (codec)
|
||
|
{
|
||
|
// A Python string is the most convenient method to
|
||
|
// save the encoded version on the heap.
|
||
|
PyObject *encobj = ((sipSimpleWrapper *)sipSelf)->user;
|
||
13 years ago
|
TQCString enc;
|
||
13 years ago
|
|
||
|
Py_XDECREF(encobj);
|
||
|
|
||
|
enc = codec->fromUnicode(*sipCpp);
|
||
|
|
||
2 years ago
|
if ((encobj = PyBytes_FromString(enc.data())) != NULL)
|
||
13 years ago
|
{
|
||
|
*sipPtrPtr = (void *)PyString_AS_STRING(encobj);
|
||
|
sipRes = PyString_GET_SIZE(encobj);
|
||
|
|
||
|
((sipSimpleWrapper *)sipSelf)->user = encobj;
|
||
|
}
|
||
|
else
|
||
|
sipRes = -1;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
const char *asc = sipCpp->ascii();
|
||
|
|
||
|
*sipPtrPtr = (void *)asc;
|
||
13 years ago
|
sipRes = tqstrlen(asc);
|
||
13 years ago
|
}
|
||
|
}
|
||
|
%End
|
||
|
};
|
||
|
|
||
13 years ago
|
bool operator==(const TQString &,const TQString &);
|
||
|
bool operator!=(const TQString &,const TQString &);
|
||
|
bool operator<(const TQString &,const TQString &);
|
||
|
bool operator<=(const TQString &,const TQString &);
|
||
|
bool operator>(const TQString &,const TQString &);
|
||
|
bool operator>=(const TQString &,const TQString &);
|
||
13 years ago
|
|
||
|
|
||
3 years ago
|
%ModuleHeaderCode
|
||
2 years ago
|
extern PyObject *PyTQt_tqt_PyObject_FromTQString(const TQString *tqstr);
|
||
3 years ago
|
%End
|
||
13 years ago
|
|
||
3 years ago
|
%ModuleCode
|
||
2 years ago
|
// Convert a TQString to a Python Unicode object.
|
||
|
PyObject *PyTQt_tqt_PyObject_FromTQString(const TQString *tqstr)
|
||
13 years ago
|
{
|
||
3 years ago
|
PyObject *obj;
|
||
|
|
||
|
// We have to work out exactly which kind to use. We assume ASCII while we
|
||
|
// are checking so that we only go through the string once in the most
|
||
|
// common case. Note that we can't use PyUnicode_FromKindAndData() because
|
||
|
// it doesn't handle surrogates in UCS2 strings.
|
||
|
|
||
2 years ago
|
int tqt_len = tqstr->length();
|
||
3 years ago
|
Py_UCS4 maxchar = 0x007f;
|
||
|
|
||
2 years ago
|
for (int tqt_i = 0; tqt_i < tqt_len && maxchar < 0xffff; ++tqt_i)
|
||
3 years ago
|
{
|
||
2 years ago
|
Py_UCS4 uch = tqstr->at(tqt_i).unicode();
|
||
3 years ago
|
|
||
|
if (uch > 0x00ff)
|
||
|
{
|
||
|
maxchar = 0xffff;
|
||
|
}
|
||
|
else if (uch > 0x007f)
|
||
|
{
|
||
|
maxchar = 0x00ff;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
// Create the correctly sized object.
|
||
2 years ago
|
if ((obj = PyUnicode_New(tqt_len, maxchar)) == NULL)
|
||
3 years ago
|
return NULL;
|
||
|
|
||
|
int kind = PyUnicode_KIND(obj);
|
||
|
void *data = PyUnicode_DATA(obj);
|
||
|
|
||
2 years ago
|
for (int tqt_i = 0; tqt_i < tqt_len; ++tqt_i)
|
||
3 years ago
|
{
|
||
2 years ago
|
Py_UCS4 uch = tqstr->at(tqt_i).unicode();
|
||
|
PyUnicode_WRITE(kind, data, tqt_i, uch);
|
||
3 years ago
|
}
|
||
|
|
||
|
return obj;
|
||
|
}
|
||
13 years ago
|
%End
|
||
|
|
||
|
|
||
3 years ago
|
%ModuleHeaderCode
|
||
2 years ago
|
extern TQString *PyTQt_tqt_PyObject_AsTQString(PyObject *obj);
|
||
3 years ago
|
%End
|
||
13 years ago
|
|
||
3 years ago
|
%ModuleCode
|
||
2 years ago
|
// Convert a Python Unicode object to a TQString.
|
||
|
TQString *PyTQt_tqt_PyObject_AsTQString(PyObject *obj)
|
||
3 years ago
|
{
|
||
|
if (PyUnicode_Check(obj))
|
||
|
{
|
||
|
SIP_SSIZE_T len = PyUnicode_GET_LENGTH(obj);
|
||
13 years ago
|
|
||
3 years ago
|
switch (PyUnicode_KIND(obj))
|
||
|
{
|
||
|
case PyUnicode_1BYTE_KIND:
|
||
2 years ago
|
return new TQString(TQString::fromUtf8((char *)PyUnicode_1BYTE_DATA(obj), len));
|
||
13 years ago
|
|
||
3 years ago
|
case PyUnicode_2BYTE_KIND:
|
||
|
// The (TQChar *) cast should be safe.
|
||
|
return new TQString((TQChar *)PyUnicode_2BYTE_DATA(obj), len);
|
||
13 years ago
|
|
||
3 years ago
|
case PyUnicode_4BYTE_KIND:
|
||
|
// Note that this doesn't handle code points greater than 0xffff. It
|
||
2 years ago
|
// could but it's only an issue for old versions of TQt.
|
||
13 years ago
|
|
||
2 years ago
|
TQString *tqstr = new TQString;
|
||
13 years ago
|
|
||
3 years ago
|
Py_UCS4 *ucode = PyUnicode_4BYTE_DATA(obj);
|
||
13 years ago
|
|
||
3 years ago
|
for (SIP_SSIZE_T i = 0; i < len; ++i)
|
||
2 years ago
|
tqstr->append(TQChar((uint)ucode[i]));
|
||
13 years ago
|
|
||
2 years ago
|
return tqstr;
|
||
3 years ago
|
}
|
||
13 years ago
|
|
||
3 years ago
|
return NULL;
|
||
|
}
|
||
|
else if (PyBytes_Check(obj))
|
||
|
{
|
||
2 years ago
|
return new TQString(PyBytes_AS_STRING(obj));
|
||
3 years ago
|
}
|
||
|
|
||
|
return NULL;
|
||
|
}
|
||
|
%End
|
||
|
|
||
|
|
||
|
%ModuleHeaderCode
|
||
2 years ago
|
extern const char *PyTQt_tqt_encode(PyObject **s, TQApplication::Encoding encoding);
|
||
13 years ago
|
%End
|
||
|
|
||
3 years ago
|
%ModuleCode
|
||
|
// Convert a Python unicode/string/bytes object to a character string encoded
|
||
|
// according to the given encoding. Update the object with a new reference to
|
||
|
// the object that owns the data.
|
||
2 years ago
|
const char *PyTQt_tqt_encode(PyObject **s, TQApplication::Encoding encoding)
|
||
3 years ago
|
{
|
||
|
PyObject *obj = *s;
|
||
|
const char *es = 0;
|
||
|
SIP_SSIZE_T sz;
|
||
|
|
||
|
if (PyUnicode_Check(obj))
|
||
|
{
|
||
|
if (encoding == TQApplication::UnicodeUTF8)
|
||
|
{
|
||
|
obj = PyUnicode_AsUTF8String(obj);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
TQTextCodec *codec = TQTextCodec::codecForTr();
|
||
|
|
||
|
if (codec)
|
||
|
{
|
||
2 years ago
|
// Use the TQt codec to get to a byte string, and then to a
|
||
3 years ago
|
// Python object.
|
||
2 years ago
|
TQString *tqstr = PyTQt_tqt_PyObject_AsTQString(obj);
|
||
|
TQString tqs = *tqstr;
|
||
|
TQByteArray ba = codec->fromUnicode(tqs);
|
||
|
delete tqstr;
|
||
3 years ago
|
|
||
|
obj = PyBytes_FromStringAndSize(ba.data(), ba.size());
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
obj = PyUnicode_AsLatin1String(obj);
|
||
|
}
|
||
|
}
|
||
|
|
||
|
if (obj)
|
||
|
{
|
||
|
es = PyBytes_AS_STRING(obj);
|
||
|
}
|
||
|
}
|
||
|
else if (PyBytes_Check(obj))
|
||
|
{
|
||
|
es = PyBytes_AS_STRING(obj);
|
||
|
Py_INCREF(obj);
|
||
|
}
|
||
|
else if (PyObject_AsCharBuffer(obj, &es, &sz) >= 0)
|
||
|
{
|
||
|
Py_INCREF(obj);
|
||
|
}
|
||
|
|
||
|
if (es)
|
||
|
{
|
||
|
*s = obj;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
PyErr_Format(PyExc_UnicodeEncodeError,
|
||
|
"unable to convert '%s' to requested encoding",
|
||
|
Py_TYPE(*s)->tp_name);
|
||
|
}
|
||
|
|
||
|
return es;
|
||
|
}
|
||
13 years ago
|
%End
|