File: cpputils.h

package info (click to toggle)
kdevelop 4%3A4.7.0-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 18,360 kB
  • ctags: 11,484
  • sloc: cpp: 105,371; python: 522; ansic: 488; lex: 422; sh: 139; ruby: 120; makefile: 51; xml: 42; php: 12
file content (85 lines) | stat: -rw-r--r-- 4,010 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
/*
   Copyright 2007-2008 David Nolden <david.nolden.kdevelop@art-master.de>

   This library is free software; you can redistribute it and/or
   modify it under the terms of the GNU Library General Public
   License version 2 as published by the Free Software Foundation.

   This library 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
   Library General Public License for more details.

   You should have received a copy of the GNU Library General Public License
   along with this library; see the file COPYING.LIB.  If not, write to
   the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
   Boston, MA 02110-1301, USA.
*/

#ifndef CPPUTILS_H
#define CPPUTILS_H

#include "environmentmanager.h"
#include <util/path.h>

namespace KDevelop
{
class IncludeItem;
class Declaration;
class ParsingEnvironment;
}

class KUrl;

namespace CppUtils
{
  
///Returns -1 if there is no #include in this line, else the first position behind the "#include" string, which may also look like " # include" or similar
int findEndOfInclude(QString line);

///If @param fast is true, no exhaustive search is done as fallback.
QString sourceOrHeaderCandidate( const QString &path, bool fast = false );

///Returns true if the given url is a header, looking at he known file extensions
bool isHeader(const KUrl &url);

const Cpp::ReferenceCountedMacroSet& standardMacros();

/// Get the full path for a file based on a search through the project's
/// include directories
/// @param localPath the path from which this findInclude is issued
/// @param skipPath this path will be skipped while searching, as needed for gcc extension #include_next
/// @return first: The found file(not a canonical path, starts with the directory it was found in)
///         second: The include-path the file was found in(can be used to skip that path on #include_next)
QPair<KDevelop::Path, KDevelop::Path> findInclude(const KDevelop::Path::List& includePaths, const KDevelop::Path& localPath,
                                                  const QString& includeName, int includeType, const KDevelop::Path& skipPath,
                                                  bool quiet=false);
    
///Thread-safe
bool needsUpdate(const Cpp::EnvironmentFilePointer& file, const KDevelop::Path& localPath, const KDevelop::Path::List& includePaths );

///Returns the include-path. Each dir has a trailing slash. Search should be iterated forward through the list
// NOTE: _no_ lock must be held when calling this, otherwise you might deadlock since this is a very ugly hacky function
// which must call stuff from the foreground thread...
KDevelop::Path::List findIncludePaths(const QString& source);

/**
  * Returns a list of all files within the include-path of the given file
  * @param addPath This path is added behind each include-path, and the content of the resulting directory used.
  * @param addIncludePaths A list of include-paths that should be used for listing, additionally to the known ones
  * @param onlyAddedIncludePaths If this is true, only the include-paths given in @p addIncludePaths will be used
  * @param prependAddedPathToName If this is true, @p addPath is prepended to each of the returned items paths
  * */
QList<KDevelop::IncludeItem> allFilesInIncludePath(const QString& source, bool local, const QString& addPath,
                                                   const QStringList& addIncludePaths = QStringList(), bool onlyAddedIncludePaths = false,
                                                   bool prependAddedPathToName = false, bool allowSourceFiles = false );

/// @return List of possible header extensions used for definition/declaration fallback switching
QStringList headerExtensions();
/// @return List of possible source extensions used for definition/declaration fallback switching
QStringList sourceExtensions();

}


#endif	//CPPUTILS_H