File: function.h

package info (click to toggle)
kdsoap 2.2.0%2Bdfsg-4
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,996 kB
  • sloc: cpp: 19,877; python: 63; makefile: 16
file content (251 lines) | stat: -rw-r--r-- 6,065 bytes parent folder | download | duplicates (3)
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
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
/*
    This file is part of kdepim.

    Copyright (c) 2004 Cornelius Schumacher <schumacher@kde.org>
    Copyright (c) 2009 David Faure <dfaure@kdab.com>

    This library is free software; you can redistribute it and/or
    modify it under the terms of the GNU Library General Public
    License as published by the Free Software Foundation; either
    version 2 of the License, or (at your option) any later version.

    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 KODE_FUNCTION_H
#define KODE_FUNCTION_H

#include <QtCore/QStringList>

#include "code.h"

#include <kode_export.h>

namespace KODE {

/**
 * This class represents a function.
 */
class KODE_EXPORT Function
{
public:
    class Argument
    {
    public:
        typedef QList<Argument> List;

        Argument(const QString &declaration, const QString &defaultArgument = QString());
        Argument(const Argument &other);
        ~Argument();

        Argument &operator=(const Argument &other);
        QString headerDeclaration() const;
        QString bodyDeclaration() const;

    private:
        class ArgumentPrivate;
        ArgumentPrivate *d;
    };

    typedef QList<Function> List;

    /**
     * The different access specifiers.
     *
     * @li Public     - Public access
     * @li Protected  - Protected access
     * @li Private    - Private access
     * @li Signal     - Qt Signal
     * @li Slot       - Qt Slot
     */
    enum AccessSpecifier { Public = 1, Protected = 2, Private = 4, Signal = 8, Slot = 16 };

    /**
     * Creates a new function.
     */
    Function();

    /**
     * Creates a new function from @param other.
     */
    Function(const Function &other);

    /**
     * Creates a new function with the given @param name.
     *
     * @param returnType The return type.
     * @param access The access type (@see AccessSpecifier).
     * @param isStatic If true, the function is marked as static.
     */
    Function(const QString &name, const QString &returnType = QString(), int access = Public,
             bool isStatic = false);

    /**
     * Destroys the function.
     */
    ~Function();

    /**
     * Assignment operator.
     */
    Function &operator=(const Function &other);

    /**
     * Sets the @param name of the function.
     */
    void setName(const QString &name);

    /**
     * Returns the name of the function.
     */
    QString name() const;

    /**
     * Sets the return type of the function.
     */
    void setReturnType(const QString &returnType);

    /**
     * Returns the return type of the function.
     */
    QString returnType() const;

    /**
     * Sets whether the function is marked as const.
     */
    void setConst(bool isConst);

    /**
     * Returns whether the function is marked as const.
     */
    bool isConst() const;

    /**
     * Sets whether the function is marked as static.
     */
    void setStatic(bool isStatic);

    /**
     * Returns whether the function is marked as static.
     */
    bool isStatic() const;

    enum VirtualMode { NotVirtual, Virtual, PureVirtual, Override, Final };
    /**
     * Sets whether the function is marked as virtual or pure virtual.
     */
    void setVirtualMode(VirtualMode v);

    /**
     * Returns whether the function is marked as virtual or pure virtual.
     */
    VirtualMode virtualMode() const;

    /**
     * Adds an @param argument to the function.
     */
    void addArgument(const Function::Argument &argument);

    /**
     * Adds an @param argument to the function.
     */
    void addArgument(const QString &argument);

    /**
     * Sets the complete argument string of the function.
     * This method does not support default values currently.
     */
    void setArgumentString(const QString &argumentString);

    /**
     * Returns the list of all arguments.
     * @param forImplementation if true, default values are omitted
     */
    Argument::List arguments() const;

    /**
     * @return whether the function has any arguments
     */
    bool hasArguments() const;

    /**
     * Adds an initializer to the function.
     */
    void addInitializer(const QString &initializer);

    /**
     * Returns the list of all initializers.
     */
    QStringList initializers() const;

    /**
     * Sets the @param body code of the function.
     */
    void setBody(const QString &body);

    /**
     * Sets the @param body code of the function.
     */
    void setBody(const Code &body);

    /**
     * Adds a @param line to the body code of the function.
     */
    void addBodyLine(const QString &line);

    /**
     * Returns the body code of the function.
     */
    QString body() const;

    /**
     * Sets the access @param specifier of the function.
     */
    void setAccess(int specifier);

    /**
     * Returns the access specifier of the function.
     */
    int access() const;

    /**
     * Returns access specifier of the function as string.
     */
    QString accessAsString() const;

    /**
     * Sets the @param documentation of the function.
     */
    void setDocs(const QString &documentation);

    /**
     * Returns the documentation of the function.
     */
    QString docs() const;

    /**
     * Sets whether the function is marked with explicit specifier.
     */
    void setExplicit(bool isExplicit = true);

    /**
     * Returns whether the function is marked with explicit specifier.
     */
    bool isExplicit() const;

private:
    class FunctionPrivate;
    FunctionPrivate *d;
};
}

QDebug operator<<(QDebug dbg, const KODE::Function &func);

#endif