2
/***************************************************************************
3
copyright : (C) 2006 by David Nolden
4
email : david.nolden.kdevelop@art-master.de
5
***************************************************************************/
7
/***************************************************************************
9
* This program is free software; you can redistribute it and/or modify *
10
* it under the terms of the GNU General Public License as published by *
11
* the Free Software Foundation; either version 2 of the License, or *
12
* (at your option) any later version. *
14
***************************************************************************/
2
Copyright 2007 David Nolden <david.nolden.kdevelop@art-master.de>
4
This library is free software; you can redistribute it and/or
5
modify it under the terms of the GNU Library General Public
6
License version 2 as published by the Free Software Foundation.
8
This library is distributed in the hope that it will be useful,
9
but WITHOUT ANY WARRANTY; without even the implied warranty of
10
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11
Library General Public License for more details.
13
You should have received a copy of the GNU Library General Public License
14
along with this library; see the file COPYING.LIB. If not, write to
15
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
16
Boston, MA 02110-1301, USA.
16
19
#ifndef __STRINGHELPERS_H__
17
20
#define __STRINGHELPERS_H__
20
#include "completiondebug.h"
21
#include "codeinformationrepository.h"
24
namespace StringHelpers {
26
void clearStr( QString& str, int start, int end );
28
///Fills all comments with whitespaces
29
QString clearComments( QString str );
31
QString cutTemplateParams( QString str );
33
QPair<QString, QString> splitTemplateParams( QString str );
35
bool parenFits( QChar c1, QChar c2 );
37
bool isParen( QChar c1 );
39
bool isTypeParen( QChar c1 );
41
bool isTypeOpenParen( QChar c1 );
43
bool isTypeCloseParen( QChar c1 );
45
bool isLeftParen( QChar c1 );
47
/*only from left to right
48
searches a fitting closing sign ( a ')' for a '(', ']' for '['
50
comments are currently not allowed */
51
int findClose( const QString& str , int pos ); //todo: make this respect strings
53
QString tagType( const Tag& tag );
55
int findCommaOrEnd( const QString& str , int pos, QChar validEnd = ' ' );
57
int countExtract( QChar c, const QString& str );
59
QString templateParamFromString( int num, QString str );
61
QStringList splitType( QString str ) ;
65
ParamIterator( QString parens, QString source ) : m_source( source ), m_parens( parens ), m_cur( 0 ), m_curEnd ( 0 ) {
66
int begin = m_source.find( m_parens[ 0 ] );
67
int end = m_source.findRev( m_parens[ 1 ] );
68
m_prefix = m_source.left( begin );
70
if ( begin == -1 || end == -1 && end - begin > 1 )
71
m_cur = m_source.length();
73
m_source = source.mid( begin + 1, end - begin );
78
ParamIterator& operator ++() {
80
if ( m_cur < ( int ) m_source.length() ) {
86
QString operator *() {
87
return m_source.mid( m_cur, m_curEnd - m_cur ).stripWhiteSpace();
90
operator bool() const {
91
return m_cur < ( int ) m_source.length();
94
QString prefix() const {
106
return findCommaOrEnd( m_source, m_cur, m_parens[ 1 ] );
111
bool isValidIdentifierSign( const QChar& c );
113
QString stringMult( int count, QString str );
22
#include <language/duchain/stringhelpers.h>
31
* Copied from kdevelop-3.4, should be redone
32
* @param index should be the index BEHIND the expression
34
int expressionAt( const QString& contents, int index );
118
// kate: tab-width 2;