From kde-commits Thu Sep 22 19:26:33 2005 From: Sascha Cunz Date: Thu, 22 Sep 2005 19:26:33 +0000 To: kde-commits Subject: KDE/kdevelop/lib/util Message-Id: <1127417193.505404.11205.nullmailer () svn ! kde ! org> X-MARC-Message: https://marc.info/?l=kde-commits&m=112741720411730 SVN commit 463035 by cunz: Added method to create a substitution map for xml from a "normal" substitution map M +16 -0 filetemplate.cpp M +7 -1 filetemplate.h --- trunk/KDE/kdevelop/lib/util/filetemplate.cpp #463034:463035 @@ -113,3 +113,19 @@ QString globalName = ::locate("data", "kdevfilecreate/file-templates/" + name); return globalName.isNull() ? fileName : globalName; } + + +QHash FileTemplate::normalSubstMapToXML( const QHash& src ) +{ + QHash result; + QHash::Iterator it( src.begin() ); + for( ; it != src.end(); ++it ) + { + QString escaped( it.value() ); + escaped.replace( "&", "&" ); + escaped.replace( "<", "<" ); + escaped.replace( ">", ">" ); + result.insert( it.key(), escaped ); + } + return result; +} --- trunk/KDE/kdevelop/lib/util/filetemplate.h #463034:463035 @@ -20,7 +20,8 @@ #ifndef _FILETEMPLATE_H_ #define _FILETEMPLATE_H_ -#include +#include +#include class KDevPlugin; class QDomDocument; @@ -83,6 +84,11 @@ * for the template in the project directory if it doesn't exist. */ static QString fullPathForName(KDevPlugin *part, const QString &name, Policy p = Default); + + /** + * Escape a substitution map for usage on a XML file. + */ + static QHash normalSubstMapToXML( const QHash& src ); }; #endif