Macro.h 4.47 KB
Newer Older
1
/**************************************************************************
con's avatar
con committed
2 3 4
**
** This file is part of Qt Creator
**
con's avatar
con committed
5
** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
con's avatar
con committed
6
**
hjk's avatar
hjk committed
7
** Contact: Nokia Corporation (info@qt.nokia.com)
con's avatar
con committed
8
**
9
**
10
** GNU Lesser General Public License Usage
11
**
hjk's avatar
hjk committed
12 13 14 15 16 17
** 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.
18
**
con's avatar
con committed
19
** In addition, as a special exception, Nokia gives you certain additional
hjk's avatar
hjk committed
20
** rights. These rights are described in the Nokia Qt LGPL Exception
con's avatar
con committed
21 22
** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
**
hjk's avatar
hjk committed
23 24 25 26 27
** Other Usage
**
** Alternatively, this file may be used in accordance with the terms and
** conditions contained in a signed written agreement between you and Nokia.
**
con's avatar
con committed
28
** If you have questions regarding the use of this file, please contact
Tobias Hunger's avatar
Tobias Hunger committed
29
** Nokia at info@qt.nokia.com.
con's avatar
con committed
30
**
31
**************************************************************************/
con's avatar
con committed
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
/*
  Copyright 2005 Roberto Raggi <roberto@kdevelop.org>

  Permission to use, copy, modify, distribute, and sell this software and its
  documentation for any purpose is hereby granted without fee, provided that
  the above copyright notice appear in all copies and that both that
  copyright notice and this permission notice appear in supporting
  documentation.

  The above copyright notice and this permission notice shall be included in
  all copies or substantial portions of the Software.

  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
  KDEVELOP TEAM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

Roberto Raggi's avatar
Roberto Raggi committed
52 53
#ifndef CPLUSPLUS_PP_MACRO_H
#define CPLUSPLUS_PP_MACRO_H
con's avatar
con committed
54

Roberto Raggi's avatar
Roberto Raggi committed
55 56
#include <CPlusPlusForwardDeclarations.h>

Friedemann Kleint's avatar
Friedemann Kleint committed
57 58 59
#include <QtCore/QByteArray>
#include <QtCore/QVector>
#include <QtCore/QString>
con's avatar
con committed
60

61
namespace CPlusPlus {
con's avatar
con committed
62

Roberto Raggi's avatar
Roberto Raggi committed
63 64 65
class CPLUSPLUS_EXPORT Macro
{
public:
66
    Macro();
Roberto Raggi's avatar
Roberto Raggi committed
67

68 69
    QByteArray name() const
    { return _name; }
con's avatar
con committed
70

71 72
    void setName(const QByteArray &name)
    { _name = name; }
con's avatar
con committed
73

74 75 76 77 78 79 80 81 82 83 84 85
    QByteArray definition() const
    { return _definition; }

    void setDefinition(const QByteArray &definition)
    { _definition = definition; }

    QVector<QByteArray> formals() const
    { return _formals; }

    void addFormal(const QByteArray &formal)
    { _formals.append(formal); }

86
    QString fileName() const
87 88
    { return _fileName; }

89
    void setFileName(const QString &fileName)
90 91 92 93 94 95 96 97
    { _fileName = fileName; }

    unsigned line() const
    { return _line; }

    void setLine(unsigned line)
    { _line = line; }

98 99 100 101 102 103 104 105 106 107 108 109
    unsigned offset() const
    { return _offset; }

    void setOffset(unsigned offset)
    { _offset = offset; }

    unsigned length() const
    { return _length; }

    void setLength(unsigned length)
    { _length = length; }

110
    bool isHidden() const
111
    { return f._hidden; }
112 113

    void setHidden(bool isHidden)
114
    { f._hidden = isHidden; }
115 116

    bool isFunctionLike() const
117
    { return f._functionLike; }
118 119

    void setFunctionLike(bool isFunctionLike)
120
    { f._functionLike = isFunctionLike; }
121 122

    bool isVariadic() const
123
    { return f._variadic; }
124 125

    void setVariadic(bool isVariadic)
126
    { f._variadic = isVariadic; }
Roberto Raggi's avatar
Roberto Raggi committed
127

128 129 130 131 132 133
    void setLineBreaks(const QList<unsigned> &breaks)
    { _lineBreaks = breaks; }

    const QList<unsigned> &lineBreaks() const
    { return _lineBreaks; }

134
    QString toString() const;
135
    QString toStringWithLineBreaks() const;
136 137 138 139 140 141

// ### private
    Macro *_next;
    unsigned _hashcode;

private:
142 143
    QString decoratedName() const;

144 145 146 147 148 149 150
    struct Flags
    {
        unsigned _hidden: 1;
        unsigned _functionLike: 1;
        unsigned _variadic: 1;
    };

151 152 153
    QByteArray _name;
    QByteArray _definition;
    QVector<QByteArray> _formals;
154
    QString _fileName;
155
    QList<unsigned> _lineBreaks;
156
    unsigned _line;
157 158
    unsigned _offset;
    unsigned _length;
159 160 161 162

    union
    {
        unsigned _state;
163
        Flags f;
164
    };
Roberto Raggi's avatar
Roberto Raggi committed
165
};
con's avatar
con committed
166

167
} // namespace CPlusPlus
con's avatar
con committed
168

Roberto Raggi's avatar
Roberto Raggi committed
169
#endif // CPLUSPLUS_PP_MACRO_H