OSDN Git Service

Update license.
[qt-creator-jp/qt-creator-jp.git] / src / libs / cplusplus / Macro.h
1 /**************************************************************************
2 **
3 ** This file is part of Qt Creator
4 **
5 ** Copyright (c) 2011 Nokia Corporation and/or its subsidiary(-ies).
6 **
7 ** Contact: Nokia Corporation (info@qt.nokia.com)
8 **
9 **
10 ** GNU Lesser General Public License Usage
11 **
12 ** This file may be used under the terms of the GNU Lesser General Public
13 ** License version 2.1 as published by the Free Software Foundation and
14 ** appearing in the file LICENSE.LGPL included in the packaging of this file.
15 ** Please review the following information to ensure the GNU Lesser General
16 ** Public License version 2.1 requirements will be met:
17 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
18 **
19 ** In addition, as a special exception, Nokia gives you certain additional
20 ** rights. These rights are described in the Nokia Qt LGPL Exception
21 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
22 **
23 ** Other Usage
24 **
25 ** Alternatively, this file may be used in accordance with the terms and
26 ** conditions contained in a signed written agreement between you and Nokia.
27 **
28 ** If you have questions regarding the use of this file, please contact
29 ** Nokia at qt-info@nokia.com.
30 **
31 **************************************************************************/
32 /*
33   Copyright 2005 Roberto Raggi <roberto@kdevelop.org>
34
35   Permission to use, copy, modify, distribute, and sell this software and its
36   documentation for any purpose is hereby granted without fee, provided that
37   the above copyright notice appear in all copies and that both that
38   copyright notice and this permission notice appear in supporting
39   documentation.
40
41   The above copyright notice and this permission notice shall be included in
42   all copies or substantial portions of the Software.
43
44   THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
45   IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
46   FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL THE
47   KDEVELOP TEAM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
48   AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
49   CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
50 */
51
52 #ifndef CPLUSPLUS_PP_MACRO_H
53 #define CPLUSPLUS_PP_MACRO_H
54
55 #include <CPlusPlusForwardDeclarations.h>
56
57 #include <QtCore/QByteArray>
58 #include <QtCore/QVector>
59 #include <QtCore/QString>
60
61 namespace CPlusPlus {
62
63 class CPLUSPLUS_EXPORT Macro
64 {
65 public:
66     Macro();
67
68     QByteArray name() const
69     { return _name; }
70
71     void setName(const QByteArray &name)
72     { _name = name; }
73
74     QByteArray definition() const
75     { return _definition; }
76
77     void setDefinition(const QByteArray &definition)
78     { _definition = definition; }
79
80     QVector<QByteArray> formals() const
81     { return _formals; }
82
83     void addFormal(const QByteArray &formal)
84     { _formals.append(formal); }
85
86     QString fileName() const
87     { return _fileName; }
88
89     void setFileName(const QString &fileName)
90     { _fileName = fileName; }
91
92     unsigned line() const
93     { return _line; }
94
95     void setLine(unsigned line)
96     { _line = line; }
97
98     unsigned offset() const
99     { return _offset; }
100
101     void setOffset(unsigned offset)
102     { _offset = offset; }
103
104     unsigned length() const
105     { return _length; }
106
107     void setLength(unsigned length)
108     { _length = length; }
109
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; }
127
128     QString toString() const;
129
130 // ### private
131     Macro *_next;
132     unsigned _hashcode;
133
134 private:
135     struct Flags
136     {
137         unsigned _hidden: 1;
138         unsigned _functionLike: 1;
139         unsigned _variadic: 1;
140     };
141
142     QByteArray _name;
143     QByteArray _definition;
144     QVector<QByteArray> _formals;
145     QString _fileName;
146     unsigned _line;
147     unsigned _offset;
148     unsigned _length;
149
150     union
151     {
152         unsigned _state;
153         Flags f;
154     };
155 };
156
157 } // namespace CPlusPlus
158
159 #endif // CPLUSPLUS_PP_MACRO_H