~ubuntu-branches/debian/sid/kdevelop/sid

« back to all changes in this revision

Viewing changes to languages/cpp/cppduchain/viablefunctions.h

  • Committer: Bazaar Package Importer
  • Author(s): Jeremy Lainé
  • Date: 2010-05-05 07:21:55 UTC
  • mfrom: (1.2.3 upstream) (5.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20100505072155-h78lx19pu04sbhtn
Tags: 4:4.0.0-2
* Upload to unstable (Closes: #579947, #481832).
* Acknowledge obsolete NMU fixes (Closes: #562410, #546961).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/* This file is part of KDevelop
 
2
    Copyright 2007 David Nolden <david.nolden.kdevelop@art-master.de>
 
3
 
 
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.
 
7
 
 
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.
 
12
 
 
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.
 
17
*/
 
18
#ifndef VIABLEFUNCTIONS_H
 
19
#define VIABLEFUNCTIONS_H
 
20
 
 
21
#include <QList>
 
22
#include "overloadresolution.h"
 
23
#include "cppduchainexport.h"
 
24
#include <language/duchain/duchainpointer.h>
 
25
 
 
26
 
 
27
namespace KDevelop  {
 
28
  class Declaration;
 
29
  class AbstractFunctionDeclaration;
 
30
}
 
31
 
 
32
///The here defined class is about finding best viable functions as defined in iso c++ draft 13.3.3
 
33
 
 
34
namespace Cpp {
 
35
 
 
36
  class TemplateDeclaration;
 
37
 
 
38
  using namespace KDevelop;
 
39
 
 
40
  class KDEVCPPDUCHAIN_EXPORT ViableFunction {
 
41
    public:
 
42
 
 
43
    explicit ViableFunction( TopDUContext* topContext = 0, Declaration* decl = 0, bool noUserDefinedConversion = false );
 
44
 
 
45
    /**
 
46
     * Is it a valid function?
 
47
     * */
 
48
    bool isValid() const;
 
49
 
 
50
    /**
 
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.
 
52
     * */
 
53
    void matchParameters( const OverloadResolver::ParameterList& params, bool partial = false );
 
54
 
 
55
    bool isBetter( const ViableFunction& other ) const;
 
56
 
 
57
    //Same as isBetter(..)
 
58
    bool operator< ( const ViableFunction& other ) const;
 
59
 
 
60
    uint worstConversion() const;
 
61
 
 
62
    /**
 
63
     * Is the function viable for the parameters given by matchParameters(...), as defined in iso c++ 13.3.2?
 
64
     * */
 
65
    bool isViable() const;
 
66
 
 
67
    KDevelop::DeclarationPointer declaration() const;
 
68
 
 
69
    struct ParameterConversion {
 
70
      ParameterConversion(int _rank=0, int _baseConversionLevels=0) : rank(_rank), baseConversionLevels(_baseConversionLevels) {
 
71
      }
 
72
 
 
73
      inline bool operator<(const ParameterConversion& rhs) const;
 
74
 
 
75
      ///The maximum value of rank is TypeConversion::MaximumConversionResult @see TypeConversion::ConversionRank
 
76
      int rank;
 
77
      int baseConversionLevels; ///@see TypeConversion::baseConversionLevels
 
78
    };
 
79
 
 
80
    ///Returns a list of structures that describe the conversion needed for each parameter of the function
 
81
    const KDevVarLengthArray<ParameterConversion>& parameterConversions() const;
 
82
 
 
83
    private:
 
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;
 
90
  };
 
91
}
 
92
 
 
93
#endif