Mercurial > projects > qtd
annotate generator/parser/rpp/pp-string.h @ 382:1d56b2a2e10c
Fixes to debugging stuff. Added size_t as primitive type to workaround Qwt build failure in debug
author | Max Samukha <maxter@spambox.com> |
---|---|
date | Mon, 12 Jul 2010 20:36:07 +0300 |
parents | 09a0f1d048f2 |
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_STRING_H | |
45 #define PP_STRING_H | |
46 | |
47 namespace rpp { | |
48 | |
49 template <typename _CharT> | |
50 class pp_string | |
51 { | |
52 typedef std::char_traits<_CharT> traits_type; | |
53 typedef std::size_t size_type; | |
54 | |
55 _CharT const *_M_begin; | |
56 std::size_t _M_size; | |
57 | |
58 public: | |
59 inline pp_string (): | |
60 _M_begin (0), _M_size(0) {} | |
61 | |
62 explicit pp_string (std::string const &__s): | |
63 _M_begin (__s.c_str ()), _M_size (__s.size ()) {} | |
64 | |
65 inline pp_string (_CharT const *__begin, std::size_t __size): | |
66 _M_begin (__begin), _M_size (__size) {} | |
67 | |
68 inline _CharT const *begin () const { return _M_begin; } | |
69 inline _CharT const *end () const { return _M_begin + _M_size; } | |
70 | |
71 inline _CharT at (std::size_t index) const { return _M_begin [index]; } | |
72 | |
73 inline std::size_t size () const { return _M_size; } | |
74 | |
75 inline int compare (pp_string const &__other) const | |
76 { | |
77 size_type const __size = this->size(); | |
78 size_type const __osize = __other.size(); | |
79 size_type const __len = std::min (__size, __osize); | |
80 | |
81 int __r = traits_type::compare (_M_begin, __other._M_begin, __len); | |
82 if (!__r) | |
83 __r = (int) (__size - __osize); | |
84 | |
85 return __r; | |
86 } | |
87 | |
88 inline bool operator == (pp_string const &__other) const | |
89 { return compare (__other) == 0; } | |
90 | |
91 inline bool operator != (pp_string const &__other) const | |
92 { return compare (__other) != 0; } | |
93 | |
94 inline bool operator < (pp_string const &__other) const | |
95 { return compare (__other) < 0; } | |
96 | |
97 inline bool operator == (char const *s) const | |
98 { | |
99 std::size_t n = strlen (s); | |
100 | |
101 if (n != _M_size) | |
102 return false; | |
103 | |
104 return ! strncmp (_M_begin, s, n); | |
105 } | |
106 | |
107 inline bool operator != (char const *s) const | |
108 { return ! operator == (s); } | |
109 }; | |
110 | |
111 } // namespace rpp | |
112 | |
113 #endif // PP_STRING_H | |
114 | |
115 // kate: space-indent on; indent-width 2; replace-tabs on; |