1 | <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
|
---|
2 | <!-- /home/espenr/tmp/qt-3.3.8-espenr-2499/qt-x11-free-3.3.8/include/qcstring.h:1 -->
|
---|
3 | <html>
|
---|
4 | <head>
|
---|
5 | <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
|
---|
6 | <title>qcstring.h Include File</title>
|
---|
7 | <style type="text/css"><!--
|
---|
8 | fn { margin-left: 1cm; text-indent: -1cm; }
|
---|
9 | a:link { color: #004faf; text-decoration: none }
|
---|
10 | a:visited { color: #672967; text-decoration: none }
|
---|
11 | body { background: #ffffff; color: black; }
|
---|
12 | --></style>
|
---|
13 | </head>
|
---|
14 | <body>
|
---|
15 |
|
---|
16 | <table border="0" cellpadding="0" cellspacing="0" width="100%">
|
---|
17 | <tr bgcolor="#E5E5E5">
|
---|
18 | <td valign=center>
|
---|
19 | <a href="index.html">
|
---|
20 | <font color="#004faf">Home</font></a>
|
---|
21 | | <a href="classes.html">
|
---|
22 | <font color="#004faf">All Classes</font></a>
|
---|
23 | | <a href="mainclasses.html">
|
---|
24 | <font color="#004faf">Main Classes</font></a>
|
---|
25 | | <a href="annotated.html">
|
---|
26 | <font color="#004faf">Annotated</font></a>
|
---|
27 | | <a href="groups.html">
|
---|
28 | <font color="#004faf">Grouped Classes</font></a>
|
---|
29 | | <a href="functions.html">
|
---|
30 | <font color="#004faf">Functions</font></a>
|
---|
31 | </td>
|
---|
32 | <td align="right" valign="center"><img src="logo32.png" align="right" width="64" height="32" border="0"></td></tr></table><h1 align=center>qcstring.h</h1>
|
---|
33 |
|
---|
34 | <p>This is the verbatim text of the qcstring.h include file. It is provided only for illustration; the copyright remains with Trolltech.
|
---|
35 | <hr>
|
---|
36 | <pre>
|
---|
37 | /****************************************************************************
|
---|
38 | ** $Id: qcstring-h.html 2051 2007-02-21 10:04:20Z chehrlic $
|
---|
39 | **
|
---|
40 | ** Definition of the extended char array operations,
|
---|
41 | ** and QByteArray and QCString classes
|
---|
42 | **
|
---|
43 | ** Created : 920609
|
---|
44 | **
|
---|
45 | ** Copyright (C) 1992-2007 Trolltech ASA. All rights reserved.
|
---|
46 | **
|
---|
47 | ** This file is part of the tools module of the Qt GUI Toolkit.
|
---|
48 | **
|
---|
49 | ** This file may be distributed under the terms of the Q Public License
|
---|
50 | ** as defined by Trolltech ASA of Norway and appearing in the file
|
---|
51 | ** LICENSE.QPL included in the packaging of this file.
|
---|
52 | **
|
---|
53 | ** This file may be distributed and/or modified under the terms of the
|
---|
54 | ** GNU General Public License version 2 as published by the Free Software
|
---|
55 | ** Foundation and appearing in the file LICENSE.GPL included in the
|
---|
56 | ** packaging of this file.
|
---|
57 | **
|
---|
58 | ** Licensees holding valid Qt Enterprise Edition or Qt Professional Edition
|
---|
59 | ** licenses may use this file in accordance with the Qt Commercial License
|
---|
60 | ** Agreement provided with the Software.
|
---|
61 | **
|
---|
62 | ** This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
|
---|
63 | ** WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
|
---|
64 | **
|
---|
65 | ** See http://www.trolltech.com/pricing.html or email sales@trolltech.com for
|
---|
66 | ** information about Qt Commercial License Agreements.
|
---|
67 | ** See http://www.trolltech.com/qpl/ for QPL licensing information.
|
---|
68 | ** See http://www.trolltech.com/gpl/ for GPL licensing information.
|
---|
69 | **
|
---|
70 | ** Contact info@trolltech.com if any conditions of this licensing are
|
---|
71 | ** not clear to you.
|
---|
72 | **
|
---|
73 | **********************************************************************/
|
---|
74 |
|
---|
75 | #ifndef QCSTRING_H
|
---|
76 | #define QCSTRING_H
|
---|
77 |
|
---|
78 | #ifndef QT_H
|
---|
79 | #include "qmemarray.h"
|
---|
80 | #endif // QT_H
|
---|
81 |
|
---|
82 | #include <string.h>
|
---|
83 |
|
---|
84 |
|
---|
85 | /*****************************************************************************
|
---|
86 | Safe and portable C string functions; extensions to standard string.h
|
---|
87 | *****************************************************************************/
|
---|
88 |
|
---|
89 | Q_EXPORT void *qmemmove( void *dst, const void *src, uint len );
|
---|
90 |
|
---|
91 | Q_EXPORT char *qstrdup( const char * );
|
---|
92 |
|
---|
93 | Q_EXPORT inline uint qstrlen( const char *str )
|
---|
94 | { return str ? (uint)strlen(str) : 0u; }
|
---|
95 |
|
---|
96 | Q_EXPORT inline char *qstrcpy( char *dst, const char *src )
|
---|
97 | { return src ? strcpy(dst, src) : 0; }
|
---|
98 |
|
---|
99 | Q_EXPORT char *qstrncpy( char *dst, const char *src, uint len );
|
---|
100 |
|
---|
101 | Q_EXPORT inline int qstrcmp( const char *str1, const char *str2 )
|
---|
102 | {
|
---|
103 | return ( str1 && str2 ) ? strcmp( str1, str2 )
|
---|
104 | : ( str1 ? 1 : ( str2 ? -1 : 0 ) );
|
---|
105 | }
|
---|
106 |
|
---|
107 | Q_EXPORT inline int qstrncmp( const char *str1, const char *str2, uint len )
|
---|
108 | {
|
---|
109 | return ( str1 && str2 ) ? strncmp( str1, str2, len )
|
---|
110 | : ( str1 ? 1 : ( str2 ? -1 : 0 ) );
|
---|
111 | }
|
---|
112 |
|
---|
113 | Q_EXPORT int qstricmp( const char *, const char * );
|
---|
114 |
|
---|
115 | Q_EXPORT int qstrnicmp( const char *, const char *, uint len );
|
---|
116 |
|
---|
117 | #ifndef QT_CLEAN_NAMESPACE
|
---|
118 | Q_EXPORT inline uint cstrlen( const char *str )
|
---|
119 | { return (uint)strlen(str); }
|
---|
120 |
|
---|
121 | Q_EXPORT inline char *cstrcpy( char *dst, const char *src )
|
---|
122 | { return strcpy(dst,src); }
|
---|
123 |
|
---|
124 | Q_EXPORT inline int cstrcmp( const char *str1, const char *str2 )
|
---|
125 | { return strcmp(str1,str2); }
|
---|
126 |
|
---|
127 | Q_EXPORT inline int cstrncmp( const char *str1, const char *str2, uint len )
|
---|
128 | { return strncmp(str1,str2,len); }
|
---|
129 | #endif
|
---|
130 |
|
---|
131 |
|
---|
132 | // qChecksum: Internet checksum
|
---|
133 |
|
---|
134 | Q_EXPORT Q_UINT16 qChecksum( const char *s, uint len );
|
---|
135 |
|
---|
136 | /*****************************************************************************
|
---|
137 | QByteArray class
|
---|
138 | *****************************************************************************/
|
---|
139 |
|
---|
140 | #if defined(Q_QDOC)
|
---|
141 | /*
|
---|
142 | We want qdoc to document QByteArray as a real class that inherits
|
---|
143 | QMemArray<char> and that is inherited by QBitArray.
|
---|
144 | */
|
---|
145 | class QByteArray : public QMemArray<char>
|
---|
146 | {
|
---|
147 | public:
|
---|
148 | QByteArray();
|
---|
149 | QByteArray( int size );
|
---|
150 | };
|
---|
151 | #else
|
---|
152 | typedef QMemArray<char> QByteArray;
|
---|
153 | #endif
|
---|
154 |
|
---|
155 | #ifndef QT_NO_COMPRESS
|
---|
156 | Q_EXPORT QByteArray qCompress( const uchar* data, int nbytes );
|
---|
157 | Q_EXPORT QByteArray qUncompress( const uchar* data, int nbytes );
|
---|
158 | Q_EXPORT inline QByteArray qCompress( const QByteArray& data)
|
---|
159 | { return qCompress( (const uchar*)data.data(), data.size() ); }
|
---|
160 | Q_EXPORT inline QByteArray qUncompress( const QByteArray& data )
|
---|
161 | { return qUncompress( (const uchar*)data.data(), data.size() ); }
|
---|
162 | #endif
|
---|
163 |
|
---|
164 | /*****************************************************************************
|
---|
165 | QByteArray stream functions
|
---|
166 | *****************************************************************************/
|
---|
167 | #ifndef QT_NO_DATASTREAM
|
---|
168 | Q_EXPORT QDataStream &operator<<( QDataStream &, const QByteArray & );
|
---|
169 | Q_EXPORT QDataStream &operator>>( QDataStream &, QByteArray & );
|
---|
170 | #endif
|
---|
171 |
|
---|
172 | /*****************************************************************************
|
---|
173 | QCString class
|
---|
174 | *****************************************************************************/
|
---|
175 |
|
---|
176 | class QRegExp;
|
---|
177 |
|
---|
178 | class Q_EXPORT QCString : public QByteArray // C string class
|
---|
179 | {
|
---|
180 | public:
|
---|
181 | QCString() {} // make null string
|
---|
182 | QCString( int size ); // allocate size incl. \0
|
---|
183 | QCString( const QCString &s ) : QByteArray( s ) {}
|
---|
184 | QCString( const char *str ); // deep copy
|
---|
185 | QCString( const char *str, uint maxlen ); // deep copy, max length
|
---|
186 | ~QCString();
|
---|
187 |
|
---|
188 | QCString &operator=( const QCString &s );// shallow copy
|
---|
189 | QCString &operator=( const char *str ); // deep copy
|
---|
190 |
|
---|
191 | bool isNull() const;
|
---|
192 | bool isEmpty() const;
|
---|
193 | uint length() const;
|
---|
194 | bool resize( uint newlen );
|
---|
195 | bool truncate( uint pos );
|
---|
196 | bool fill( char c, int len = -1 );
|
---|
197 |
|
---|
198 | QCString copy() const;
|
---|
199 |
|
---|
200 | QCString &sprintf( const char *format, ... );
|
---|
201 |
|
---|
202 | int find( char c, int index=0, bool cs=TRUE ) const;
|
---|
203 | int find( const char *str, int index=0, bool cs=TRUE ) const;
|
---|
204 | #ifndef QT_NO_REGEXP
|
---|
205 | int find( const QRegExp &, int index=0 ) const;
|
---|
206 | #endif
|
---|
207 | int findRev( char c, int index=-1, bool cs=TRUE) const;
|
---|
208 | int findRev( const char *str, int index=-1, bool cs=TRUE) const;
|
---|
209 | #ifndef QT_NO_REGEXP_CAPTURE
|
---|
210 | int findRev( const QRegExp &, int index=-1 ) const;
|
---|
211 | #endif
|
---|
212 | int contains( char c, bool cs=TRUE ) const;
|
---|
213 | int contains( const char *str, bool cs=TRUE ) const;
|
---|
214 | #ifndef QT_NO_REGEXP
|
---|
215 | int contains( const QRegExp & ) const;
|
---|
216 | #endif
|
---|
217 | QCString left( uint len ) const;
|
---|
218 | QCString right( uint len ) const;
|
---|
219 | QCString mid( uint index, uint len=0xffffffff) const;
|
---|
220 |
|
---|
221 | QCString leftJustify( uint width, char fill=' ', bool trunc=FALSE)const;
|
---|
222 | QCString rightJustify( uint width, char fill=' ',bool trunc=FALSE)const;
|
---|
223 |
|
---|
224 | QCString lower() const;
|
---|
225 | QCString upper() const;
|
---|
226 |
|
---|
227 | QCString stripWhiteSpace() const;
|
---|
228 | QCString simplifyWhiteSpace() const;
|
---|
229 |
|
---|
230 | QCString &insert( uint index, const char * );
|
---|
231 | QCString &insert( uint index, char );
|
---|
232 | QCString &append( const char * );
|
---|
233 | QCString &prepend( const char * );
|
---|
234 | QCString &remove( uint index, uint len );
|
---|
235 | QCString &replace( uint index, uint len, const char * );
|
---|
236 | #ifndef QT_NO_REGEXP
|
---|
237 | QCString &replace( const QRegExp &, const char * );
|
---|
238 | #endif
|
---|
239 | QCString &replace( char c, const char *after );
|
---|
240 | QCString &replace( const char *, const char * );
|
---|
241 | QCString &replace( char, char );
|
---|
242 |
|
---|
243 | short toShort( bool *ok=0 ) const;
|
---|
244 | ushort toUShort( bool *ok=0 ) const;
|
---|
245 | int toInt( bool *ok=0 ) const;
|
---|
246 | uint toUInt( bool *ok=0 ) const;
|
---|
247 | long toLong( bool *ok=0 ) const;
|
---|
248 | ulong toULong( bool *ok=0 ) const;
|
---|
249 | float toFloat( bool *ok=0 ) const;
|
---|
250 | double toDouble( bool *ok=0 ) const;
|
---|
251 |
|
---|
252 | QCString &setStr( const char *s );
|
---|
253 | QCString &setNum( short );
|
---|
254 | QCString &setNum( ushort );
|
---|
255 | QCString &setNum( int );
|
---|
256 | QCString &setNum( uint );
|
---|
257 | QCString &setNum( long );
|
---|
258 | QCString &setNum( ulong );
|
---|
259 | QCString &setNum( float, char f='g', int prec=6 );
|
---|
260 | QCString &setNum( double, char f='g', int prec=6 );
|
---|
261 |
|
---|
262 | bool setExpand( uint index, char c );
|
---|
263 |
|
---|
264 | operator const char *() const;
|
---|
265 | QCString &operator+=( const char *str );
|
---|
266 | QCString &operator+=( char c );
|
---|
267 | private:
|
---|
268 | int find( const char *str, int index, bool cs, uint l ) const;
|
---|
269 | };
|
---|
270 |
|
---|
271 |
|
---|
272 | /*****************************************************************************
|
---|
273 | QCString stream functions
|
---|
274 | *****************************************************************************/
|
---|
275 | #ifndef QT_NO_DATASTREAM
|
---|
276 | Q_EXPORT QDataStream &operator<<( QDataStream &, const QCString & );
|
---|
277 | Q_EXPORT QDataStream &operator>>( QDataStream &, QCString & );
|
---|
278 | #endif
|
---|
279 |
|
---|
280 | /*****************************************************************************
|
---|
281 | QCString inline functions
|
---|
282 | *****************************************************************************/
|
---|
283 |
|
---|
284 | inline QCString &QCString::operator=( const QCString &s )
|
---|
285 | { return (QCString&)assign( s ); }
|
---|
286 |
|
---|
287 | inline QCString &QCString::operator=( const char *str )
|
---|
288 | { return (QCString&)duplicate( str, qstrlen(str)+1 ); }
|
---|
289 |
|
---|
290 | inline bool QCString::isNull() const
|
---|
291 | { return data() == 0; }
|
---|
292 |
|
---|
293 | inline bool QCString::isEmpty() const
|
---|
294 | { return data() == 0 || *data() == '\0'; }
|
---|
295 |
|
---|
296 | inline uint QCString::length() const
|
---|
297 | { return qstrlen( data() ); }
|
---|
298 |
|
---|
299 | inline bool QCString::truncate( uint pos )
|
---|
300 | { return resize(pos+1); }
|
---|
301 |
|
---|
302 | inline QCString QCString::copy() const
|
---|
303 | { return QCString( data() ); }
|
---|
304 |
|
---|
305 | inline QCString &QCString::prepend( const char *s )
|
---|
306 | { return insert(0,s); }
|
---|
307 |
|
---|
308 | inline QCString &QCString::append( const char *s )
|
---|
309 | { return operator+=(s); }
|
---|
310 |
|
---|
311 | inline QCString &QCString::setNum( short n )
|
---|
312 | { return setNum((long)n); }
|
---|
313 |
|
---|
314 | inline QCString &QCString::setNum( ushort n )
|
---|
315 | { return setNum((ulong)n); }
|
---|
316 |
|
---|
317 | inline QCString &QCString::setNum( int n )
|
---|
318 | { return setNum((long)n); }
|
---|
319 |
|
---|
320 | inline QCString &QCString::setNum( uint n )
|
---|
321 | { return setNum((ulong)n); }
|
---|
322 |
|
---|
323 | inline QCString &QCString::setNum( float n, char f, int prec )
|
---|
324 | { return setNum((double)n,f,prec); }
|
---|
325 |
|
---|
326 | inline QCString::operator const char *() const
|
---|
327 | { return (const char *)data(); }
|
---|
328 |
|
---|
329 |
|
---|
330 | /*****************************************************************************
|
---|
331 | QCString non-member operators
|
---|
332 | *****************************************************************************/
|
---|
333 |
|
---|
334 | Q_EXPORT inline bool operator==( const QCString &s1, const QCString &s2 )
|
---|
335 | { return qstrcmp( s1.data(), s2.data() ) == 0; }
|
---|
336 |
|
---|
337 | Q_EXPORT inline bool operator==( const QCString &s1, const char *s2 )
|
---|
338 | { return qstrcmp( s1.data(), s2 ) == 0; }
|
---|
339 |
|
---|
340 | Q_EXPORT inline bool operator==( const char *s1, const QCString &s2 )
|
---|
341 | { return qstrcmp( s1, s2.data() ) == 0; }
|
---|
342 |
|
---|
343 | Q_EXPORT inline bool operator!=( const QCString &s1, const QCString &s2 )
|
---|
344 | { return qstrcmp( s1.data(), s2.data() ) != 0; }
|
---|
345 |
|
---|
346 | Q_EXPORT inline bool operator!=( const QCString &s1, const char *s2 )
|
---|
347 | { return qstrcmp( s1.data(), s2 ) != 0; }
|
---|
348 |
|
---|
349 | Q_EXPORT inline bool operator!=( const char *s1, const QCString &s2 )
|
---|
350 | { return qstrcmp( s1, s2.data() ) != 0; }
|
---|
351 |
|
---|
352 | Q_EXPORT inline bool operator<( const QCString &s1, const QCString& s2 )
|
---|
353 | { return qstrcmp( s1.data(), s2.data() ) < 0; }
|
---|
354 |
|
---|
355 | Q_EXPORT inline bool operator<( const QCString &s1, const char *s2 )
|
---|
356 | { return qstrcmp( s1.data(), s2 ) < 0; }
|
---|
357 |
|
---|
358 | Q_EXPORT inline bool operator<( const char *s1, const QCString &s2 )
|
---|
359 | { return qstrcmp( s1, s2.data() ) < 0; }
|
---|
360 |
|
---|
361 | Q_EXPORT inline bool operator<=( const QCString &s1, const QCString &s2 )
|
---|
362 | { return qstrcmp( s1.data(), s2.data() ) <= 0; }
|
---|
363 |
|
---|
364 | Q_EXPORT inline bool operator<=( const QCString &s1, const char *s2 )
|
---|
365 | { return qstrcmp( s1.data(), s2 ) <= 0; }
|
---|
366 |
|
---|
367 | Q_EXPORT inline bool operator<=( const char *s1, const QCString &s2 )
|
---|
368 | { return qstrcmp( s1, s2.data() ) <= 0; }
|
---|
369 |
|
---|
370 | Q_EXPORT inline bool operator>( const QCString &s1, const QCString &s2 )
|
---|
371 | { return qstrcmp( s1.data(), s2.data() ) > 0; }
|
---|
372 |
|
---|
373 | Q_EXPORT inline bool operator>( const QCString &s1, const char *s2 )
|
---|
374 | { return qstrcmp( s1.data(), s2 ) > 0; }
|
---|
375 |
|
---|
376 | Q_EXPORT inline bool operator>( const char *s1, const QCString &s2 )
|
---|
377 | { return qstrcmp( s1, s2.data() ) > 0; }
|
---|
378 |
|
---|
379 | Q_EXPORT inline bool operator>=( const QCString &s1, const QCString& s2 )
|
---|
380 | { return qstrcmp( s1.data(), s2.data() ) >= 0; }
|
---|
381 |
|
---|
382 | Q_EXPORT inline bool operator>=( const QCString &s1, const char *s2 )
|
---|
383 | { return qstrcmp( s1.data(), s2 ) >= 0; }
|
---|
384 |
|
---|
385 | Q_EXPORT inline bool operator>=( const char *s1, const QCString &s2 )
|
---|
386 | { return qstrcmp( s1, s2.data() ) >= 0; }
|
---|
387 |
|
---|
388 | Q_EXPORT inline const QCString operator+( const QCString &s1,
|
---|
389 | const QCString &s2 )
|
---|
390 | {
|
---|
391 | QCString tmp( s1.data() );
|
---|
392 | tmp += s2;
|
---|
393 | return tmp;
|
---|
394 | }
|
---|
395 |
|
---|
396 | Q_EXPORT inline const QCString operator+( const QCString &s1, const char *s2 )
|
---|
397 | {
|
---|
398 | QCString tmp( s1.data() );
|
---|
399 | tmp += s2;
|
---|
400 | return tmp;
|
---|
401 | }
|
---|
402 |
|
---|
403 | Q_EXPORT inline const QCString operator+( const char *s1, const QCString &s2 )
|
---|
404 | {
|
---|
405 | QCString tmp( s1 );
|
---|
406 | tmp += s2;
|
---|
407 | return tmp;
|
---|
408 | }
|
---|
409 |
|
---|
410 | Q_EXPORT inline const QCString operator+( const QCString &s1, char c2 )
|
---|
411 | {
|
---|
412 | QCString tmp( s1.data() );
|
---|
413 | tmp += c2;
|
---|
414 | return tmp;
|
---|
415 | }
|
---|
416 |
|
---|
417 | Q_EXPORT inline const QCString operator+( char c1, const QCString &s2 )
|
---|
418 | {
|
---|
419 | QCString tmp;
|
---|
420 | tmp += c1;
|
---|
421 | tmp += s2;
|
---|
422 | return tmp;
|
---|
423 | }
|
---|
424 | #include "qwinexport.h"
|
---|
425 | #endif // QCSTRING_H
|
---|
426 | </pre>
|
---|
427 | <!-- eof -->
|
---|
428 | <p><address><hr><div align=center>
|
---|
429 | <table width=100% cellspacing=0 border=0><tr>
|
---|
430 | <td>Copyright © 2007
|
---|
431 | <a href="troll.html">Trolltech</a><td align=center><a href="trademarks.html">Trademarks</a>
|
---|
432 | <td align=right><div align=right>Qt 3.3.8</div>
|
---|
433 | </table></div></address></body>
|
---|
434 | </html>
|
---|