~oif-team/ubuntu/natty/qt4-x11/xi2.1

« back to all changes in this revision

Viewing changes to doc/html/q3cstring.html

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad
  • Date: 2005-08-24 04:09:09 UTC
  • Revision ID: james.westby@ubuntu.com-20050824040909-xmxe9jfr4a0w5671
Tags: upstream-4.0.0
ImportĀ upstreamĀ versionĀ 4.0.0

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
<?xml version="1.0" encoding="iso-8859-1"?>
 
2
<!DOCTYPE html
 
3
    PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "DTD/xhtml1-strict.dtd">
 
4
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
 
5
<!-- /tmp/qt-4.0.0-espenr-1119621036935/qt-x11-opensource-desktop-4.0.0/src/qt3support/tools/q3cstring.cpp -->
 
6
<head>
 
7
    <title>Qt 4.0: Q3CString Class Reference</title>
 
8
    <style>h3.fn,span.fn { margin-left: 1cm; text-indent: -1cm; }
 
9
a:link { color: #004faf; text-decoration: none }
 
10
a:visited { color: #672967; text-decoration: none }
 
11
td.postheader { font-family: sans-serif }
 
12
tr.address { font-family: sans-serif }
 
13
body { background: #ffffff; color: black; }</style>
 
14
</head>
 
15
<body>
 
16
<table border="0" cellpadding="0" cellspacing="0" width="100%">
 
17
<tr>
 
18
<td align="left" valign="top" width="32"><img src="images/qt-logo.png" align="left" width="32" height="32" border="0" /></td>
 
19
<td width="1">&nbsp;&nbsp;</td><td class="postheader" valign="center"><a href="index.html"><font color="#004faf">Home</font></a>&nbsp;&middot; <a href="classes.html"><font color="#004faf">All&nbsp;Classes</font></a>&nbsp;&middot; <a href="mainclasses.html"><font color="#004faf">Main&nbsp;Classes</font></a>&nbsp;&middot; <a href="annotated.html"><font color="#004faf">Annotated</font></a>&nbsp;&middot; <a href="groups.html"><font color="#004faf">Grouped&nbsp;Classes</font></a>&nbsp;&middot; <a href="functions.html"><font color="#004faf">Functions</font></a></td>
 
20
<td align="right" valign="top" width="230"><img src="images/trolltech-logo.png" align="right" width="203" height="32" border="0" /></td></tr></table><h1 align="center">Q3CString Class Reference</h1>
 
21
<p>The Q3CString class provides an abstraction of the classic C zero-terminated char array (char *). <a href="#details">More...</a></p>
 
22
<pre>#include &lt;Q3CString&gt;</pre><p><b>This class is part of the Qt 3 support library.</b> It is provided to keep old source code working. We strongly advise against using it in new code. See the <a href="porting4.html">Porting Guide</a> for more information.</p>
 
23
<p>Part of the <a href="qt3support.html">Qt3Support</a> module.</p>
 
24
<p>Inherits <a href="qbytearray.html">QByteArray</a>.</p>
 
25
<p><b>Note:</b> All the functions in this class are <a href="threads.html#reentrant">reentrant</a>.</p>
 
26
<ul>
 
27
<li><a href="q3cstring-members.html">List of all members, including inherited members</a></li>
 
28
</ul>
 
29
<a name="public-functions"></a>
 
30
<h3>Public Functions</h3>
 
31
<ul>
 
32
<li><div class="fn"/><b><a href="q3cstring.html#Q3CString">Q3CString</a></b> ()</li>
 
33
<li><div class="fn"/><b><a href="q3cstring.html#Q3CString-2">Q3CString</a></b> ( int <i>size</i> )</li>
 
34
<li><div class="fn"/><b><a href="q3cstring.html#Q3CString-3">Q3CString</a></b> ( const Q3CString &amp; <i>s</i> )</li>
 
35
<li><div class="fn"/><b><a href="q3cstring.html#Q3CString-4">Q3CString</a></b> ( const QByteArray &amp; <i>ba</i> )</li>
 
36
<li><div class="fn"/><b><a href="q3cstring.html#Q3CString-5">Q3CString</a></b> ( const char * <i>str</i> )</li>
 
37
<li><div class="fn"/><b><a href="q3cstring.html#Q3CString-6">Q3CString</a></b> ( const char * <i>str</i>, uint <i>maxsize</i> )</li>
 
38
<li><div class="fn"/>Q3CString &amp; <b><a href="q3cstring.html#append">append</a></b> ( const char * <i>str</i> )</li>
 
39
<li><div class="fn"/>Q3CString <b><a href="q3cstring.html#copy">copy</a></b> () const</li>
 
40
<li><div class="fn"/>Q3CString <b><a href="q3cstring.html#leftJustify">leftJustify</a></b> ( uint <i>width</i>, char <i>fill</i> = ' ', bool <i>truncate</i> = false ) const</li>
 
41
<li><div class="fn"/>Q3CString <b><a href="q3cstring.html#lower">lower</a></b> () const</li>
 
42
<li><div class="fn"/>Q3CString <b><a href="q3cstring.html#rightJustify">rightJustify</a></b> ( uint <i>width</i>, char <i>fill</i> = ' ', bool <i>truncate</i> = false ) const</li>
 
43
<li><div class="fn"/>bool <b><a href="q3cstring.html#setExpand">setExpand</a></b> ( uint <i>index</i>, char <i>c</i> )</li>
 
44
<li><div class="fn"/>Q3CString &amp; <b><a href="q3cstring.html#setNum">setNum</a></b> ( double <i>n</i>, char <i>f</i> = 'g', int <i>prec</i> = 6 )</li>
 
45
<li><div class="fn"/>Q3CString &amp; <b><a href="q3cstring.html#setNum-2">setNum</a></b> ( long <i>n</i> )</li>
 
46
<li><div class="fn"/>Q3CString &amp; <b><a href="q3cstring.html#setNum-3">setNum</a></b> ( ulong <i>n</i> )</li>
 
47
<li><div class="fn"/>Q3CString &amp; <b><a href="q3cstring.html#setNum-4">setNum</a></b> ( int <i>n</i> )</li>
 
48
<li><div class="fn"/>Q3CString &amp; <b><a href="q3cstring.html#setNum-5">setNum</a></b> ( uint <i>n</i> )</li>
 
49
<li><div class="fn"/>Q3CString &amp; <b><a href="q3cstring.html#setNum-6">setNum</a></b> ( short <i>n</i> )</li>
 
50
<li><div class="fn"/>Q3CString &amp; <b><a href="q3cstring.html#setNum-7">setNum</a></b> ( ushort <i>n</i> )</li>
 
51
<li><div class="fn"/>Q3CString &amp; <b><a href="q3cstring.html#setNum-8">setNum</a></b> ( float <i>n</i>, char <i>f</i> = 'g', int <i>prec</i> = 6 )</li>
 
52
<li><div class="fn"/>Q3CString &amp; <b><a href="q3cstring.html#setStr">setStr</a></b> ( const char * <i>str</i> )</li>
 
53
<li><div class="fn"/>Q3CString <b><a href="q3cstring.html#simplifyWhiteSpace">simplifyWhiteSpace</a></b> () const</li>
 
54
<li><div class="fn"/>Q3CString &amp; <b><a href="q3cstring.html#sprintf">sprintf</a></b> ( const char * <i>format</i>, ... )</li>
 
55
<li><div class="fn"/>Q3CString <b><a href="q3cstring.html#stripWhiteSpace">stripWhiteSpace</a></b> () const</li>
 
56
<li><div class="fn"/>double <b><a href="q3cstring.html#toDouble">toDouble</a></b> ( bool * <i>ok</i> = 0 ) const</li>
 
57
<li><div class="fn"/>float <b><a href="q3cstring.html#toFloat">toFloat</a></b> ( bool * <i>ok</i> = 0 ) const</li>
 
58
<li><div class="fn"/>int <b><a href="q3cstring.html#toInt">toInt</a></b> ( bool * <i>ok</i> = 0 ) const</li>
 
59
<li><div class="fn"/>long <b><a href="q3cstring.html#toLong">toLong</a></b> ( bool * <i>ok</i> = 0 ) const</li>
 
60
<li><div class="fn"/>short <b><a href="q3cstring.html#toShort">toShort</a></b> ( bool * <i>ok</i> = 0 ) const</li>
 
61
<li><div class="fn"/>uint <b><a href="q3cstring.html#toUInt">toUInt</a></b> ( bool * <i>ok</i> = 0 ) const</li>
 
62
<li><div class="fn"/>ulong <b><a href="q3cstring.html#toULong">toULong</a></b> ( bool * <i>ok</i> = 0 ) const</li>
 
63
<li><div class="fn"/>ushort <b><a href="q3cstring.html#toUShort">toUShort</a></b> ( bool * <i>ok</i> = 0 ) const</li>
 
64
<li><div class="fn"/>Q3CString <b><a href="q3cstring.html#upper">upper</a></b> () const</li>
 
65
<li><div class="fn"/>Q3CString &amp; <b><a href="q3cstring.html#operator-eq">operator=</a></b> ( const Q3CString &amp; <i>s</i> )</li>
 
66
<li><div class="fn"/>Q3CString &amp; <b><a href="q3cstring.html#operator-eq-2">operator=</a></b> ( const QByteArray &amp; <i>ba</i> )</li>
 
67
<li><div class="fn"/>Q3CString &amp; <b><a href="q3cstring.html#operator-eq-3">operator=</a></b> ( const char * <i>str</i> )</li>
 
68
</ul>
 
69
<ul>
 
70
<li><div class="fn"/>112 public functions inherited from <a href="qbytearray.html#public-functions">QByteArray</a></li>
 
71
</ul>
 
72
<a name="related-non-members"></a>
 
73
<h3>Related Non-Members</h3>
 
74
<ul>
 
75
<li><div class="fn"/>bool <b><a href="q3cstring.html#operator-not-eq-26">operator!=</a></b> ( const Q3CString &amp; <i>s1</i>, const Q3CString &amp; <i>s2</i> )</li>
 
76
<li><div class="fn"/>bool <b><a href="q3cstring.html#operator-not-eq-31">operator!=</a></b> ( const Q3CString &amp; <i>s1</i>, const char * <i>s2</i> )</li>
 
77
<li><div class="fn"/>bool <b><a href="q3cstring.html#operator-not-eq-32">operator!=</a></b> ( const char * <i>s1</i>, const Q3CString &amp; <i>s2</i> )</li>
 
78
<li><div class="fn"/>const Q3CString <b><a href="q3cstring.html#operator-2b-13">operator+</a></b> ( const Q3CString &amp; <i>s1</i>, const Q3CString &amp; <i>s2</i> )</li>
 
79
<li><div class="fn"/>const Q3CString <b><a href="q3cstring.html#operator-2b-24">operator+</a></b> ( const Q3CString &amp; <i>s1</i>, const char * <i>s2</i> )</li>
 
80
<li><div class="fn"/>const Q3CString <b><a href="q3cstring.html#operator-2b-25">operator+</a></b> ( const char * <i>s1</i>, const Q3CString &amp; <i>s2</i> )</li>
 
81
<li><div class="fn"/>const Q3CString <b><a href="q3cstring.html#operator-2b-26">operator+</a></b> ( const Q3CString &amp; <i>s</i>, char <i>c</i> )</li>
 
82
<li><div class="fn"/>const Q3CString <b><a href="q3cstring.html#operator-2b-27">operator+</a></b> ( char <i>c</i>, const Q3CString &amp; <i>s</i> )</li>
 
83
<li><div class="fn"/>bool <b><a href="q3cstring.html#operator-lt-7">operator&lt;</a></b> ( const Q3CString &amp; <i>s1</i>, const char * <i>s2</i> )</li>
 
84
<li><div class="fn"/>bool <b><a href="q3cstring.html#operator-lt-12">operator&lt;</a></b> ( const char * <i>s1</i>, const Q3CString &amp; <i>s2</i> )</li>
 
85
<li><div class="fn"/>QDataStream &amp; <b><a href="q3cstring.html#operator-lt-lt-85">operator&lt;&lt;</a></b> ( QDataStream &amp; <i>s</i>, const Q3CString &amp; <i>str</i> )</li>
 
86
<li><div class="fn"/>bool <b><a href="q3cstring.html#operator-lt-eq-7">operator&lt;=</a></b> ( const Q3CString &amp; <i>s1</i>, const char * <i>s2</i> )</li>
 
87
<li><div class="fn"/>bool <b><a href="q3cstring.html#operator-lt-eq-12">operator&lt;=</a></b> ( const char * <i>s1</i>, const Q3CString &amp; <i>s2</i> )</li>
 
88
<li><div class="fn"/>bool <b><a href="q3cstring.html#operator-eq-eq-36">operator==</a></b> ( const Q3CString &amp; <i>s1</i>, const Q3CString &amp; <i>s2</i> )</li>
 
89
<li><div class="fn"/>bool <b><a href="q3cstring.html#operator-eq-eq-41">operator==</a></b> ( const Q3CString &amp; <i>s1</i>, const char * <i>s2</i> )</li>
 
90
<li><div class="fn"/>bool <b><a href="q3cstring.html#operator-eq-eq-42">operator==</a></b> ( const char * <i>s1</i>, const Q3CString &amp; <i>s2</i> )</li>
 
91
<li><div class="fn"/>bool <b><a href="q3cstring.html#operator-gt-7">operator&gt;</a></b> ( const Q3CString &amp; <i>s1</i>, const char * <i>s2</i> )</li>
 
92
<li><div class="fn"/>bool <b><a href="q3cstring.html#operator-gt-12">operator&gt;</a></b> ( const char * <i>s1</i>, const Q3CString &amp; <i>s2</i> )</li>
 
93
<li><div class="fn"/>bool <b><a href="q3cstring.html#operator-gt-eq-7">operator&gt;=</a></b> ( const Q3CString &amp; <i>s1</i>, const char * <i>s2</i> )</li>
 
94
<li><div class="fn"/>bool <b><a href="q3cstring.html#operator-gt-eq-12">operator&gt;=</a></b> ( const char * <i>s1</i>, const Q3CString &amp; <i>s2</i> )</li>
 
95
<li><div class="fn"/>QDataStream &amp; <b><a href="q3cstring.html#operator-gt-gt-57">operator&gt;&gt;</a></b> ( QDataStream &amp; <i>s</i>, Q3CString &amp; <i>str</i> )</li>
 
96
</ul>
 
97
<h3>Additional Inherited Members</h3>
 
98
<ul>
 
99
<li><div class="fn"/>7 static public members inherited from <a href="qbytearray.html#static-public-members">QByteArray</a></li>
 
100
</ul>
 
101
<a name="details"></a>
 
102
<hr />
 
103
<h2>Detailed Description</h2>
 
104
<p>The Q3CString class provides an abstraction of the classic C zero-terminated char array (char *).</p>
 
105
<p>Q3CString tries to behave like a more convenient <tt>const char *</tt>. The price of doing this is that some algorithms will perform badly. For example, <a href="q3cstring.html#append">append</a>() is O(<a href="qbytearray.html#length">length</a>()) since it scans for a null terminator. Although you might use Q3CString for text that is never exposed to the user, for most purposes, and especially for user-visible text, you should use <a href="qstring.html">QString</a>. <a href="qstring.html">QString</a> provides implicit sharing, Unicode and other internationalization support, and is well optimized.</p>
 
106
<p>Note that for the Q3CString methods that take a <tt>const char *</tt> parameter the <tt>const char *</tt> must either be 0 (null) or not-null and '\0' (NUL byte) terminated; otherwise the results are undefined.</p>
 
107
<p>A Q3CString that has not been assigned to anything is <i>null</i>, i.e. both the length and the data pointer is 0. A Q3CString that references the empty string (&quot;&quot;, a single '\0' char) is <i>empty</i>. Both null and empty Q3CStrings are legal parameters to the methods. Assigning <tt>const char *</tt> 0 to Q3CString produces a null Q3CString.</p>
 
108
<p>The <a href="qbytearray.html#length">length</a>() function returns the length of the string; <a href="qbytearray.html#resize">resize</a>() resizes the string and <a href="qbytearray.html#truncate">truncate</a>() truncates the string. A string can be filled with a character using <a href="qbytearray.html#fill">fill</a>(). Strings can be left or right padded with characters using <a href="q3cstring.html#leftJustify">leftJustify</a>() and <a href="q3cstring.html#rightJustify">rightJustify</a>(). Characters, strings and regular expressions can be searched for using <a href="qbytearray-qt3.html#find">find</a>() and <a href="qbytearray-qt3.html#findRev">findRev</a>(), and counted using <a href="qbytearray.html#contains">contains</a>().</p>
 
109
<p>Strings and characters can be inserted with <a href="q3cstring.html#insert">insert</a>() and appended with <a href="q3cstring.html#append">append</a>(). A string can be prepended with <a href="q3cstring.html#prepend">prepend</a>(). Characters can be removed from the string with <a href="q3cstring.html#remove">remove</a>() and replaced with <a href="q3cstring.html#replace">replace</a>().</p>
 
110
<p>Portions of a string can be extracted using <a href="q3cstring.html#left">left</a>(), <a href="q3cstring.html#right">right</a>() and <a href="q3cstring.html#mid">mid</a>(). Whitespace can be removed using <a href="q3cstring.html#stripWhiteSpace">stripWhiteSpace</a>() and <a href="q3cstring.html#simplifyWhiteSpace">simplifyWhiteSpace</a>(). Strings can be converted to uppercase or lowercase with <a href="q3cstring.html#upper">upper</a>() and <a href="q3cstring.html#lower">lower</a>() respectively.</p>
 
111
<p>Strings that contain numbers can be converted to numbers with <a href="q3cstring.html#toShort">toShort</a>(), <a href="q3cstring.html#toInt">toInt</a>(), <a href="q3cstring.html#toLong">toLong</a>(), <a href="q3cstring.html#toULong">toULong</a>(), <a href="q3cstring.html#toFloat">toFloat</a>() and <a href="q3cstring.html#toDouble">toDouble</a>(). Numbers can be converted to strings with <a href="q3cstring.html#setNum">setNum</a>().</p>
 
112
<p>Many operators are overloaded to work with Q3CStrings. Q3CString also supports some more obscure functions, e.g. <a href="q3cstring.html#sprintf">sprintf</a>(), <a href="q3cstring.html#setStr">setStr</a>() and <a href="q3cstring.html#setExpand">setExpand</a>().</p>
 
113
<p>Note on Character Comparisons</p>
 
114
<p>In Q3CString the notion of uppercase and lowercase and of which character is greater than or less than another character is locale dependent. This affects functions which support a case insensitive option or which compare or lowercase or uppercase their arguments. Case insensitive operations and comparisons will be accurate if both strings contain only ASCII characters. (If <tt>$LC_CTYPE</tt> is set, most Unix systems do &quot;the right thing&quot;.) Functions that this affects include <a href="qbytearray.html#contains">contains</a>(), <a href="qbytearray-qt3.html#find">find</a>(), <a href="qbytearray-qt3.html#findRev">findRev</a>(), <a href="qbytearray.html#operator-lt">operator&lt;</a>(), <a href="qbytearray.html#operator-lt-eq">operator&lt;=</a>(), <a href="qbytearray.html#operator-gt">operator&gt;</a>(), <a href="qbytearray.html#operator-gt-eq">operator&gt;=</a>(), <a href="q3cstring.html#lower">lower</a>() and <a href="q3cstring.html#upper">upper</a>().</p>
 
115
<p>This issue does not apply to <a href="qstring.html">QString</a>s since they represent characters using Unicode.</p>
 
116
<p>Performance note: The Q3CString methods for <a href="qregexp.html">QRegExp</a> searching are implemented by converting the Q3CString to a <a href="qstring.html">QString</a> and performing the search on that. This implies a deep copy of the Q3CString data. If you are going to perform many <a href="qregexp.html">QRegExp</a> searches on a large Q3CString, you will get better performance by converting the Q3CString to a <a href="qstring.html">QString</a> yourself, and then searching in the <a href="qstring.html">QString</a>.</p>
 
117
<hr />
 
118
<h2>Member Function Documentation</h2>
 
119
<h3 class="fn"><a name="Q3CString"></a>Q3CString::Q3CString ()</h3>
 
120
<p>Constructs a null string.</p>
 
121
<p>See also <a href="qbytearray.html#isNull">isNull</a>().</p>
 
122
<h3 class="fn"><a name="Q3CString-2"></a>Q3CString::Q3CString ( int <i>size</i> )</h3>
 
123
<p>Constructs a string with room for <i>size</i> characters, including the '\0'-terminator. Makes a null string if <i>size</i> == 0.</p>
 
124
<p>If <i>size</i> &gt; 0, then the first and last characters in the string are initialized to '\0'. All other characters are uninitialized.</p>
 
125
<p>See also <a href="qbytearray.html#resize">resize</a>() and <a href="qbytearray.html#isNull">isNull</a>().</p>
 
126
<h3 class="fn"><a name="Q3CString-3"></a>Q3CString::Q3CString ( const Q3CString &amp; <i>s</i> )</h3>
 
127
<p>Constructs a shallow copy <i>s</i>.</p>
 
128
<h3 class="fn"><a name="Q3CString-4"></a>Q3CString::Q3CString ( const <a href="qbytearray.html">QByteArray</a> &amp; <i>ba</i> )</h3>
 
129
<p>Constructs a copy of <i>ba</i>.</p>
 
130
<h3 class="fn"><a name="Q3CString-5"></a>Q3CString::Q3CString ( const char * <i>str</i> )</h3>
 
131
<p>Constructs a string that is a deep copy of <i>str</i>.</p>
 
132
<p>If <i>str</i> is 0 a null string is created.</p>
 
133
<p>See also <a href="qbytearray.html#isNull">isNull</a>().</p>
 
134
<h3 class="fn"><a name="Q3CString-6"></a>Q3CString::Q3CString ( const char * <i>str</i>, <a href="qtglobal.html#uint-typedef">uint</a> <i>maxsize</i> )</h3>
 
135
<p>Constructs a string that is a deep copy of <i>str</i>. The copy will be at most <i>maxsize</i> bytes long including the '\0'-terminator.</p>
 
136
<p>Example:</p>
 
137
<pre>&nbsp;   Q3CString str(&quot;helloworld&quot;, 6); // assigns &quot;hello&quot; to str</pre>
 
138
<p>If <i>str</i> contains a 0 byte within the first <i>maxsize</i> bytes, the resulting <a href="q3cstring.html">Q3CString</a> will be terminated by this 0. If <i>str</i> is 0 a null string is created.</p>
 
139
<p>See also <a href="qbytearray.html#isNull">isNull</a>().</p>
 
140
<h3 class="fn"><a name="append"></a>Q3CString &amp; Q3CString::append ( const char * <i>str</i> )</h3>
 
141
<p>Appends string <i>str</i> to the string and returns a reference to the string. Equivalent to operator+=().</p>
 
142
<h3 class="fn"><a name="copy"></a>Q3CString Q3CString::copy () const</h3>
 
143
<p>Returns a deep copy of this string.</p>
 
144
<p>See also <a href="qbytearray.html#detach">detach</a>().</p>
 
145
<h3 class="fn"><a name="leftJustify"></a>Q3CString Q3CString::leftJustify ( <a href="qtglobal.html#uint-typedef">uint</a> <i>width</i>, char <i>fill</i> = ' ', bool <i>truncate</i> = false ) const</h3>
 
146
<p>Returns a string of length <i>width</i> (plus one for the terminating '\0') that contains this string padded with the <i>fill</i> character.</p>
 
147
<p>If the length of the string exceeds <i>width</i> and <i>truncate</i> is false (the default), then the returned string is a copy of the string. If the length of the string exceeds <i>width</i> and <i>truncate</i> is true, then the returned string is a left(<i>width</i>).</p>
 
148
<p>Example:</p>
 
149
<pre>&nbsp;   Q3CString s(&quot;apple&quot;);
 
150
    Q3CString t = s.leftJustify(8, '.');  // t == &quot;apple...&quot;</pre>
 
151
<p>See also <a href="q3cstring.html#rightJustify">rightJustify</a>().</p>
 
152
<h3 class="fn"><a name="lower"></a>Q3CString Q3CString::lower () const</h3>
 
153
<p>Use <a href="qbytearray.html#toLower">QByteArray::toLower</a>() instead.</p>
 
154
<h3 class="fn"><a name="rightJustify"></a>Q3CString Q3CString::rightJustify ( <a href="qtglobal.html#uint-typedef">uint</a> <i>width</i>, char <i>fill</i> = ' ', bool <i>truncate</i> = false ) const</h3>
 
155
<p>Returns a string of length <i>width</i> (plus one for the terminating '\0') that contains zero or more of the <i>fill</i> character followed by this string.</p>
 
156
<p>If the length of the string exceeds <i>width</i> and <i>truncate</i> is false (the default), then the returned string is a copy of the string. If the length of the string exceeds <i>width</i> and <i>truncate</i> is true, then the returned string is a left(<i>width</i>).</p>
 
157
<p>Example:</p>
 
158
<pre>&nbsp;   Q3CString s(&quot;pie&quot;);
 
159
    Q3CString t = s.rightJustify(8, '.');  // t == &quot;.....pie&quot;</pre>
 
160
<p>See also <a href="q3cstring.html#leftJustify">leftJustify</a>().</p>
 
161
<h3 class="fn"><a name="setExpand"></a>bool Q3CString::setExpand ( <a href="qtglobal.html#uint-typedef">uint</a> <i>index</i>, char <i>c</i> )</h3>
 
162
<p>Sets the character at position <i>index</i> to <i>c</i> and expands the string if necessary, padding with spaces.</p>
 
163
<p>Returns false if <i>index</i> was out of range and the string could not be expanded; otherwise returns true.</p>
 
164
<h3 class="fn"><a name="setNum"></a>Q3CString &amp; Q3CString::setNum ( double <i>n</i>, char <i>f</i> = 'g', int <i>prec</i> = 6 )</h3>
 
165
<p>Sets the string to the string representation of the number <i>n</i> and returns a reference to the string.</p>
 
166
<p>The format of the string representation is specified by the format character <i>f</i>, and the precision (number of digits after the decimal point) is specified with <i>prec</i>.</p>
 
167
<p>The valid formats for <i>f</i> are 'e', 'E', 'f', 'g' and 'G'. The formats are the same as for <a href="q3cstring.html#sprintf">sprintf</a>(); they are explained in <a href="qstring.html#arg">QString::arg</a>().</p>
 
168
<h3 class="fn"><a name="setNum-2"></a>Q3CString &amp; Q3CString::setNum ( long <i>n</i> )</h3>
 
169
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
170
<p>Sets the string to the string representation of the number <i>n</i> and returns a reference to the string.</p>
 
171
<h3 class="fn"><a name="setNum-3"></a>Q3CString &amp; Q3CString::setNum ( <a href="qtglobal.html#ulong-typedef">ulong</a> <i>n</i> )</h3>
 
172
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
173
<p>Sets the string to the string representation of the number <i>n</i> and returns a reference to the string.</p>
 
174
<h3 class="fn"><a name="setNum-4"></a>Q3CString &amp; Q3CString::setNum ( int <i>n</i> )</h3>
 
175
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
176
<p>Sets the string to the string representation of the number <i>n</i> and returns a reference to the string.</p>
 
177
<h3 class="fn"><a name="setNum-5"></a>Q3CString &amp; Q3CString::setNum ( <a href="qtglobal.html#uint-typedef">uint</a> <i>n</i> )</h3>
 
178
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
179
<p>Sets the string to the string representation of the number <i>n</i> and returns a reference to the string.</p>
 
180
<h3 class="fn"><a name="setNum-6"></a>Q3CString &amp; Q3CString::setNum ( short <i>n</i> )</h3>
 
181
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
182
<p>Sets the string to the string representation of the number <i>n</i> and returns a reference to the string.</p>
 
183
<h3 class="fn"><a name="setNum-7"></a>Q3CString &amp; Q3CString::setNum ( <a href="qtglobal.html#ushort-typedef">ushort</a> <i>n</i> )</h3>
 
184
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
185
<p>Sets the string to the string representation of the number <i>n</i> and returns a reference to the string.</p>
 
186
<h3 class="fn"><a name="setNum-8"></a>Q3CString &amp; Q3CString::setNum ( float <i>n</i>, char <i>f</i> = 'g', int <i>prec</i> = 6 )</h3>
 
187
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
188
<h3 class="fn"><a name="setStr"></a>Q3CString &amp; Q3CString::setStr ( const char * <i>str</i> )</h3>
 
189
<p>Makes a deep copy of <i>str</i>. Returns a reference to the string.</p>
 
190
<h3 class="fn"><a name="simplifyWhiteSpace"></a>Q3CString Q3CString::simplifyWhiteSpace () const</h3>
 
191
<p>Use <a href="qbytearray.html#simplified">QByteArray::simplified</a>() instead.</p>
 
192
<h3 class="fn"><a name="sprintf"></a>Q3CString &amp; Q3CString::sprintf ( const char * <i>format</i>, ... )</h3>
 
193
<p>Implemented as a call to the native vsprintf() (see the manual for your C library).</p>
 
194
<p>If the string is shorter than 256 characters, this sprintf() calls resize(256) to decrease the chance of memory corruption. The string is resized back to its actual length before sprintf() returns.</p>
 
195
<p>Example:</p>
 
196
<pre>&nbsp;   Q3CString s;
 
197
    s.sprintf(&quot;%d - %s&quot;, 1, &quot;first&quot;);                // result &lt; 256 chars
 
198
 
 
199
    Q3CString big(25000);                        // very long string
 
200
    big.sprintf(&quot;%d - %s&quot;, 2, longString);        // result &lt; 25000 chars</pre>
 
201
<p><b>Warning:</b> All vsprintf() implementations will write past the end of the target string (*this) if the <i>format</i> specification and arguments happen to be longer than the target string, and some will also fail if the target string is longer than some arbitrary implementation limit.</p>
 
202
<p>Giving user-supplied arguments to sprintf() is risky: Sooner or later someone will paste a huge line into your application.</p>
 
203
<h3 class="fn"><a name="stripWhiteSpace"></a>Q3CString Q3CString::stripWhiteSpace () const</h3>
 
204
<p>Use <a href="qbytearray.html#trimmed">QByteArray::trimmed</a>() instead.</p>
 
205
<h3 class="fn"><a name="toDouble"></a>double Q3CString::toDouble ( bool * <i>ok</i> = 0 ) const</h3>
 
206
<p>Returns the string converted to a <tt>double</tt> value.</p>
 
207
<p>If <i>ok</i> is not 0: *<i>ok</i> is set to false if the string is not a number, or if it has trailing garbage; otherwise *<i>ok</i> is set to true.</p>
 
208
<h3 class="fn"><a name="toFloat"></a>float Q3CString::toFloat ( bool * <i>ok</i> = 0 ) const</h3>
 
209
<p>Returns the string converted to a <tt>float</tt> value.</p>
 
210
<p>If <i>ok</i> is not 0: *<i>ok</i> is set to false if the string is not a number, or if it has trailing garbage; otherwise *<i>ok</i> is set to true.</p>
 
211
<h3 class="fn"><a name="toInt"></a>int Q3CString::toInt ( bool * <i>ok</i> = 0 ) const</h3>
 
212
<p>Returns the string converted to a <tt>int</tt> value.</p>
 
213
<p>If <i>ok</i> is not 0: *<i>ok</i> is set to false if the string is not a number, or if it has trailing garbage; otherwise *<i>ok</i> is set to true.</p>
 
214
<h3 class="fn"><a name="toLong"></a>long Q3CString::toLong ( bool * <i>ok</i> = 0 ) const</h3>
 
215
<p>Returns the string converted to a <tt>long</tt> value.</p>
 
216
<p>If <i>ok</i> is not 0: *<i>ok</i> is set to false if the string is not a number, or if it has trailing garbage; otherwise *<i>ok</i> is set to true.</p>
 
217
<h3 class="fn"><a name="toShort"></a>short Q3CString::toShort ( bool * <i>ok</i> = 0 ) const</h3>
 
218
<p>Returns the string converted to a <tt>short</tt> value.</p>
 
219
<p>If <i>ok</i> is not 0: *<i>ok</i> is set to false if the string is not a number, is out of range, or if it has trailing garbage; otherwise *<i>ok</i> is set to true.</p>
 
220
<h3 class="fn"><a name="toUInt"></a><a href="qtglobal.html#uint-typedef">uint</a> Q3CString::toUInt ( bool * <i>ok</i> = 0 ) const</h3>
 
221
<p>Returns the string converted to an <tt>unsigned int</tt> value.</p>
 
222
<p>If <i>ok</i> is not 0: *<i>ok</i> is set to false if the string is not a number, or if it has trailing garbage; otherwise *<i>ok</i> is set to true.</p>
 
223
<h3 class="fn"><a name="toULong"></a><a href="qtglobal.html#ulong-typedef">ulong</a> Q3CString::toULong ( bool * <i>ok</i> = 0 ) const</h3>
 
224
<p>Returns the string converted to an <tt>unsigned long</tt> value.</p>
 
225
<p>If <i>ok</i> is not 0: *<i>ok</i> is set to false if the string is not a number, or if it has trailing garbage; otherwise *<i>ok</i> is set to true.</p>
 
226
<h3 class="fn"><a name="toUShort"></a><a href="qtglobal.html#ushort-typedef">ushort</a> Q3CString::toUShort ( bool * <i>ok</i> = 0 ) const</h3>
 
227
<p>Returns the string converted to an <tt>unsigned short</tt> value.</p>
 
228
<p>If <i>ok</i> is not 0: *<i>ok</i> is set to false if the string is not a number, is out of range, or if it has trailing garbage; otherwise *<i>ok</i> is set to true.</p>
 
229
<h3 class="fn"><a name="upper"></a>Q3CString Q3CString::upper () const</h3>
 
230
<p>Use <a href="qbytearray.html#toUpper">QByteArray::toUpper</a>() instead.</p>
 
231
<h3 class="fn"><a name="operator-eq"></a>Q3CString &amp; Q3CString::operator= ( const Q3CString &amp; <i>s</i> )</h3>
 
232
<p>Assigns a shallow copy of <i>s</i> to this string and returns a reference to this string.</p>
 
233
<h3 class="fn"><a name="operator-eq-2"></a>Q3CString &amp; Q3CString::operator= ( const <a href="qbytearray.html">QByteArray</a> &amp; <i>ba</i> )</h3>
 
234
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
235
<p>Assigns byte array <i>ba</i> to this <a href="q3cstring.html">Q3CString</a>.</p>
 
236
<h3 class="fn"><a name="operator-eq-3"></a>Q3CString &amp; Q3CString::operator= ( const char * <i>str</i> )</h3>
 
237
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
238
<p>Assigns a deep copy of <i>str</i> to this string and returns a reference to this string.</p>
 
239
<p>If <i>str</i> is 0 a null string is created.</p>
 
240
<p>See also <a href="qbytearray.html#isNull">isNull</a>().</p>
 
241
<hr />
 
242
<h2>Related Non-Members</h2>
 
243
<h3 class="fn"><a name="operator-not-eq-26"></a>bool operator!= ( const Q3CString &amp; <i>s1</i>, const Q3CString &amp; <i>s2</i> )</h3>
 
244
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
245
<p>Returns true if <i>s1</i> and <i>s2</i> are different; otherwise returns false.</p>
 
246
<p>Equivalent to qstrcmp(<i>s1</i>, <i>s2</i>) != 0.</p>
 
247
<h3 class="fn"><a name="operator-not-eq-31"></a>bool operator!= ( const Q3CString &amp; <i>s1</i>, const char * <i>s2</i> )</h3>
 
248
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
249
<p>Returns true if <i>s1</i> and <i>s2</i> are different; otherwise returns false.</p>
 
250
<p>Equivalent to qstrcmp(<i>s1</i>, <i>s2</i>) != 0.</p>
 
251
<h3 class="fn"><a name="operator-not-eq-32"></a>bool operator!= ( const char * <i>s1</i>, const Q3CString &amp; <i>s2</i> )</h3>
 
252
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
253
<p>Returns true if <i>s1</i> and <i>s2</i> are different; otherwise returns false.</p>
 
254
<p>Equivalent to qstrcmp(<i>s1</i>, <i>s2</i>) != 0.</p>
 
255
<h3 class="fn"><a name="operator-2b-13"></a>const Q3CString operator+ ( const Q3CString &amp; <i>s1</i>, const Q3CString &amp; <i>s2</i> )</h3>
 
256
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
257
<p>Returns a string which consists of the concatenation of <i>s1</i> and <i>s2</i>.</p>
 
258
<h3 class="fn"><a name="operator-2b-24"></a>const Q3CString operator+ ( const Q3CString &amp; <i>s1</i>, const char * <i>s2</i> )</h3>
 
259
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
260
<p>Returns a string which consists of the concatenation of <i>s1</i> and <i>s2</i>.</p>
 
261
<h3 class="fn"><a name="operator-2b-25"></a>const Q3CString operator+ ( const char * <i>s1</i>, const Q3CString &amp; <i>s2</i> )</h3>
 
262
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
263
<p>Returns a string which consists of the concatenation of <i>s1</i> and <i>s2</i>.</p>
 
264
<h3 class="fn"><a name="operator-2b-26"></a>const Q3CString operator+ ( const Q3CString &amp; <i>s</i>, char <i>c</i> )</h3>
 
265
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
266
<p>Returns a string which consists of the concatenation of <i>s</i> and <i>c</i>.</p>
 
267
<h3 class="fn"><a name="operator-2b-27"></a>const Q3CString operator+ ( char <i>c</i>, const Q3CString &amp; <i>s</i> )</h3>
 
268
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
269
<p>Returns a string which consists of the concatenation of <i>c</i> and <i>s</i>.</p>
 
270
<h3 class="fn"><a name="operator-lt-7"></a>bool operator&lt; ( const Q3CString &amp; <i>s1</i>, const char * <i>s2</i> )</h3>
 
271
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
272
<p>Returns true if <i>s1</i> is less than <i>s2</i>; otherwise returns false.</p>
 
273
<p>Equivalent to qstrcmp(<i>s1</i>, <i>s2</i>) &lt; 0.</p>
 
274
<h3 class="fn"><a name="operator-lt-12"></a>bool operator&lt; ( const char * <i>s1</i>, const Q3CString &amp; <i>s2</i> )</h3>
 
275
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
276
<p>Returns true if <i>s1</i> is less than <i>s2</i>; otherwise returns false.</p>
 
277
<p>Equivalent to qstrcmp(<i>s1</i>, <i>s2</i>) &lt; 0.</p>
 
278
<h3 class="fn"><a name="operator-lt-lt-85"></a><a href="qdatastream.html">QDataStream</a> &amp; operator&lt;&lt; ( <a href="qdatastream.html">QDataStream</a> &amp; <i>s</i>, const Q3CString &amp; <i>str</i> )</h3>
 
279
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
280
<p>Writes string <i>str</i> to the stream <i>s</i>.</p>
 
281
<p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>.</p>
 
282
<h3 class="fn"><a name="operator-lt-eq-7"></a>bool operator&lt;= ( const Q3CString &amp; <i>s1</i>, const char * <i>s2</i> )</h3>
 
283
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
284
<p>Returns true if <i>s1</i> is less than or equal to <i>s2</i>; otherwise returns false.</p>
 
285
<p>Equivalent to qstrcmp(<i>s1</i>, <i>s2</i>) &lt;= 0.</p>
 
286
<h3 class="fn"><a name="operator-lt-eq-12"></a>bool operator&lt;= ( const char * <i>s1</i>, const Q3CString &amp; <i>s2</i> )</h3>
 
287
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
288
<p>Returns true if <i>s1</i> is less than or equal to <i>s2</i>; otherwise returns false.</p>
 
289
<p>Equivalent to qstrcmp(<i>s1</i>, <i>s2</i>) &lt;= 0.</p>
 
290
<h3 class="fn"><a name="operator-eq-eq-36"></a>bool operator== ( const Q3CString &amp; <i>s1</i>, const Q3CString &amp; <i>s2</i> )</h3>
 
291
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
292
<p>Returns true if <i>s1</i> and <i>s2</i> are equal; otherwise returns false.</p>
 
293
<p>Equivalent to qstrcmp(<i>s1</i>, <i>s2</i>) == 0.</p>
 
294
<h3 class="fn"><a name="operator-eq-eq-41"></a>bool operator== ( const Q3CString &amp; <i>s1</i>, const char * <i>s2</i> )</h3>
 
295
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
296
<p>Returns true if <i>s1</i> and <i>s2</i> are equal; otherwise returns false.</p>
 
297
<p>Equivalent to qstrcmp(<i>s1</i>, <i>s2</i>) == 0.</p>
 
298
<h3 class="fn"><a name="operator-eq-eq-42"></a>bool operator== ( const char * <i>s1</i>, const Q3CString &amp; <i>s2</i> )</h3>
 
299
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
300
<p>Returns true if <i>s1</i> and <i>s2</i> are equal; otherwise returns false.</p>
 
301
<p>Equivalent to qstrcmp(<i>s1</i>, <i>s2</i>) == 0.</p>
 
302
<h3 class="fn"><a name="operator-gt-7"></a>bool operator&gt; ( const Q3CString &amp; <i>s1</i>, const char * <i>s2</i> )</h3>
 
303
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
304
<p>Returns true if <i>s1</i> is greater than <i>s2</i>; otherwise returns false.</p>
 
305
<p>Equivalent to qstrcmp(<i>s1</i>, <i>s2</i>) &gt; 0.</p>
 
306
<h3 class="fn"><a name="operator-gt-12"></a>bool operator&gt; ( const char * <i>s1</i>, const Q3CString &amp; <i>s2</i> )</h3>
 
307
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
308
<p>Returns true if <i>s1</i> is greater than <i>s2</i>; otherwise returns false.</p>
 
309
<p>Equivalent to qstrcmp(<i>s1</i>, <i>s2</i>) &gt; 0.</p>
 
310
<h3 class="fn"><a name="operator-gt-eq-7"></a>bool operator&gt;= ( const Q3CString &amp; <i>s1</i>, const char * <i>s2</i> )</h3>
 
311
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
312
<p>Returns true if <i>s1</i> is greater than or equal to <i>s2</i>; otherwise returns false.</p>
 
313
<p>Equivalent to qstrcmp(<i>s1</i>, <i>s2</i>) &gt;= 0.</p>
 
314
<h3 class="fn"><a name="operator-gt-eq-12"></a>bool operator&gt;= ( const char * <i>s1</i>, const Q3CString &amp; <i>s2</i> )</h3>
 
315
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
316
<p>Returns true if <i>s1</i> is greater than or equal to <i>s2</i>; otherwise returns false.</p>
 
317
<p>Equivalent to qstrcmp(<i>s1</i>, <i>s2</i>) &gt;= 0.</p>
 
318
<h3 class="fn"><a name="operator-gt-gt-57"></a><a href="qdatastream.html">QDataStream</a> &amp; operator&gt;&gt; ( <a href="qdatastream.html">QDataStream</a> &amp; <i>s</i>, Q3CString &amp; <i>str</i> )</h3>
 
319
<p>This is an overloaded member function, provided for convenience. It behaves essentially like the above function.</p>
 
320
<p>Reads a string into <i>str</i> from the stream <i>s</i>.</p>
 
321
<p>See also <a href="datastreamformat.html">Format of the QDataStream operators</a>.</p>
 
322
<p /><address><hr /><div align="center">
 
323
<table width="100%" cellspacing="0" border="0"><tr class="address">
 
324
<td width="30%">Copyright &copy; 2005 <a href="trolltech.html">Trolltech</a></td>
 
325
<td width="40%" align="center"><a href="trademarks.html">Trademarks</a></td>
 
326
<td width="30%" align="right"><div align="right">Qt 4.0.0</div></td>
 
327
</tr></table></div></address></body>
 
328
</html>