Overview.h 4.31 KB
Newer Older
hjk's avatar
hjk committed
1
/****************************************************************************
con's avatar
con committed
2
**
3
** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).
hjk's avatar
hjk committed
4
** Contact: http://www.qt-project.org/legal
con's avatar
con committed
5
**
hjk's avatar
hjk committed
6
** This file is part of Qt Creator.
con's avatar
con committed
7
**
hjk's avatar
hjk committed
8
9
10
11
12
13
14
** Commercial License Usage
** Licensees holding valid commercial Qt licenses may use this file in
** accordance with the commercial license agreement provided with the
** Software or, alternatively, in accordance with the terms contained in
** a written agreement between you and Digia.  For licensing terms and
** conditions see http://qt.digia.com/licensing.  For further information
** use the contact form at http://qt.digia.com/contact-us.
15
**
16
** GNU Lesser General Public License Usage
hjk's avatar
hjk committed
17
18
19
20
21
22
23
24
25
** Alternatively, this file may be used under the terms of the GNU Lesser
** General Public License version 2.1 as published by the Free Software
** Foundation and appearing in the file LICENSE.LGPL included in the
** packaging of this file.  Please review the following information to
** ensure the GNU Lesser General Public License version 2.1 requirements
** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
**
** In addition, as a special exception, Digia gives you certain additional
** rights.  These rights are described in the Digia Qt LGPL Exception
con's avatar
con committed
26
27
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
28
****************************************************************************/
hjk's avatar
hjk committed
29

Roberto Raggi's avatar
Roberto Raggi committed
30
31
#ifndef CPLUSPLUS_OVERVIEW_H
#define CPLUSPLUS_OVERVIEW_H
con's avatar
con committed
32

33
#include <cplusplus/CPlusPlusForwardDeclarations.h>
Friedemann Kleint's avatar
Friedemann Kleint committed
34

35
36
#include <QList>
#include <QString>
con's avatar
con committed
37
38
39

namespace CPlusPlus {

40
41
42
43
44
45
46
47
48
49
/*!
   \class Overview

   \brief Converts a FullySpecifiedType and/or any qualified name,
          to its string representation.

   The public data members (except the ones starting with "marked")
   determine what exactly and how to print.
 */

con's avatar
con committed
50
51
52
53
54
class CPLUSPLUS_EXPORT Overview
{
public:
    Overview();

Roberto Raggi's avatar
Roberto Raggi committed
55
    QString operator()(const Name *name) const
con's avatar
con committed
56
57
    { return prettyName(name); }

58
59
60
    QString operator()(const QList<const Name *> &fullyQualifiedName) const
    { return prettyName(fullyQualifiedName); }

Roberto Raggi's avatar
Roberto Raggi committed
61
    QString operator()(const FullySpecifiedType &type, const Name *name = 0) const
con's avatar
con committed
62
63
    { return prettyType(type, name); }

Roberto Raggi's avatar
Roberto Raggi committed
64
    QString prettyName(const Name *name) const;
65
    QString prettyName(const QList<const Name *> &fullyQualifiedName) const;
Roberto Raggi's avatar
Roberto Raggi committed
66
    QString prettyType(const FullySpecifiedType &type, const Name *name = 0) const;
con's avatar
con committed
67
68
    QString prettyType(const FullySpecifiedType &type, const QString &name) const;

69
public:
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
    /*!
        \enum Overview::StarBindFlag

        The StarBindFlags describe how the '*' and '&' in pointers/references
        should be bound in the string representation.

        This also applies to rvalue references ('&&'), but not to
        pointers to functions or arrays like in

          void (*p)()
          void (*p)[]

        since it seems to be quite uncommon to use spaces there.

        See the examples below. These assume that exactly one
        flag is set. That is, it may look different with
        flag combinations.

          \value BindToIdentifier
                 e.g. "char *foo", but not "char * foo"
          \value BindToTypeName
                 e.g. "char*", but not "char *"
          \value BindToLeftSpecifier
                 e.g. "char * const* const", but not "char * const * const"
          \value BindToRightSpecifier
                 e.g. "char *const", but not "char * const"
     */
    enum StarBindFlag {
        BindToIdentifier = 0x1,
        BindToTypeName = 0x2,
        BindToLeftSpecifier = 0x4,
        BindToRightSpecifier = 0x8
    };
    Q_DECLARE_FLAGS(StarBindFlags, StarBindFlag)

    StarBindFlags starBindFlags;
106
107
108
109
110
    bool showArgumentNames: 1;
    bool showReturnTypes: 1;
    bool showFunctionSignatures: 1;
    bool showDefaultArguments: 1;
    bool showTemplateParameters: 1;
111
    bool includeWhiteSpaceInOperatorName: 1; /// "operator =()" vs "operator=()"
112
113
114
115
116
117
118
119
120
121

    /*!
        You can get the start and end position of a function argument
        in the resulting string. Set "markedArgument" to the desired
        argument. After processing, "markedArgumentBegin" and
        "markedArgumentEnd" will contain the positions.
     */
    unsigned markedArgument;
    int markedArgumentBegin;
    int markedArgumentEnd;
con's avatar
con committed
122
123
};

124
} // namespace CPlusPlus
con's avatar
con committed
125

Roberto Raggi's avatar
Roberto Raggi committed
126
#endif // CPLUSPLUS_OVERVIEW_H