// // 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 = sipBuildResult (NULL, "N", new QChar (acpp), sipClass_QChar)) == 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; int pos = 0; QChar *cKey; QString *sData; while (PyDict_Next(sipPy, &pos, &key, &value)) { int iserr = 0; cKey = (QChar *)sipForceConvertTo_QChar (key, &iserr); sData = (QString *)sipForceConvertTo_QString (value, &iserr); if (iserr) { *sipIsErr = 1; delete map; return 0; } map->insert (*cKey, *sData); } *sipCppPtr = map; return 1; %End }; %MappedType QMap //converts a Python dict of QString:QStringList { %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) { QStringList bcpp = it.data (); PyObject *ainst = PyString_FromString ((char *)((QString *)&it.key ())); PyObject *binst; if (((binst = sipBuildResult (NULL, "N", new QStringList (bcpp), sipClass_QStringList)) == 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; int pos = 0; QString *sKey; QStringList *slData; while (PyDict_Next(sipPy, &pos, &key, &value)) { int iserr = 0; sKey = (QString *)sipForceConvertTo_QString (value, &iserr); slData = (QStringList *)sipForceConvertTo_QStringList (value, &iserr); if (iserr) { *sipIsErr = 1; delete map; return 0; } map->insert (*sKey, *slData); } *sipCppPtr = map; return 1; %End }; %MappedType QMap //converts a Python dict of QChar:QStringList { %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 (); QStringList bcpp = it.data (); PyObject *binst; PyObject *ainst; if (((ainst = sipBuildResult (NULL, "N", new QChar (acpp), sipClass_QChar)) == NULL) || (binst = sipBuildResult (NULL, "N", new QStringList (bcpp), sipClass_QStringList)) || (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; int pos = 0; QChar *cKey; QStringList *slData; while (PyDict_Next(sipPy, &pos, &key, &value)) { int iserr = 0; cKey = (QChar *)sipForceConvertTo_QChar (key, &iserr); slData = (QStringList *)sipForceConvertTo_QStringList (value, &iserr); if (iserr) { *sipIsErr = 1; delete map; return 0; } map->insert (*cKey, *slData); } *sipCppPtr = map; return 1; %End };