1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409
|
// qbytearray.sip generated by MetaSIP on Fri Apr 16 11:32:08 2010
//
// This file is part of the QtCore Python extension module.
//
// Copyright (c) 2010 Riverbank Computing Limited <info@riverbankcomputing.com>
//
// This file is part of PyQt.
//
// This file may be used under the terms of the GNU General Public
// License versions 2.0 or 3.0 as published by the Free Software
// Foundation and appearing in the files LICENSE.GPL2 and LICENSE.GPL3
// included in the packaging of this file. Alternatively you may (at
// your option) use any later version of the GNU General Public
// License if such license has been publicly approved by Riverbank
// Computing Limited (or its successors, if any) and the KDE Free Qt
// Foundation. In addition, as a special exception, Riverbank gives you
// certain additional rights. These rights are described in the Riverbank
// GPL Exception version 1.1, which can be found in the file
// GPL_EXCEPTION.txt in this package.
//
// Please review the following information to ensure GNU General
// Public Licensing requirements will be met:
// http://trolltech.com/products/qt/licenses/licensing/opensource/. If
// you are unsure which license is appropriate for your use, please
// review the following information:
// http://trolltech.com/products/qt/licenses/licensing/licensingoverview
// or contact the sales department at sales@riverbankcomputing.com.
//
// This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
// WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
%ModuleCode
#include <qbytearray.h>
%End
quint16 qChecksum(const char * /Array/, uint /ArraySize/);
class QByteArray
{
%TypeHeaderCode
#include <qbytearray.h>
%End
%TypeCode
// This is needed by __hash__().
#include <qhash.h>
// Convenience function for converting a QByteArray to a Python str object.
static PyObject *QByteArrayToPyStr(QByteArray *ba)
{
char *data = ba->data();
if (data)
// QByteArrays may have embedded '\0's so set the size explicitly.
return SIPBytes_FromStringAndSize(data, ba->size());
return SIPBytes_FromString("");
}
%End
%ConvertToTypeCode
// We have to be very careful about what we allow to be converted to a
// QByteArray and to a QString as we need to take into account the v1 and v2
// APIs and Python v2.x and v3.x.
//
// QSvgRenderer() is a good example of what needs to work "naturally". This
// has a ctor that takes a QString argument that is the name of the SVG file.
// It has another ctor that takes a QByteArray argument that is the SVG data.
//
// In Python v2.x we want a str object to be interpreted as the name of the
// file (as that is the historical behaviour). This has the following
// implications.
//
// - The QString version of the ctor must appear before the QByteArray version
// in the .sip file. This rule should be applied wherever a similar
// situation arises.
// - A QString must not automatically convert a QByteArray.
// - QByteArray must also exist in the v2 API.
//
// In Python v3.x we want a bytes object to be used wherever a QByteArray is
// expected. This means that a QString must not automatically convert a bytes
// object.
//
// Qt uses QByteArray to represent binary data and also '\0' terminated C
// strings. If we only allowed a bytes object to be automatically converted to
// a QByteArray then we would force such strings to be either explicitly
// specified as bytes (ie. have a leading 'b') or wrapped in a call to the
// QByteArray ctor - neither of which is very Pythonic. We therefore allow a
// Latin-1 encoded str object to be automatcially converted to a QByteArray.
// For consistency we also allow a Python v2.x unicode object to be similarly
// converted.
if (sipIsErr == NULL)
return (
#if PY_VERSION_HEX >= 0x02060000
PyByteArray_Check(sipPy) ||
#endif
PyUnicode_Check(sipPy) || SIPBytes_Check(sipPy) ||
sipCanConvertToType(sipPy, sipType_QByteArray, SIP_NO_CONVERTORS));
#if PY_VERSION_HEX >= 0x02060000
if (PyByteArray_Check(sipPy))
{
*sipCppPtr = new QByteArray(PyByteArray_AS_STRING(sipPy),
PyByteArray_GET_SIZE(sipPy));
return sipGetState(sipTransferObj);
}
#endif
if (PyUnicode_Check(sipPy))
{
const char *bytes = sipString_AsLatin1String(&sipPy);
if (!sipPy)
{
*sipIsErr = 1;
return 0;
}
*sipCppPtr = new QByteArray(bytes);
Py_DECREF(sipPy);
return sipGetState(sipTransferObj);
}
if (SIPBytes_Check(sipPy))
{
*sipCppPtr = new QByteArray(SIPBytes_AS_STRING(sipPy),
SIPBytes_GET_SIZE(sipPy));
return sipGetState(sipTransferObj);
}
*sipCppPtr = reinterpret_cast<QByteArray *>(sipConvertToType(sipPy,
sipType_QByteArray, sipTransferObj, SIP_NO_CONVERTORS, 0, sipIsErr));
return 0;
%End
%BIGetBufferCode
sipRes = PyBuffer_FillInfo(sipBuffer, sipSelf, sipCpp->data(), sipCpp->size(), 0, sipFlags);
%End
%BIGetReadBufferCode
if (sipSegment != 0)
{
PyErr_SetString(PyExc_SystemError, "accessing non-existent QByteArray segment");
sipRes = -1;
}
else
{
*sipPtrPtr = (void *)sipCpp->data();
sipRes = sipCpp->size();
}
%End
%BIGetSegCountCode
if (sipLenPtr)
*sipLenPtr = sipCpp->size();
sipRes = 1;
%End
%BIGetCharBufferCode
if (sipSegment != 0)
{
PyErr_SetString(PyExc_SystemError, "accessing non-existent QByteArray segment");
sipRes = -1;
}
else
{
*sipPtrPtr = (void *)sipCpp->data();
sipRes = sipCpp->size();
}
%End
%PickleCode
sipRes = Py_BuildValue((char *)"(s#)", sipCpp->data(), sipCpp->size());
%End
public:
QByteArray();
QByteArray(int, char);
QByteArray(const QByteArray &);
~QByteArray();
void resize(int);
QByteArray &fill(char, int size = -1);
void clear();
int indexOf(const QByteArray &, int from = 0) const;
int indexOf(const QString &, int from = 0) const;
int lastIndexOf(const QByteArray &, int from = -1) const;
int lastIndexOf(const QString &, int from = -1) const;
int count(const QByteArray &) const;
QByteArray left(int) const;
QByteArray right(int) const;
QByteArray mid(int, int length = -1) const;
bool startsWith(const QByteArray &) const;
bool endsWith(const QByteArray &) const;
void truncate(int);
void chop(int);
QByteArray toLower() const;
QByteArray toUpper() const;
QByteArray trimmed() const;
QByteArray simplified() const;
QByteArray leftJustified(int, char fill = ' ', bool truncate = false) const;
QByteArray rightJustified(int, char fill = ' ', bool truncate = false) const;
QByteArray &prepend(const QByteArray &);
QByteArray &append(const QByteArray &);
QByteArray &append(const QString &);
QByteArray &insert(int, const QByteArray &);
QByteArray &insert(int, const QString &);
QByteArray &remove(int, int);
QByteArray &replace(int, int, const QByteArray &);
QByteArray &replace(const QByteArray &, const QByteArray &);
QByteArray &replace(const QString &, const QByteArray &);
QList<QByteArray> split(char) const;
QByteArray &operator+=(const QByteArray &);
QByteArray &operator+=(const QString &);
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;
short toShort(bool *ok = 0, int base = 10) const;
ushort toUShort(bool *ok = 0, int base = 10) const;
int toInt(bool *ok = 0, int base = 10) const;
uint toUInt(bool *ok = 0, int base = 10) const;
long toLong(bool *ok = 0, int base = 10) const;
ulong toULong(bool *ok = 0, int base = 10) const;
qlonglong toLongLong(bool *ok = 0, int base = 10) const;
qulonglong toULongLong(bool *ok = 0, int base = 10) const;
float toFloat(bool *ok = 0) const;
double toDouble(bool *ok = 0) const;
QByteArray toBase64() const;
QByteArray &setNum(int /Constrained/, int base = 10);
QByteArray &setNum(double /Constrained/, char format = 'g', int precision = 6);
QByteArray &setNum(qlonglong, int base = 10);
QByteArray &setNum(qulonglong, int base = 10);
static QByteArray number(int /Constrained/, int base = 10);
static QByteArray number(double /Constrained/, char format = 'g', int precision = 6);
static QByteArray number(qlonglong, int base = 10);
static QByteArray number(qulonglong, int base = 10);
static QByteArray fromBase64(const QByteArray &);
static QByteArray fromRawData(const char * /Array/, int /ArraySize/);
%If (Qt_4_3_0 -)
static QByteArray fromHex(const QByteArray &);
%End
int count() const;
int length() const;
bool isNull() const;
int size() const;
const char at(int) const;
const char operator[](int) const;
%MethodCode
SIP_SSIZE_T idx = sipConvertFromSequenceIndex(a0, sipCpp->count());
if (idx < 0)
sipIsErr = 1;
else
sipRes = sipCpp->operator[]((int)idx);
%End
QByteArray operator[](SIP_PYSLICE slice) const;
%MethodCode
SIP_SSIZE_T len, start, stop, step, slicelength, i;
len = sipCpp->length();
if (PySlice_GetIndicesEx((PySliceObject *)a0, len, &start, &stop, &step, &slicelength) < 0)
sipIsErr = 1;
else
{
sipRes = new QByteArray();
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 QByteArray &a) const;
%MethodCode
// It looks like you can't assign QBool to int.
sipRes = bool(sipCpp->contains(*a0));
%End
long __hash__() const;
%MethodCode
sipRes = qHash(*sipCpp);
%End
SIP_PYOBJECT __str__() const /DocType="str"/;
%MethodCode
sipRes = QByteArrayToPyStr(sipCpp);
#if PY_MAJOR_VERSION >= 3
PyObject *repr = PyObject_Repr(sipRes);
if (repr)
{
Py_DECREF(sipRes);
sipRes = repr;
}
#endif
%End
SIP_PYOBJECT __repr__() const /DocType="str"/;
%MethodCode
PyObject *str = QByteArrayToPyStr(sipCpp);
if (str)
{
#if PY_MAJOR_VERSION >= 3
sipRes = PyUnicode_FromFormat("PyQt4.QtCore.QByteArray(%R)", str);
#else
sipRes = PyString_FromString("PyQt4.QtCore.QByteArray(");
PyString_ConcatAndDel(&sipRes, PyObject_Repr(str));
PyString_ConcatAndDel(&sipRes, PyString_FromString(")"));
#endif
Py_DECREF(str);
}
%End
QByteArray operator*(int m) const;
%MethodCode
sipRes = new QByteArray();
while (a0-- > 0)
*sipRes += *sipCpp;
%End
QByteArray &operator*=(int m);
%MethodCode
QByteArray orig(*sipCpp);
sipCpp->clear();
while (a0-- > 0)
*sipCpp += orig;
%End
bool isEmpty() const;
SIP_PYOBJECT data() /DocType="Py_v3:bytes;str"/;
%MethodCode
// QByteArrays may contain embedded '\0's so set the size explicitly.
char *res = sipCpp->data();
int len = sipCpp->size();
if (res)
{
if ((sipRes = SIPBytes_FromStringAndSize(res, len)) == NULL)
sipIsErr = 1;
}
else
{
Py_INCREF(Py_None);
sipRes = Py_None;
}
%End
int capacity() const;
void reserve(int);
void squeeze();
void push_back(const QByteArray &);
void push_front(const QByteArray &);
QBool contains(const QByteArray &) const;
%If (Qt_4_3_0 -)
QByteArray toHex() const;
%End
%If (Qt_4_4_0 -)
QByteArray toPercentEncoding(const QByteArray &exclude = QByteArray(), const QByteArray &include = QByteArray(), char percent = '%') const;
%End
%If (Qt_4_4_0 -)
static QByteArray fromPercentEncoding(const QByteArray &, char percent = '%');
%End
%If (Qt_4_5_0 -)
QByteArray repeated(int) const;
%End
};
bool operator==(const QByteArray &, const QByteArray &);
bool operator!=(const QByteArray &, const QByteArray &);
bool operator<(const QByteArray &, const QByteArray &);
bool operator<=(const QByteArray &, const QByteArray &);
bool operator>(const QByteArray &, const QByteArray &);
bool operator>=(const QByteArray &, const QByteArray &);
const QByteArray operator+(const QByteArray &, const QByteArray &);
QDataStream &operator<<(QDataStream &, const QByteArray & /Constrained/);
QDataStream &operator>>(QDataStream &, QByteArray & /Constrained/);
QByteArray qCompress(const QByteArray &, int compressionLevel = -1);
QByteArray qUncompress(const QByteArray &);
%If (Qt_4_3_0 -)
void qSwap(QByteArray &, QByteArray &);
%End
|