// // Copyright 2006 Jim Bublitz // Earlier copyrights 1998 - 2005 Jim Bublitz and/or Phil Thompson // may also apply // Generated by preSip // module kdecore version KDE 3.5.3 // This software 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 of // the License, or (at your option) any later version. // // This software is distributed 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 this library; see the file COPYING. // If not, write to the Free Software Foundation, Inc., // 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. %ModuleHeaderCode #include %End %If ( KDE_3_2_0 - ) class KMacroExpanderBase { %TypeHeaderCode #include %End public: KMacroExpanderBase (QChar = '%'); void expandMacros (QString&); bool expandMacrosShellQuote (QString&, uint& /In, Out/); bool expandMacrosShellQuote (QString&); void setEscapeChar (QChar); QChar escapeChar () const; protected: virtual int expandPlainMacro (const QString&, uint, QStringList&); virtual int expandEscapedMacro (const QString&, uint, QStringList&); }; // class KMacroExpanderBase %End %If ( KDE_3_3_0 - ) class KWordMacroExpander : KMacroExpanderBase { %TypeHeaderCode #include %End public: KWordMacroExpander (QChar = '%'); protected: virtual int expandPlainMacro (const QString&, uint, QStringList&); virtual int expandEscapedMacro (const QString&, uint, QStringList&); virtual bool expandMacro (const QString&, QStringList&) = 0; }; // class KWordMacroExpander %End %If ( KDE_3_3_0 - ) class KCharMacroExpander : KMacroExpanderBase { %TypeHeaderCode #include %End public: KCharMacroExpander (QChar = '%'); protected: virtual int expandPlainMacro (const QString&, uint, QStringList&); virtual int expandEscapedMacro (const QString&, uint, QStringList&); virtual bool expandMacro (QChar, QStringList&) = 0; }; // class KCharMacroExpander %End %If ( KDE_3_2_0 - ) namespace KMacroExpander { QString expandMacros (const QString&, const QMap&, QChar = '%'); QString expandMacrosShellQuote (const QString&, const QMap&, QChar = '%'); QString expandMacros (const QString&, const QMap&, QChar = '%'); QString expandMacrosShellQuote (const QString&, const QMap&, QChar = '%'); QString expandMacros (const QString&, const QMap&, QChar = '%'); QString expandMacros (const QString&, const QMap&, QChar = '%'); QString expandMacrosShellQuote (const QString&, const QMap&, QChar = '%'); QString expandMacrosShellQuote (const QString&, const QMap&, QChar = '%'); }; // namespace KMacroExpander %End %MappedType QMap //converts a Python dict of QChar:QString { %TypeHeaderCode #include #include %End %ConvertFromTypeCode if (!sipCpp) return PyDict_New(); PyObject *dict; // Create the dictionary. if ((dict = PyDict_New()) == NULL) return NULL; // Get it. const QMap map = *sipCpp; QMap::ConstIterator it; for (it = map.begin (); it != map.end (); ++it) { QChar acpp = it.key (); PyObject *binst = PyString_FromString ((char *)((QString *)&it.data ())); PyObject *ainst; if (((ainst = sipConvertFromNewType(new QChar(acpp), sipType_QChar, sipTransferObj)) == NULL) || (binst == NULL) || (PyDict_SetItem (dict, ainst, binst) < 0)) { Py_XDECREF (ainst); Py_XDECREF (binst); Py_DECREF (dict); return NULL; } } return dict; %End %ConvertToTypeCode // Convert a Python dictionary to a QMap if (sipIsErr == NULL) return PyDict_Check(sipPy); QMap *map = new QMap; PyObject *key, *value; SIP_SSIZE_T pos = 0; QChar *cKey; QString *sData; while (PyDict_Next(sipPy, &pos, &key, &value)) { int iserr = 0, cKey_state, sData_state; cKey = (QChar *)sipForceConvertToType(key, sipType_QChar, sipTransferObj, SIP_NOT_NONE, &cKey_state, &iserr); sData = (QString *)sipForceConvertToType(value, sipType_QString, sipTransferObj, SIP_NOT_NONE, &sData_state, &iserr); if (iserr) { if (cKey) sipReleaseType(cKey, sipType_QChar, cKey_state); *sipIsErr = 1; delete map; return 0; } map->insert (*cKey, *sData); sipReleaseType(cKey, sipType_QChar, cKey_state); sipReleaseType(sData, sipType_QString, sData_state); } *sipCppPtr = map; return 1; %End }; %MappedType QMap //converts a Python dict of QString:QStringList { %TypeHeaderCode #include #include #include %End %ConvertFromTypeCode if (!sipCpp) return PyDict_New(); PyObject *dict; // Create the dictionary. if ((dict = PyDict_New()) == NULL) return NULL; // Get it. const QMap map = *sipCpp; QMap::ConstIterator it; for (it = map.begin (); it != map.end (); ++it) { QStringList bcpp = it.data (); PyObject *ainst = PyString_FromString ((char *)((QString *)&it.key ())); PyObject *binst; if (((binst = sipConvertFromNewType(new QStringList(bcpp), sipType_QStringList, sipTransferObj)) == NULL) || (ainst == NULL) || (PyDict_SetItem (dict, ainst, binst) < 0)) { Py_XDECREF (ainst); Py_XDECREF (binst); Py_DECREF (dict); return NULL; } } return dict; %End %ConvertToTypeCode // Convert a Python dictionary to a QMap on the heap. if (sipIsErr == NULL) return PyDict_Check(sipPy); QMap *map = new QMap; PyObject *key, *value; SIP_SSIZE_T pos = 0; QString *sKey; QStringList *slData; while (PyDict_Next(sipPy, &pos, &key, &value)) { int iserr = 0, sKey_state, slData_state; sKey = (QString *)sipForceConvertToType(key, sipType_QString, sipTransferObj, SIP_NOT_NONE, &sKey_state, &iserr); slData = (QStringList *)sipForceConvertToType(value, sipType_QStringList, sipTransferObj, SIP_NOT_NONE, &slData_state, &iserr); if (iserr) { if (sKey) sipReleaseType(sKey, sipType_QString, sKey_state); *sipIsErr = 1; delete map; return 0; } map->insert (*sKey, *slData); sipReleaseType(sKey, sipType_QString, sKey_state); sipReleaseType(slData, sipType_QStringList, slData_state); } *sipCppPtr = map; return 1; %End }; %MappedType QMap //converts a Python dict of QChar:QStringList { %TypeHeaderCode #include #include #include %End %ConvertFromTypeCode if (!sipCpp) return PyDict_New(); PyObject *dict; // Create the dictionary. if ((dict = PyDict_New()) == NULL) return NULL; // Get it. const QMap map = *sipCpp; QMap::ConstIterator it; for (it = map.begin (); it != map.end (); ++it) { QChar acpp = it.key (); QStringList bcpp = it.data (); PyObject *binst; PyObject *ainst; if (((ainst = sipConvertFromNewType(new QChar(acpp), sipType_QChar, sipTransferObj)) == NULL) || (binst = sipConvertFromNewType(new QStringList(bcpp), sipType_QStringList, sipTransferObj)) || (PyDict_SetItem (dict, ainst, binst) < 0)) { Py_XDECREF (ainst); Py_XDECREF (binst); Py_DECREF (dict); return NULL; } } return dict; %End %ConvertToTypeCode // Convert a Python dictionary to a QMap on the heap. if (sipIsErr == NULL) return PyDict_Check(sipPy); QMap *map = new QMap; PyObject *key, *value; SIP_SSIZE_T pos = 0; QChar *cKey; QStringList *slData; while (PyDict_Next(sipPy, &pos, &key, &value)) { int iserr = 0, cKey_state, slData_state; cKey = (QChar *)sipForceConvertToType(key, sipType_QChar, sipTransferObj, SIP_NOT_NONE, &cKey_state, &iserr); slData = (QStringList *)sipForceConvertToType(value, sipType_QStringList, sipTransferObj, SIP_NOT_NONE, &slData_state, &iserr); if (iserr) { if (cKey) sipReleaseType(cKey, sipType_QChar, cKey_state); *sipIsErr = 1; delete map; return 0; } map->insert (*cKey, *slData); sipReleaseType(cKey, sipType_QChar, cKey_state); sipReleaseType(slData, sipType_QStringList, slData_state); } *sipCppPtr = map; return 1; %End };