From kde-core-devel Thu Sep 22 17:30:17 2005 From: Sascha Cunz Date: Thu, 22 Sep 2005 17:30:17 +0000 To: kde-core-devel Subject: KMacroExpander convience methods for kdelibs4_snapshot? Message-Id: <200509221930.17966.sascha.cunz () tiscali ! de> X-MARC-Message: https://marc.info/?l=kde-core-devel&m=112741036312678 MIME-Version: 1 Content-Type: multipart/mixed; boundary="--Boundary-00=_pouMDNfXF8wQv4n" --Boundary-00=_pouMDNfXF8wQv4n Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Content-Disposition: inline Hi, in trunk, KMacroExpander was changed to use QHash instead of QMap. This change is not yet in kdelibs4_snapshot. I'm about to convert and write lots of new code for kdevelop that will use KMacroExpander, and as i expect that QMap will appear there about 75 to 100 times and i actually do not want to change that later, should I - merge the change from 439322 to 457320 in the kmacroexpander.* files to kdelibs4_snapshot - commit convience methods to kdelibs4_snapshot (i.e. like attached patch) - use a "typedef QMap KMacroExpanderMap;" in kdevelop - just accept the fact, that i'll have to take 2 hours and walk over it again and change it - stop using kdelibs4_snapshot totally - something i've not yet thought of? Cheers Sascha --Boundary-00=_pouMDNfXF8wQv4n Content-Type: text/x-diff; charset="us-ascii"; name="kme.patch" Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename="kme.patch" Index: kmacroexpander.h =================================================================== --- kmacroexpander.h (Revision 462022) +++ kmacroexpander.h (Arbeitskopie) @@ -271,6 +271,7 @@ * \endcode */ KDECORE_EXPORT QString expandMacros( const QString &str, const QMap &map, QChar c = '%' ); + KDECORE_EXPORT QString expandMacros( const QString &str, const QHash &map, QChar c = '%' ); /** * Perform safe macro expansion (substitution) on a string for use @@ -296,6 +297,7 @@ * \endcode */ KDECORE_EXPORT QString expandMacrosShellQuote( const QString &str, const QMap &map, QChar c = '%' ); + KDECORE_EXPORT QString expandMacrosShellQuote( const QString &str, const QHash &map, QChar c = '%' ); /** * Perform safe macro expansion (substitution) on a string. @@ -321,6 +323,7 @@ * \endcode */ KDECORE_EXPORT QString expandMacros( const QString &str, const QMap &map, QChar c = '%' ); + KDECORE_EXPORT QString expandMacros( const QString &str, const QHash &map, QChar c = '%' ); /** * Perform safe macro expansion (substitution) on a string for use @@ -349,13 +352,16 @@ * \endcode */ KDECORE_EXPORT QString expandMacrosShellQuote( const QString &str, const QMap &map, QChar c = '%' ); + KDECORE_EXPORT QString expandMacrosShellQuote( const QString &str, const QHash &map, QChar c = '%' ); /** * Same as above, except that the macros expand to string lists that * are simply join(" ")ed together. */ KDECORE_EXPORT QString expandMacros( const QString &str, const QMap &map, QChar c = '%' ); + KDECORE_EXPORT QString expandMacros( const QString &str, const QHash &map, QChar c = '%' ); KDECORE_EXPORT QString expandMacros( const QString &str, const QMap &map, QChar c = '%' ); + KDECORE_EXPORT QString expandMacros( const QString &str, const QHash &map, QChar c = '%' ); /* * Same as above, except that the macros expand to string lists. @@ -364,7 +370,9 @@ * quoted string. */ KDECORE_EXPORT QString expandMacrosShellQuote( const QString &str, const QMap &map, QChar c = '%' ); + KDECORE_EXPORT QString expandMacrosShellQuote( const QString &str, const QHash &map, QChar c = '%' ); KDECORE_EXPORT QString expandMacrosShellQuote( const QString &str, const QMap &map, QChar c = '%' ); + KDECORE_EXPORT QString expandMacrosShellQuote( const QString &str, const QHash &map, QChar c = '%' ); } #endif /* _KMACROEXPANDER_H */ Index: kmacroexpander.cpp =================================================================== --- kmacroexpander.cpp (Revision 462022) +++ kmacroexpander.cpp (Arbeitskopie) @@ -27,6 +27,17 @@ #include +#include + +template QMap hashToMap( const QHash& h ) +{ + QMap m; + QHash::const_iterator i = h.constBegin(); + for( ; i != h.constEnd(); ++i ) + m[i.key()] = i.value(); + return m; +} + KMacroExpanderBase::KMacroExpanderBase( QChar c ) { escapechar = c; @@ -539,4 +550,12 @@ QString expandMacros( const QString &ostr, const QMap &map, QChar c ) { return TexpandMacros( ostr, map, c ); } QString expandMacrosShellQuote( const QString &ostr, const QMap &map, QChar c ) { return TexpandMacrosShellQuote( ostr, map, c ); } + QString expandMacros( const QString &ostr, const QHash &map, QChar c ) { return TexpandMacros( ostr, hashToMap(map), c ); } + QString expandMacrosShellQuote( const QString &ostr, const QHash &map, QChar c ) { return TexpandMacrosShellQuote( ostr, hashToMap(map), c ); } + QString expandMacros( const QString &ostr, const QHash &map, QChar c ) { return TexpandMacros( ostr, hashToMap(map), c ); } + QString expandMacrosShellQuote( const QString &ostr, const QHash &map, QChar c ) { return TexpandMacrosShellQuote( ostr, hashToMap(map), c ); } + QString expandMacros( const QString &ostr, const QHash &map, QChar c ) { return TexpandMacros( ostr, hashToMap(map), c ); } + QString expandMacrosShellQuote( const QString &ostr, const QHash &map, QChar c ) { return TexpandMacrosShellQuote( ostr, hashToMap(map), c ); } + QString expandMacros( const QString &ostr, const QHash &map, QChar c ) { return TexpandMacros( ostr, hashToMap(map), c ); } + QString expandMacrosShellQuote( const QString &ostr, const QHash &map, QChar c ) { return TexpandMacrosShellQuote( ostr, hashToMap(map), c ); } } // namespace --Boundary-00=_pouMDNfXF8wQv4n--