source: trunk/doc/html/qcstring-h.html

Last change on this file was 190, checked in by rudi, 14 years ago

reference documentation added

File size: 15.0 KB
RevLine 
[190]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"><!--
8fn { margin-left: 1cm; text-indent: -1cm; }
9a:link { color: #004faf; text-decoration: none }
10a:visited { color: #672967; text-decoration: none }
11body { 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&nbsp;Classes</font></a>
23 | <a href="mainclasses.html">
24<font color="#004faf">Main&nbsp;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&nbsp;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 &lt;string.h&gt;
83
84
85/*****************************************************************************
86 Safe and portable C string functions; extensions to standard string.h
87 *****************************************************************************/
88
89Q_EXPORT void *qmemmove( void *dst, const void *src, uint len );
90
91Q_EXPORT char *qstrdup( const char * );
92
93Q_EXPORT inline uint qstrlen( const char *str )
94{ return str ? (uint)strlen(str) : 0u; }
95
96Q_EXPORT inline char *qstrcpy( char *dst, const char *src )
97{ return src ? strcpy(dst, src) : 0; }
98
99Q_EXPORT char *qstrncpy( char *dst, const char *src, uint len );
100
101Q_EXPORT inline int qstrcmp( const char *str1, const char *str2 )
102{
103 return ( str1 &amp;&amp; str2 ) ? strcmp( str1, str2 )
104 : ( str1 ? 1 : ( str2 ? -1 : 0 ) );
105}
106
107Q_EXPORT inline int qstrncmp( const char *str1, const char *str2, uint len )
108{
109 return ( str1 &amp;&amp; str2 ) ? strncmp( str1, str2, len )
110 : ( str1 ? 1 : ( str2 ? -1 : 0 ) );
111}
112
113Q_EXPORT int qstricmp( const char *, const char * );
114
115Q_EXPORT int qstrnicmp( const char *, const char *, uint len );
116
117#ifndef QT_CLEAN_NAMESPACE
118Q_EXPORT inline uint cstrlen( const char *str )
119{ return (uint)strlen(str); }
120
121Q_EXPORT inline char *cstrcpy( char *dst, const char *src )
122{ return strcpy(dst,src); }
123
124Q_EXPORT inline int cstrcmp( const char *str1, const char *str2 )
125{ return strcmp(str1,str2); }
126
127Q_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
134Q_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&lt;char&gt; and that is inherited by QBitArray.
144*/
145class QByteArray : public QMemArray&lt;char&gt;
146{
147public:
148 QByteArray();
149 QByteArray( int size );
150};
151#else
152typedef QMemArray&lt;char&gt; QByteArray;
153#endif
154
155#ifndef QT_NO_COMPRESS
156Q_EXPORT QByteArray qCompress( const uchar* data, int nbytes );
157Q_EXPORT QByteArray qUncompress( const uchar* data, int nbytes );
158Q_EXPORT inline QByteArray qCompress( const QByteArray&amp; data)
159{ return qCompress( (const uchar*)data.data(), data.size() ); }
160Q_EXPORT inline QByteArray qUncompress( const QByteArray&amp; data )
161{ return qUncompress( (const uchar*)data.data(), data.size() ); }
162#endif
163
164/*****************************************************************************
165 QByteArray stream functions
166 *****************************************************************************/
167#ifndef QT_NO_DATASTREAM
168Q_EXPORT QDataStream &amp;operator&lt;&lt;( QDataStream &amp;, const QByteArray &amp; );
169Q_EXPORT QDataStream &amp;operator&gt;&gt;( QDataStream &amp;, QByteArray &amp; );
170#endif
171
172/*****************************************************************************
173 QCString class
174 *****************************************************************************/
175
176class QRegExp;
177
178class Q_EXPORT QCString : public QByteArray // C string class
179{
180public:
181 QCString() {} // make null string
182 QCString( int size ); // allocate size incl. \0
183 QCString( const QCString &amp;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 &amp;operator=( const QCString &amp;s );// shallow copy
189 QCString &amp;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 &amp;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 &amp;, 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 &amp;, 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 &amp; ) 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 &amp;insert( uint index, const char * );
231 QCString &amp;insert( uint index, char );
232 QCString &amp;append( const char * );
233 QCString &amp;prepend( const char * );
234 QCString &amp;remove( uint index, uint len );
235 QCString &amp;replace( uint index, uint len, const char * );
236#ifndef QT_NO_REGEXP
237 QCString &amp;replace( const QRegExp &amp;, const char * );
238#endif
239 QCString &amp;replace( char c, const char *after );
240 QCString &amp;replace( const char *, const char * );
241 QCString &amp;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 &amp;setStr( const char *s );
253 QCString &amp;setNum( short );
254 QCString &amp;setNum( ushort );
255 QCString &amp;setNum( int );
256 QCString &amp;setNum( uint );
257 QCString &amp;setNum( long );
258 QCString &amp;setNum( ulong );
259 QCString &amp;setNum( float, char f='g', int prec=6 );
260 QCString &amp;setNum( double, char f='g', int prec=6 );
261
262 bool setExpand( uint index, char c );
263
264 operator const char *() const;
265 QCString &amp;operator+=( const char *str );
266 QCString &amp;operator+=( char c );
267private:
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
276Q_EXPORT QDataStream &amp;operator&lt;&lt;( QDataStream &amp;, const QCString &amp; );
277Q_EXPORT QDataStream &amp;operator&gt;&gt;( QDataStream &amp;, QCString &amp; );
278#endif
279
280/*****************************************************************************
281 QCString inline functions
282 *****************************************************************************/
283
284inline QCString &amp;QCString::operator=( const QCString &amp;s )
285{ return (QCString&amp;)assign( s ); }
286
287inline QCString &amp;QCString::operator=( const char *str )
288{ return (QCString&amp;)duplicate( str, qstrlen(str)+1 ); }
289
290inline bool QCString::isNull() const
291{ return data() == 0; }
292
293inline bool QCString::isEmpty() const
294{ return data() == 0 || *data() == '\0'; }
295
296inline uint QCString::length() const
297{ return qstrlen( data() ); }
298
299inline bool QCString::truncate( uint pos )
300{ return resize(pos+1); }
301
302inline QCString QCString::copy() const
303{ return QCString( data() ); }
304
305inline QCString &amp;QCString::prepend( const char *s )
306{ return insert(0,s); }
307
308inline QCString &amp;QCString::append( const char *s )
309{ return operator+=(s); }
310
311inline QCString &amp;QCString::setNum( short n )
312{ return setNum((long)n); }
313
314inline QCString &amp;QCString::setNum( ushort n )
315{ return setNum((ulong)n); }
316
317inline QCString &amp;QCString::setNum( int n )
318{ return setNum((long)n); }
319
320inline QCString &amp;QCString::setNum( uint n )
321{ return setNum((ulong)n); }
322
323inline QCString &amp;QCString::setNum( float n, char f, int prec )
324{ return setNum((double)n,f,prec); }
325
326inline QCString::operator const char *() const
327{ return (const char *)data(); }
328
329
330/*****************************************************************************
331 QCString non-member operators
332 *****************************************************************************/
333
334Q_EXPORT inline bool operator==( const QCString &amp;s1, const QCString &amp;s2 )
335{ return qstrcmp( s1.data(), s2.data() ) == 0; }
336
337Q_EXPORT inline bool operator==( const QCString &amp;s1, const char *s2 )
338{ return qstrcmp( s1.data(), s2 ) == 0; }
339
340Q_EXPORT inline bool operator==( const char *s1, const QCString &amp;s2 )
341{ return qstrcmp( s1, s2.data() ) == 0; }
342
343Q_EXPORT inline bool operator!=( const QCString &amp;s1, const QCString &amp;s2 )
344{ return qstrcmp( s1.data(), s2.data() ) != 0; }
345
346Q_EXPORT inline bool operator!=( const QCString &amp;s1, const char *s2 )
347{ return qstrcmp( s1.data(), s2 ) != 0; }
348
349Q_EXPORT inline bool operator!=( const char *s1, const QCString &amp;s2 )
350{ return qstrcmp( s1, s2.data() ) != 0; }
351
352Q_EXPORT inline bool operator&lt;( const QCString &amp;s1, const QCString&amp; s2 )
353{ return qstrcmp( s1.data(), s2.data() ) &lt; 0; }
354
355Q_EXPORT inline bool operator&lt;( const QCString &amp;s1, const char *s2 )
356{ return qstrcmp( s1.data(), s2 ) &lt; 0; }
357
358Q_EXPORT inline bool operator&lt;( const char *s1, const QCString &amp;s2 )
359{ return qstrcmp( s1, s2.data() ) &lt; 0; }
360
361Q_EXPORT inline bool operator&lt;=( const QCString &amp;s1, const QCString &amp;s2 )
362{ return qstrcmp( s1.data(), s2.data() ) &lt;= 0; }
363
364Q_EXPORT inline bool operator&lt;=( const QCString &amp;s1, const char *s2 )
365{ return qstrcmp( s1.data(), s2 ) &lt;= 0; }
366
367Q_EXPORT inline bool operator&lt;=( const char *s1, const QCString &amp;s2 )
368{ return qstrcmp( s1, s2.data() ) &lt;= 0; }
369
370Q_EXPORT inline bool operator&gt;( const QCString &amp;s1, const QCString &amp;s2 )
371{ return qstrcmp( s1.data(), s2.data() ) &gt; 0; }
372
373Q_EXPORT inline bool operator&gt;( const QCString &amp;s1, const char *s2 )
374{ return qstrcmp( s1.data(), s2 ) &gt; 0; }
375
376Q_EXPORT inline bool operator&gt;( const char *s1, const QCString &amp;s2 )
377{ return qstrcmp( s1, s2.data() ) &gt; 0; }
378
379Q_EXPORT inline bool operator&gt;=( const QCString &amp;s1, const QCString&amp; s2 )
380{ return qstrcmp( s1.data(), s2.data() ) &gt;= 0; }
381
382Q_EXPORT inline bool operator&gt;=( const QCString &amp;s1, const char *s2 )
383{ return qstrcmp( s1.data(), s2 ) &gt;= 0; }
384
385Q_EXPORT inline bool operator&gt;=( const char *s1, const QCString &amp;s2 )
386{ return qstrcmp( s1, s2.data() ) &gt;= 0; }
387
388Q_EXPORT inline const QCString operator+( const QCString &amp;s1,
389 const QCString &amp;s2 )
390{
391 QCString tmp( s1.data() );
392 tmp += s2;
393 return tmp;
394}
395
396Q_EXPORT inline const QCString operator+( const QCString &amp;s1, const char *s2 )
397{
398 QCString tmp( s1.data() );
399 tmp += s2;
400 return tmp;
401}
402
403Q_EXPORT inline const QCString operator+( const char *s1, const QCString &amp;s2 )
404{
405 QCString tmp( s1 );
406 tmp += s2;
407 return tmp;
408}
409
410Q_EXPORT inline const QCString operator+( const QCString &amp;s1, char c2 )
411{
412 QCString tmp( s1.data() );
413 tmp += c2;
414 return tmp;
415}
416
417Q_EXPORT inline const QCString operator+( char c1, const QCString &amp;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 &copy; 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>
Note: See TracBrowser for help on using the repository browser.