Mercurial > projects > qtd
annotate generator/parser/rpp/pp-internal.h @ 52:09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
author | eldar |
---|---|
date | Mon, 18 May 2009 15:23:28 +0000 |
parents | e78566595089 |
children |
rev | line source |
---|---|
1 | 1 /**************************************************************************** |
2 ** | |
52
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
3 ** Copyright (C) 1992-2009 Nokia. All rights reserved. |
1 | 4 ** Copyright 2005 Roberto Raggi <roberto@kdevelop.org> |
5 ** | |
6 ** This file is part of Qt Jambi. | |
7 ** | |
52
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
8 ** Commercial Usage |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
9 Licensees holding valid Qt Commercial licenses may use this file in |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
10 accordance with the Qt Commercial License Agreement provided with the |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
11 Software or, alternatively, in accordance with the terms contained in |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
12 a written agreement between you and Nokia. |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
13 |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
14 GNU Lesser General Public License Usage |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
15 Alternatively, this file may be used under the terms of the GNU Lesser |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
16 General Public License version 2.1 as published by the Free Software |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
17 Foundation and appearing in the file LICENSE.LGPL included in the |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
18 packaging of this file. Please review the following information to |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
19 ensure the GNU Lesser General Public License version 2.1 requirements |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
20 will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
21 |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
22 In addition, as a special exception, Nokia gives you certain |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
23 additional rights. These rights are described in the Nokia Qt LGPL |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
24 Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
25 package. |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
26 |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
27 GNU General Public License Usage |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
28 Alternatively, this file may be used under the terms of the GNU |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
29 General Public License version 3.0 as published by the Free Software |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
30 Foundation and appearing in the file LICENSE.GPL included in the |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
31 packaging of this file. Please review the following information to |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
32 ensure the GNU General Public License version 3.0 requirements will be |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
33 met: http://www.gnu.org/copyleft/gpl.html. |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
34 |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
35 If you are unsure which license is appropriate for your use, please |
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
36 contact the sales department at qt-sales@nokia.com. |
1 | 37 |
38 ** | |
39 ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | |
40 ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
41 ** | |
42 ****************************************************************************/ | |
43 | |
44 #ifndef PP_INTERNAL_H | |
45 #define PP_INTERNAL_H | |
46 | |
47 #include <algorithm> | |
52
09a0f1d048f2
update parser to that from jambi 4.5, attemt to fix building with gcc 4.4
eldar
parents:
1
diff
changeset
|
48 #include <cstdio> |
1 | 49 |
50 namespace rpp { | |
51 | |
52 namespace _PP_internal | |
53 { | |
54 | |
55 inline void extract_file_path (const std::string &__filename, std::string *__filepath) | |
56 { | |
57 std::size_t __index = __filename.rfind (PATH_SEPARATOR); | |
58 | |
59 if (__index == std::string::npos) | |
60 *__filepath = "/"; | |
61 | |
62 else | |
63 __filepath->assign (__filename, 0, __index + 1); | |
64 } | |
65 | |
66 template <typename _OutputIterator> | |
67 void output_line(const std::string &__filename, int __line, _OutputIterator __result) | |
68 { | |
69 std::string __msg; | |
70 | |
71 __msg += "# "; | |
72 | |
73 char __line_descr[16]; | |
74 pp_snprintf (__line_descr, 16, "%d", __line); | |
75 __msg += __line_descr; | |
76 | |
77 __msg += " \""; | |
78 | |
79 if (__filename.empty ()) | |
80 __msg += "<internal>"; | |
81 else | |
82 __msg += __filename; | |
83 | |
84 __msg += "\"\n"; | |
85 std::copy (__msg.begin (), __msg.end (), __result); | |
86 } | |
87 | |
88 template <typename _InputIterator> | |
89 inline bool comment_p (_InputIterator __first, _InputIterator __last) /*const*/ | |
90 { | |
91 if (__first == __last) | |
92 return false; | |
93 | |
94 if (*__first != '/') | |
95 return false; | |
96 | |
97 if (++__first == __last) | |
98 return false; | |
99 | |
100 return (*__first == '/' || *__first == '*'); | |
101 } | |
102 | |
103 struct _Compare_string: public std::binary_function<bool, pp_fast_string const *, pp_fast_string const *> | |
104 { | |
105 inline bool operator () (pp_fast_string const *__lhs, pp_fast_string const *__rhs) const | |
106 { return *__lhs < *__rhs; } | |
107 }; | |
108 | |
109 struct _Equal_to_string: public std::binary_function<bool, pp_fast_string const *, pp_fast_string const *> | |
110 { | |
111 inline bool operator () (pp_fast_string const *__lhs, pp_fast_string const *__rhs) const | |
112 { return *__lhs == *__rhs; } | |
113 }; | |
114 | |
115 struct _Hash_string: public std::unary_function<std::size_t, pp_fast_string const *> | |
116 { | |
117 inline std::size_t operator () (pp_fast_string const *__s) const | |
118 { | |
119 char const *__ptr = __s->begin (); | |
120 std::size_t __size = __s->size (); | |
121 std::size_t __h = 0; | |
122 | |
123 for (std::size_t i = 0; i < __size; ++i) | |
124 __h = (__h << 5) - __h + __ptr [i]; | |
125 | |
126 return __h; | |
127 } | |
128 }; | |
129 | |
130 } // _PP_internal | |
131 | |
132 } // namespace rpp | |
133 | |
134 #endif // PP_INTERNAL_H | |
135 | |
136 // kate: space-indent on; indent-width 2; replace-tabs on; |