author | kergoth <kergoth> | 2002-11-01 00:10:42 (UTC) |
---|---|---|
committer | kergoth <kergoth> | 2002-11-01 00:10:42 (UTC) |
commit | 5042e3cf0d3514552769e441f5aad590c8eaf967 (patch) (unidiff) | |
tree | 4a5ea45f3519d981a172ab5275bf38c6fa778dec /qmake/include/qcstring.h | |
parent | 108c1c753e74e989cc13923086996791428c9af4 (diff) | |
download | opie-5042e3cf0d3514552769e441f5aad590c8eaf967.zip opie-5042e3cf0d3514552769e441f5aad590c8eaf967.tar.gz opie-5042e3cf0d3514552769e441f5aad590c8eaf967.tar.bz2 |
Adding qmake in preperation for new build system
-rw-r--r-- | qmake/include/qcstring.h | 391 |
1 files changed, 391 insertions, 0 deletions
diff --git a/qmake/include/qcstring.h b/qmake/include/qcstring.h new file mode 100644 index 0000000..004bb3b --- a/dev/null +++ b/qmake/include/qcstring.h | |||
@@ -0,0 +1,391 @@ | |||
1 | /**************************************************************************** | ||
2 | ** $Id$ | ||
3 | ** | ||
4 | ** Definition of the extended char array operations, | ||
5 | ** and QByteArray and QCString classes | ||
6 | ** | ||
7 | ** Created : 920609 | ||
8 | ** | ||
9 | ** Copyright (C) 1992-2002 Trolltech AS. All rights reserved. | ||
10 | ** | ||
11 | ** This file is part of the tools module of the Qt GUI Toolkit. | ||
12 | ** | ||
13 | ** This file may be distributed under the terms of the Q Public License | ||
14 | ** as defined by Trolltech AS of Norway and appearing in the file | ||
15 | ** LICENSE.QPL included in the packaging of this file. | ||
16 | ** | ||
17 | ** This file may be distributed and/or modified under the terms of the | ||
18 | ** GNU General Public License version 2 as published by the Free Software | ||
19 | ** Foundation and appearing in the file LICENSE.GPL included in the | ||
20 | ** packaging of this file. | ||
21 | ** | ||
22 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition | ||
23 | ** licenses may use this file in accordance with the Qt Commercial License | ||
24 | ** Agreement provided with the Software. | ||
25 | ** | ||
26 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE | ||
27 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | ||
28 | ** | ||
29 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for | ||
30 | ** information about Qt Commercial License Agreements. | ||
31 | ** See http://www.trolltech.com/qpl/ for QPL licensing information. | ||
32 | ** See http://www.trolltech.com/gpl/ for GPL licensing information. | ||
33 | ** | ||
34 | ** Contact info@trolltech.com if any conditions of this licensing are | ||
35 | ** not clear to you. | ||
36 | ** | ||
37 | **********************************************************************/ | ||
38 | |||
39 | #ifndef QCSTRING_H | ||
40 | #define QCSTRING_H | ||
41 | |||
42 | #ifndef QT_H | ||
43 | #include "qmemarray.h" | ||
44 | #endif // QT_H | ||
45 | |||
46 | #include <string.h> | ||
47 | |||
48 | |||
49 | /***************************************************************************** | ||
50 | Safe and portable C string functions; extensions to standard string.h | ||
51 | *****************************************************************************/ | ||
52 | |||
53 | Q_EXPORT void *qmemmove( void *dst, const void *src, uint len ); | ||
54 | |||
55 | Q_EXPORT char *qstrdup( const char * ); | ||
56 | |||
57 | Q_EXPORT inline uint qstrlen( const char *str ) | ||
58 | { return str ? (uint)strlen(str) : 0; } | ||
59 | |||
60 | Q_EXPORT inline char *qstrcpy( char *dst, const char *src ) | ||
61 | { return src ? strcpy(dst, src) : 0; } | ||
62 | |||
63 | Q_EXPORT char *qstrncpy( char *dst, const char *src, uint len ); | ||
64 | |||
65 | Q_EXPORT inline int qstrcmp( const char *str1, const char *str2 ) | ||
66 | { | ||
67 | return ( str1 && str2 ) ? strcmp( str1, str2 ) | ||
68 | : ( str1 ? 1 : ( str2 ? -1 : 0 ) ); | ||
69 | } | ||
70 | |||
71 | Q_EXPORT inline int qstrncmp( const char *str1, const char *str2, uint len ) | ||
72 | { | ||
73 | return ( str1 && str2 ) ? strncmp( str1, str2, len ) | ||
74 | : ( str1 ? 1 : ( str2 ? -1 : 0 ) ); | ||
75 | } | ||
76 | |||
77 | Q_EXPORT int qstricmp( const char *, const char * ); | ||
78 | |||
79 | Q_EXPORT int qstrnicmp( const char *, const char *, uint len ); | ||
80 | |||
81 | #ifndef QT_CLEAN_NAMESPACE | ||
82 | Q_EXPORT inline uint cstrlen( const char *str ) | ||
83 | { return (uint)strlen(str); } | ||
84 | |||
85 | Q_EXPORT inline char *cstrcpy( char *dst, const char *src ) | ||
86 | { return strcpy(dst,src); } | ||
87 | |||
88 | Q_EXPORT inline int cstrcmp( const char *str1, const char *str2 ) | ||
89 | { return strcmp(str1,str2); } | ||
90 | |||
91 | Q_EXPORT inline int cstrncmp( const char *str1, const char *str2, uint len ) | ||
92 | { return strncmp(str1,str2,len); } | ||
93 | #endif | ||
94 | |||
95 | |||
96 | // qChecksum: Internet checksum | ||
97 | |||
98 | Q_EXPORT Q_UINT16 qChecksum( const char *s, uint len ); | ||
99 | |||
100 | /***************************************************************************** | ||
101 | QByteArray class | ||
102 | *****************************************************************************/ | ||
103 | |||
104 | #if defined(Q_TEMPLATEDLL) | ||
105 | Q_TEMPLATE_EXTERN template class Q_EXPORT QMemArray<char>; | ||
106 | #endif | ||
107 | |||
108 | #if defined(Q_QDOC) | ||
109 | /* | ||
110 | We want qdoc to document QByteArray as a real class that inherits | ||
111 | QMemArray<char> and that is inherited by QBitArray. | ||
112 | */ | ||
113 | class QByteArray : public QMemArray<char> | ||
114 | { | ||
115 | public: | ||
116 | QByteArray(); | ||
117 | QByteArray( int size ); | ||
118 | }; | ||
119 | #else | ||
120 | typedef QMemArray<char> QByteArray; | ||
121 | #endif | ||
122 | |||
123 | #ifndef QT_NO_COMPRESS | ||
124 | Q_EXPORT QByteArray qCompress( const uchar* data, int nbytes ); | ||
125 | Q_EXPORT QByteArray qUncompress( const uchar* data, int nbytes ); | ||
126 | Q_EXPORT inline QByteArray qCompress( const QByteArray& data) | ||
127 | { return qCompress( (const uchar*)data.data(), data.size() ); } | ||
128 | Q_EXPORT inline QByteArray qUncompress( const QByteArray& data ) | ||
129 | { return qUncompress( (const uchar*)data.data(), data.size() ); } | ||
130 | #endif | ||
131 | |||
132 | /***************************************************************************** | ||
133 | QByteArray stream functions | ||
134 | *****************************************************************************/ | ||
135 | #ifndef QT_NO_DATASTREAM | ||
136 | Q_EXPORT QDataStream &operator<<( QDataStream &, const QByteArray & ); | ||
137 | Q_EXPORT QDataStream &operator>>( QDataStream &, QByteArray & ); | ||
138 | #endif | ||
139 | |||
140 | /***************************************************************************** | ||
141 | QCString class | ||
142 | *****************************************************************************/ | ||
143 | |||
144 | class QRegExp; | ||
145 | |||
146 | class Q_EXPORT QCString : public QByteArray// C string class | ||
147 | { | ||
148 | public: | ||
149 | QCString() {} // make null string | ||
150 | QCString( int size ); // allocate size incl. \0 | ||
151 | QCString( const QCString &s ) : QByteArray( s ) {} | ||
152 | QCString( const char *str ); // deep copy | ||
153 | QCString( const char *str, uint maxlen );// deep copy, max length | ||
154 | ~QCString(); | ||
155 | |||
156 | QCString &operator=( const QCString &s );// shallow copy | ||
157 | QCString &operator=( const char *str );// deep copy | ||
158 | |||
159 | bool isNull()const; | ||
160 | bool isEmpty()const; | ||
161 | uint length()const; | ||
162 | boolresize( uint newlen ); | ||
163 | booltruncate( uint pos ); | ||
164 | boolfill( char c, int len = -1 ); | ||
165 | |||
166 | QCString copy()const; | ||
167 | |||
168 | QCString &sprintf( const char *format, ... ); | ||
169 | |||
170 | int find( char c, int index=0, bool cs=TRUE ) const; | ||
171 | int find( const char *str, int index=0, bool cs=TRUE ) const; | ||
172 | #ifndef QT_NO_REGEXP | ||
173 | int find( const QRegExp &, int index=0 ) const; | ||
174 | #endif | ||
175 | int findRev( char c, int index=-1, bool cs=TRUE) const; | ||
176 | int findRev( const char *str, int index=-1, bool cs=TRUE) const; | ||
177 | #ifndef QT_NO_REGEXP_CAPTURE | ||
178 | int findRev( const QRegExp &, int index=-1 ) const; | ||
179 | #endif | ||
180 | int contains( char c, bool cs=TRUE ) const; | ||
181 | int contains( const char *str, bool cs=TRUE ) const; | ||
182 | #ifndef QT_NO_REGEXP | ||
183 | int contains( const QRegExp & ) const; | ||
184 | #endif | ||
185 | QCStringleft( uint len ) const; | ||
186 | QCStringright( uint len ) const; | ||
187 | QCStringmid( uint index, uint len=0xffffffff) const; | ||
188 | |||
189 | QCStringleftJustify( uint width, char fill=' ', bool trunc=FALSE)const; | ||
190 | QCStringrightJustify( uint width, char fill=' ',bool trunc=FALSE)const; | ||
191 | |||
192 | QCStringlower() const; | ||
193 | QCStringupper() const; | ||
194 | |||
195 | QCString stripWhiteSpace()const; | ||
196 | QCString simplifyWhiteSpace()const; | ||
197 | |||
198 | QCString &insert( uint index, const char * ); | ||
199 | QCString &insert( uint index, char ); | ||
200 | QCString &append( const char * ); | ||
201 | QCString &prepend( const char * ); | ||
202 | QCString &remove( uint index, uint len ); | ||
203 | QCString &replace( uint index, uint len, const char * ); | ||
204 | #ifndef QT_NO_REGEXP | ||
205 | QCString &replace( const QRegExp &, const char * ); | ||
206 | #endif | ||
207 | QCString &replace( char c, const char *after ); | ||
208 | QCString &replace( const char *, const char * ); | ||
209 | QCString &replace( char, char ); | ||
210 | |||
211 | short toShort( bool *ok=0 )const; | ||
212 | ushort toUShort( bool *ok=0 )const; | ||
213 | int toInt( bool *ok=0 )const; | ||
214 | uint toUInt( bool *ok=0 )const; | ||
215 | long toLong( bool *ok=0 )const; | ||
216 | ulong toULong( bool *ok=0 )const; | ||
217 | float toFloat( bool *ok=0 )const; | ||
218 | double toDouble( bool *ok=0 )const; | ||
219 | |||
220 | QCString &setStr( const char *s ); | ||
221 | QCString &setNum( short ); | ||
222 | QCString &setNum( ushort ); | ||
223 | QCString &setNum( int ); | ||
224 | QCString &setNum( uint ); | ||
225 | QCString &setNum( long ); | ||
226 | QCString &setNum( ulong ); | ||
227 | QCString &setNum( float, char f='g', int prec=6 ); | ||
228 | QCString &setNum( double, char f='g', int prec=6 ); | ||
229 | |||
230 | boolsetExpand( uint index, char c ); | ||
231 | |||
232 | operator const char *() const; | ||
233 | QCString &operator+=( const char *str ); | ||
234 | QCString &operator+=( char c ); | ||
235 | }; | ||
236 | |||
237 | |||
238 | /***************************************************************************** | ||
239 | QCString stream functions | ||
240 | *****************************************************************************/ | ||
241 | #ifndef QT_NO_DATASTREAM | ||
242 | Q_EXPORT QDataStream &operator<<( QDataStream &, const QCString & ); | ||
243 | Q_EXPORT QDataStream &operator>>( QDataStream &, QCString & ); | ||
244 | #endif | ||
245 | |||
246 | /***************************************************************************** | ||
247 | QCString inline functions | ||
248 | *****************************************************************************/ | ||
249 | |||
250 | inline QCString &QCString::operator=( const QCString &s ) | ||
251 | { return (QCString&)assign( s ); } | ||
252 | |||
253 | inline QCString &QCString::operator=( const char *str ) | ||
254 | { return (QCString&)duplicate( str, qstrlen(str)+1 ); } | ||
255 | |||
256 | inline bool QCString::isNull() const | ||
257 | { return data() == 0; } | ||
258 | |||
259 | inline bool QCString::isEmpty() const | ||
260 | { return data() == 0 || *data() == '\0'; } | ||
261 | |||
262 | inline uint QCString::length() const | ||
263 | { return qstrlen( data() ); } | ||
264 | |||
265 | inline bool QCString::truncate( uint pos ) | ||
266 | { return resize(pos+1); } | ||
267 | |||
268 | inline QCString QCString::copy() const | ||
269 | { return QCString( data() ); } | ||
270 | |||
271 | inline QCString &QCString::prepend( const char *s ) | ||
272 | { return insert(0,s); } | ||
273 | |||
274 | inline QCString &QCString::append( const char *s ) | ||
275 | { return operator+=(s); } | ||
276 | |||
277 | inline QCString &QCString::setNum( short n ) | ||
278 | { return setNum((long)n); } | ||
279 | |||
280 | inline QCString &QCString::setNum( ushort n ) | ||
281 | { return setNum((ulong)n); } | ||
282 | |||
283 | inline QCString &QCString::setNum( int n ) | ||
284 | { return setNum((long)n); } | ||
285 | |||
286 | inline QCString &QCString::setNum( uint n ) | ||
287 | { return setNum((ulong)n); } | ||
288 | |||
289 | inline QCString &QCString::setNum( float n, char f, int prec ) | ||
290 | { return setNum((double)n,f,prec); } | ||
291 | |||
292 | inline QCString::operator const char *() const | ||
293 | { return (const char *)data(); } | ||
294 | |||
295 | |||
296 | /***************************************************************************** | ||
297 | QCString non-member operators | ||
298 | *****************************************************************************/ | ||
299 | |||
300 | Q_EXPORT inline bool operator==( const QCString &s1, const QCString &s2 ) | ||
301 | { return qstrcmp( s1.data(), s2.data() ) == 0; } | ||
302 | |||
303 | Q_EXPORT inline bool operator==( const QCString &s1, const char *s2 ) | ||
304 | { return qstrcmp( s1.data(), s2 ) == 0; } | ||
305 | |||
306 | Q_EXPORT inline bool operator==( const char *s1, const QCString &s2 ) | ||
307 | { return qstrcmp( s1, s2.data() ) == 0; } | ||
308 | |||
309 | Q_EXPORT inline bool operator!=( const QCString &s1, const QCString &s2 ) | ||
310 | { return qstrcmp( s1.data(), s2.data() ) != 0; } | ||
311 | |||
312 | Q_EXPORT inline bool operator!=( const QCString &s1, const char *s2 ) | ||
313 | { return qstrcmp( s1.data(), s2 ) != 0; } | ||
314 | |||
315 | Q_EXPORT inline bool operator!=( const char *s1, const QCString &s2 ) | ||
316 | { return qstrcmp( s1, s2.data() ) != 0; } | ||
317 | |||
318 | Q_EXPORT inline bool operator<( const QCString &s1, const QCString& s2 ) | ||
319 | { return qstrcmp( s1.data(), s2.data() ) < 0; } | ||
320 | |||
321 | Q_EXPORT inline bool operator<( const QCString &s1, const char *s2 ) | ||
322 | { return qstrcmp( s1.data(), s2 ) < 0; } | ||
323 | |||
324 | Q_EXPORT inline bool operator<( const char *s1, const QCString &s2 ) | ||
325 | { return qstrcmp( s1, s2.data() ) < 0; } | ||
326 | |||
327 | Q_EXPORT inline bool operator<=( const QCString &s1, const QCString &s2 ) | ||
328 | { return qstrcmp( s1.data(), s2.data() ) <= 0; } | ||
329 | |||
330 | Q_EXPORT inline bool operator<=( const QCString &s1, const char *s2 ) | ||
331 | { return qstrcmp( s1.data(), s2 ) <= 0; } | ||
332 | |||
333 | Q_EXPORT inline bool operator<=( const char *s1, const QCString &s2 ) | ||
334 | { return qstrcmp( s1, s2.data() ) <= 0; } | ||
335 | |||
336 | Q_EXPORT inline bool operator>( const QCString &s1, const QCString &s2 ) | ||
337 | { return qstrcmp( s1.data(), s2.data() ) > 0; } | ||
338 | |||
339 | Q_EXPORT inline bool operator>( const QCString &s1, const char *s2 ) | ||
340 | { return qstrcmp( s1.data(), s2 ) > 0; } | ||
341 | |||
342 | Q_EXPORT inline bool operator>( const char *s1, const QCString &s2 ) | ||
343 | { return qstrcmp( s1, s2.data() ) > 0; } | ||
344 | |||
345 | Q_EXPORT inline bool operator>=( const QCString &s1, const QCString& s2 ) | ||
346 | { return qstrcmp( s1.data(), s2.data() ) >= 0; } | ||
347 | |||
348 | Q_EXPORT inline bool operator>=( const QCString &s1, const char *s2 ) | ||
349 | { return qstrcmp( s1.data(), s2 ) >= 0; } | ||
350 | |||
351 | Q_EXPORT inline bool operator>=( const char *s1, const QCString &s2 ) | ||
352 | { return qstrcmp( s1, s2.data() ) >= 0; } | ||
353 | |||
354 | Q_EXPORT inline const QCString operator+( const QCString &s1, | ||
355 | const QCString &s2 ) | ||
356 | { | ||
357 | QCString tmp( s1.data() ); | ||
358 | tmp += s2; | ||
359 | return tmp; | ||
360 | } | ||
361 | |||
362 | Q_EXPORT inline const QCString operator+( const QCString &s1, const char *s2 ) | ||
363 | { | ||
364 | QCString tmp( s1.data() ); | ||
365 | tmp += s2; | ||
366 | return tmp; | ||
367 | } | ||
368 | |||
369 | Q_EXPORT inline const QCString operator+( const char *s1, const QCString &s2 ) | ||
370 | { | ||
371 | QCString tmp( s1 ); | ||
372 | tmp += s2; | ||
373 | return tmp; | ||
374 | } | ||
375 | |||
376 | Q_EXPORT inline const QCString operator+( const QCString &s1, char c2 ) | ||
377 | { | ||
378 | QCString tmp( s1.data() ); | ||
379 | tmp += c2; | ||
380 | return tmp; | ||
381 | } | ||
382 | |||
383 | Q_EXPORT inline const QCString operator+( char c1, const QCString &s2 ) | ||
384 | { | ||
385 | QCString tmp; | ||
386 | tmp += c1; | ||
387 | tmp += s2; | ||
388 | return tmp; | ||
389 | } | ||
390 | |||
391 | #endif // QCSTRING_H | ||