KDevelop API Documentation

codemodel_utils.h

Go to the documentation of this file.
00001 /* This file is part of KDevelop
00002     Copyright (C) 2003 Roberto Raggi <roberto@kdevelop.org>
00003     Copyright (C) 2003-2004 Alexander Dymo <cloudtemple@mksat.net>
00004 
00005     This library is free software; you can redistribute it and/or
00006     modify it under the terms of the GNU Library General Public
00007     License as published by the Free Software Foundation; either
00008     version 2 of the License, or (at your option) any later version.
00009 
00010     This library is distributed in the hope that it will be useful,
00011     but WITHOUT ANY WARRANTY; without even the implied warranty of
00012     MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013     Library General Public License for more details.
00014 
00015     You should have received a copy of the GNU Library General Public License
00016     along with this library; see the file COPYING.LIB.  If not, write to
00017     the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00018     Boston, MA 02111-1307, USA.
00019 */
00020 
00021 #ifndef _CODEMODEL_UTILS_H_
00022 #define _CODEMODEL_UTILS_H_
00023 
00024 #include "codemodel.h"
00025 
00026 namespace CodeModelUtils
00027 {
00028 
00029 template <class Pred> void findFunctionDefinitions( Pred pred, const FileList& fileList, FunctionDefinitionList & lst );
00030 template <class Pred> void findFunctionDefinitions( Pred pred, const NamespaceDom& ns, FunctionDefinitionList & lst );
00031 template <class Pred> void findFunctionDefinitions( Pred pred, const NamespaceList& namespaceList, FunctionDefinitionList & lst );
00032 template <class Pred> void findFunctionDefinitions( Pred pred, const ClassList& classList, FunctionDefinitionList & lst );
00033 template <class Pred> void findFunctionDefinitions( Pred pred, const FunctionDefinitionList& functionDefinitionList, FunctionDefinitionList & lst );
00034 template <class Pred> void findFunctionDefinitions( Pred pred, const ClassDom& klass, FunctionDefinitionList & lst );
00035 template <class Pred> void findFunctionDefinitions( Pred pred, const FunctionDefinitionDom& fun, FunctionDefinitionList & lst );
00036 template <class Pred> void findFunctionDefinitions( Pred pred, FunctionDefinitionList & lst );
00037 
00038 
00039 template <class Pred>
00040 void findFunctionDefinitions( Pred pred, const FileList& fileList, FunctionDefinitionList & lst )
00041 {
00042     for( FileList::ConstIterator it=fileList.begin(); it!=fileList.end(); ++it )
00043     findFunctionDefinitions( pred, model_cast<NamespaceDom>(*it), lst );
00044 }
00045 
00046 template <class Pred>
00047 void findFunctionDefinitions( Pred pred, const NamespaceDom& ns, FunctionDefinitionList & lst )
00048 {
00049     findFunctionDefinitions( pred, ns->namespaceList(), lst );
00050     findFunctionDefinitions( pred, ns->classList(), lst );
00051     findFunctionDefinitions( pred, ns->functionDefinitionList(), lst );
00052 }
00053 
00054 template <class Pred>
00055 void findFunctionDefinitions( Pred pred, const NamespaceList& namespaceList, FunctionDefinitionList & lst )
00056 {
00057     for( NamespaceList::ConstIterator it=namespaceList.begin(); it!=namespaceList.end(); ++it )
00058     findFunctionDefinitions( pred, *it, lst );
00059 }
00060 
00061 template <class Pred>
00062 void findFunctionDefinitions( Pred pred, const ClassList& classList, FunctionDefinitionList & lst )
00063 {
00064     for( ClassList::ConstIterator it=classList.begin(); it!=classList.end(); ++it )
00065     findFunctionDefinitions( pred, *it, lst );
00066 }
00067 
00068 template <class Pred>
00069 void findFunctionDefinitions( Pred pred, const FunctionDefinitionList& functionDefinitionList, FunctionDefinitionList & lst )
00070 {
00071     for( FunctionDefinitionList::ConstIterator it=functionDefinitionList.begin(); it!=functionDefinitionList.end(); ++it )
00072     findFunctionDefinitions( pred, *it, lst );
00073 }
00074 
00075 template <class Pred>
00076 void findFunctionDefinitions( Pred pred, const ClassDom& klass, FunctionDefinitionList & lst )
00077 {
00078     findFunctionDefinitions( pred, klass->classList(), lst );
00079     findFunctionDefinitions( pred, klass->functionDefinitionList(), lst );
00080 }
00081 
00082 template <class Pred>
00083 void findFunctionDefinitions( Pred pred, const FunctionDefinitionDom& fun, FunctionDefinitionList & lst )
00084 {
00085     if( pred(fun) )
00086     lst << fun;
00087 }
00088 ;
00089 
00090 #if 0
00091 template <class Pred>
00092 void findFunctionDefinitions( Pred pred, FunctionDefinitionList & lst )
00093 {
00094     FileList fileList = m_store->fileList();
00095     for( FileList::Iterator it=fileList.begin(); it!=fileList.end(); ++it )
00096     findFunctionDefinitions( pred, model_cast<NamespaceDom>(*it), lst );
00097 }
00098 #endif
00099 
00100 template <class Pred> void findFunctionDeclarations( Pred pred, const FileList& fileList, FunctionList & lst );
00101 template <class Pred> void findFunctionDeclarations( Pred pred, const NamespaceDom& ns, FunctionList & lst );
00102 template <class Pred> void findFunctionDeclarations( Pred pred, const NamespaceList& namespaceList, FunctionList & lst );
00103 template <class Pred> void findFunctionDeclarations( Pred pred, const ClassList& classList, FunctionList & lst );
00104 template <class Pred> void findFunctionDeclarations( Pred pred, const FunctionList& functionDefinitionList, FunctionList & lst );
00105 template <class Pred> void findFunctionDeclarations( Pred pred, const ClassDom& klass, FunctionList & lst );
00106 template <class Pred> void findFunctionDeclarations( Pred pred, const FunctionDefinitionDom& fun, FunctionList & lst );
00107 template <class Pred> void findFunctionDeclarations( Pred pred, FunctionList & lst );
00108 
00109 
00110 template <class Pred>
00111 void findFunctionDeclarations( Pred pred, const FileList& fileList, FunctionList & lst )
00112 {
00113     for( FileList::ConstIterator it=fileList.begin(); it!=fileList.end(); ++it )
00114     findFunctionDeclarations( pred, model_cast<NamespaceDom>(*it), lst );
00115 }
00116 
00117 template <class Pred>
00118 void findFunctionDeclarations( Pred pred, const NamespaceDom& ns, FunctionList & lst )
00119 {
00120     findFunctionDeclarations( pred, ns->namespaceList(), lst );
00121     findFunctionDeclarations( pred, ns->classList(), lst );
00122     findFunctionDeclarations( pred, ns->functionList(), lst );
00123 }
00124 
00125 template <class Pred>
00126 void findFunctionDeclarations( Pred pred, const NamespaceList& namespaceList, FunctionList & lst )
00127 {
00128     for( NamespaceList::ConstIterator it=namespaceList.begin(); it!=namespaceList.end(); ++it )
00129     findFunctionDeclarations( pred, *it, lst );
00130 }
00131 
00132 template <class Pred>
00133 void findFunctionDeclarations( Pred pred, const ClassList& classList, FunctionList & lst )
00134 {
00135     for( ClassList::ConstIterator it=classList.begin(); it!=classList.end(); ++it )
00136     findFunctionDeclarations( pred, *it, lst );
00137 }
00138 
00139 template <class Pred>
00140 void findFunctionDeclarations( Pred pred, const FunctionList& functionList, FunctionList & lst )
00141 {
00142     for( FunctionList::ConstIterator it=functionList.begin(); it!=functionList.end(); ++it )
00143     findFunctionDeclarations( pred, *it, lst );
00144 }
00145 
00146 template <class Pred>
00147 void findFunctionDeclarations( Pred pred, const ClassDom& klass, FunctionList & lst )
00148 {
00149     findFunctionDeclarations( pred, klass->classList(), lst );
00150     findFunctionDeclarations( pred, klass->functionList(), lst );
00151 }
00152 
00153 template <class Pred>
00154 void findFunctionDeclarations( Pred pred, const FunctionDom& fun, FunctionList & lst )
00155 {
00156     if( pred(fun) )
00157     lst << fun;
00158 }
00159 
00160 
00161 struct Scope{
00162     ClassDom klass;
00163     NamespaceDom ns;
00164 };
00165 
00166 struct AllFunctions{
00167     QMap<FunctionDom, Scope> relations;
00168     FunctionList functionList;
00169 };
00170 struct AllFunctionDefinitions{
00171     QMap<FunctionDefinitionDom, Scope> relations;
00172     FunctionDefinitionList functionList;
00173 };
00174 
00175 namespace Functions{
00176 void processClasses(FunctionList &list, const ClassDom dom);
00177 void processNamespaces(FunctionList &list, const NamespaceDom dom);
00178 void processClasses(FunctionList &list, const ClassDom dom, QMap<FunctionDom, Scope> &relations);
00179 void processClasses(FunctionList &list, const ClassDom dom, QMap<FunctionDom, Scope> &relations, const NamespaceDom &nsdom);
00180 void processNamespaces(FunctionList &list, const NamespaceDom dom, QMap<FunctionDom, Scope> &relations);
00181 }
00182 namespace FunctionDefinitions{
00183 void processClasses(FunctionDefinitionList &list, const ClassDom dom);
00184 void processNamespaces(FunctionDefinitionList &list, const NamespaceDom dom);
00185 void processClasses(FunctionDefinitionList &list, const ClassDom dom, QMap<FunctionDefinitionDom, Scope> &relations);
00186 void processClasses(FunctionDefinitionList &list, const ClassDom dom, QMap<FunctionDefinitionDom, Scope> &relations, const NamespaceDom &nsdom);
00187 void processNamespaces(FunctionDefinitionList &list, const NamespaceDom dom, QMap<FunctionDefinitionDom, Scope> &relations);
00188 }
00189 
00197 bool compareDeclarationToDefinition(const FunctionDom& dec, const FunctionDefinitionDom& def);
00198 
00203 class PredDefinitionMatchesDeclaration{
00204 public:
00205     PredDefinitionMatchesDeclaration(const FunctionDom& func) : m_declaration(func){};
00206     bool operator() (const FunctionDefinitionDom& def) const
00207     {
00208         return compareDeclarationToDefinition(m_declaration, def);
00209     }
00210     
00211 private:
00212     const FunctionDom m_declaration;
00213 };
00214 
00215 FunctionList allFunctions(const FileDom &dom);
00216 AllFunctions allFunctionsDetailed(const FileDom &dom);
00217 AllFunctionDefinitions allFunctionDefinitionsDetailed(const FileDom &dom);
00218 }
00219 
00220 #endif // __CODEMODEL_UTILS_H
KDE Logo
This file is part of the documentation for KDevelop Version 3.1.2.
Documentation copyright © 1996-2004 the KDE developers.
Generated on Wed Mar 23 00:03:52 2005 by doxygen 1.3.9.1 written by Dimitri van Heesch, © 1997-2003