1
/* This file is part of KDevelop
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.
18
#ifndef VIABLEFUNCTIONS_H
19
#define VIABLEFUNCTIONS_H
22
#include "overloadresolution.h"
23
#include "cppduchainexport.h"
24
#include <language/duchain/duchainpointer.h>
29
class AbstractFunctionDeclaration;
32
///The here defined class is about finding best viable functions as defined in iso c++ draft 13.3.3
36
class TemplateDeclaration;
38
using namespace KDevelop;
40
class KDEVCPPDUCHAIN_EXPORT ViableFunction {
43
explicit ViableFunction( TopDUContext* topContext = 0, Declaration* decl = 0, bool noUserDefinedConversion = false );
46
* Is it a valid function?
51
* @param partial If this is true, the function is treated as if it had max. as many parameters as are given, so a match with only a part of the parameters is possible.
53
void matchParameters( const OverloadResolver::ParameterList& params, bool partial = false );
55
bool isBetter( const ViableFunction& other ) const;
57
//Same as isBetter(..)
58
bool operator< ( const ViableFunction& other ) const;
60
uint worstConversion() const;
63
* Is the function viable for the parameters given by matchParameters(...), as defined in iso c++ 13.3.2?
65
bool isViable() const;
67
KDevelop::DeclarationPointer declaration() const;
69
struct ParameterConversion {
70
ParameterConversion(int _rank=0, int _baseConversionLevels=0) : rank(_rank), baseConversionLevels(_baseConversionLevels) {
73
inline bool operator<(const ParameterConversion& rhs) const;
75
///The maximum value of rank is TypeConversion::MaximumConversionResult @see TypeConversion::ConversionRank
77
int baseConversionLevels; ///@see TypeConversion::baseConversionLevels
80
///Returns a list of structures that describe the conversion needed for each parameter of the function
81
const KDevVarLengthArray<ParameterConversion>& parameterConversions() const;
84
KDevVarLengthArray<ParameterConversion> m_parameterConversions;
85
KDevelop::DeclarationPointer m_declaration;
86
KDevelop::TopDUContextPointer m_topContext;
87
TypePtr<KDevelop::FunctionType> m_type;
88
KDevelop::AbstractFunctionDeclaration* m_funDecl;
89
bool m_parameterCountMismatch, m_noUserDefinedConversion;