File indexing completed on 2024-04-28 04:38:36

0001 /* 
0002     SPDX-FileCopyrightText: 2007 David Nolden <david.nolden.kdevelop@art-master.de>
0003 
0004     SPDX-License-Identifier: LGPL-2.0-only
0005 */
0006 
0007 #ifndef __STRINGHELPERS_H__
0008 #define __STRINGHELPERS_H__
0009 
0010 #include <QString>
0011 
0012 namespace Utils {
0013 
0014 /**
0015  * Copied from kdevelop-3.4, should be redone
0016  * @param index should be the index BEHIND the expression
0017  * */
0018 int expressionAt( const QString& contents, int index );
0019 
0020 QString quoteExpression(const QString& expr);
0021 
0022 QString unquoteExpression(const QString& expr);
0023 
0024 /**
0025  * Quote the string, using quoteCh
0026  */
0027 QString quote(const QString& str, QChar quoteCh = QLatin1Char('"'));
0028 
0029 /**
0030  * Unquote and optionally unescape unicode escape sequence.
0031  * Handle escape sequence
0032  *     '\\' '\\'                      -> '\\'
0033  *     '\\' quoteCh                   -> quoteCh
0034  *     '\\' 'u' 'N' 'N' 'N' 'N'       -> '\uNNNN'
0035  *     '\\' 'x''N''N'                 -> '\xNN'
0036  */
0037 QString unquote(const QString& str, bool unescapeUnicode = false, QChar quoteCh = QLatin1Char('"'));
0038 
0039 } // end of namespace Utils
0040 
0041 #endif // __STRINGHELPERS_H__