Imported Upstream version 0.60.7
[platform/upstream/aspell.git] / manual / aspell-dev.html / Strings.html
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
2 <html>
3 <!-- This is the developer's manual for Aspell.
4
5 Copyright © 2002, 2003, 2004, 2006 Kevin Atkinson.
6
7 Permission is granted to copy, distribute and/or modify this document
8 under the terms of the GNU Free Documentation License, Version 1.1 or
9 any later version published by the Free Software Foundation; with no
10 Invariant Sections, no Front-Cover Texts and no Back-Cover Texts.  A
11 copy of the license is included in the section entitled "GNU Free
12 Documentation License". -->
13 <!-- Created by GNU Texinfo 5.2, http://www.gnu.org/software/texinfo/ -->
14 <head>
15 <title>Aspell Developer&rsquo;s Manual: Strings</title>
16
17 <meta name="description" content="Aspell spell checker developer&rsquo;s manual.">
18 <meta name="keywords" content="Aspell Developer&rsquo;s Manual: Strings">
19 <meta name="resource-type" content="document">
20 <meta name="distribution" content="global">
21 <meta name="Generator" content="makeinfo">
22 <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
23 <link href="index.html#Top" rel="start" title="Top">
24 <link href="index.html#SEC_Contents" rel="contents" title="Table of Contents">
25 <link href="index.html#Top" rel="up" title="Top">
26 <link href="Smart-Pointers.html#Smart-Pointers" rel="next" title="Smart Pointers">
27 <link href="Source-Code-Layout.html#Source-Code-Layout" rel="prev" title="Source Code Layout">
28 <style type="text/css">
29 <!--
30 a.summary-letter {text-decoration: none}
31 blockquote.smallquotation {font-size: smaller}
32 div.display {margin-left: 3.2em}
33 div.example {margin-left: 3.2em}
34 div.indentedblock {margin-left: 3.2em}
35 div.lisp {margin-left: 3.2em}
36 div.smalldisplay {margin-left: 3.2em}
37 div.smallexample {margin-left: 3.2em}
38 div.smallindentedblock {margin-left: 3.2em; font-size: smaller}
39 div.smalllisp {margin-left: 3.2em}
40 kbd {font-style:oblique}
41 pre.display {font-family: inherit}
42 pre.format {font-family: inherit}
43 pre.menu-comment {font-family: serif}
44 pre.menu-preformatted {font-family: serif}
45 pre.smalldisplay {font-family: inherit; font-size: smaller}
46 pre.smallexample {font-size: smaller}
47 pre.smallformat {font-family: inherit; font-size: smaller}
48 pre.smalllisp {font-size: smaller}
49 span.nocodebreak {white-space:nowrap}
50 span.nolinebreak {white-space:nowrap}
51 span.roman {font-family:serif; font-weight:normal}
52 span.sansserif {font-family:sans-serif; font-weight:normal}
53 ul.no-bullet {list-style: none}
54 -->
55 </style>
56
57
58 </head>
59
60 <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
61 <a name="Strings"></a>
62 <div class="header">
63 <p>
64 Next: <a href="Smart-Pointers.html#Smart-Pointers" accesskey="n" rel="next">Smart Pointers</a>, Previous: <a href="Source-Code-Layout.html#Source-Code-Layout" accesskey="p" rel="prev">Source Code Layout</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p>
65 </div>
66 <hr>
67 <a name="Strings-1"></a>
68 <h2 class="chapter">7 Strings</h2>
69
70 <a name="String"></a>
71 <h3 class="section">7.1 String</h3>
72
73 <p>The <code>String</code> class provided the same functionality of the C++
74 string except for fewer constructors.  It also inherits <code>OStream</code>
75 so that you can write to it with the <code>&lt;&lt;</code> operator.  It is
76 defined in <code>string.hpp</code>.
77 </p>
78 <a name="ParmString"></a>
79 <h3 class="section">7.2 ParmString</h3>
80
81 <p>ParmString is a special string class that is designed to be used as a
82 parameter for a function that is expecting a string.  It is defined in
83 <code>parm_string.hpp</code>.  It will allow either a <code>const char *</code> or
84 <code>String</code> class to be passed in.  It will automatically convert to
85 a <code>const char *</code>.  The string can also be accessed via the
86 <code>str</code> method.  Usage example:
87 </p><pre class="verbatim">void foo(ParmString s1, ParmString s2) {
88    const char * str0 = s1;
89    unsigned int size0 = s2.size()
90    if (s1 == s2 || s2 == &quot;bar&quot;) {
91      ...
92    }
93 }
94 ...
95 String s1 = &quot;...&quot;;
96 foo(s1);
97 const char * s2 = &quot;...&quot;;
98 foo(s2);
99 </pre>
100 <p>This class should be used when a string is being passed in as a
101 parameter.  It is faster than using <code>const String &amp;</code> (as that
102 will create an unnecessary temporary when a <code>const char *</code> is
103 passed in), and is less annoying than using <code>const char *</code> (as it
104 doesn&rsquo;t require the <code>c_str()</code> method to be used when a
105 <code>String</code> is passed in).
106 </p>
107 <a name="CharVector"></a>
108 <h3 class="section">7.3 CharVector</h3>
109
110 <p>A character vector is basically a <code>Vector&lt;char&gt;</code> but it has a few
111 additional methods for dealing with strings which <code>Vector</code> does
112 not provide.  It, like <code>String</code>, is also inherits <code>OStream</code>
113 so that you can write to it with the <code>&lt;&lt;</code> operator.  It is
114 defined in <code>char_vector.hpp</code>.  Use it when ever you need a string
115 which is guaranteed to be in a continuous block of memory which you
116 can write to.
117 </p>
118 <hr>
119 <div class="header">
120 <p>
121 Next: <a href="Smart-Pointers.html#Smart-Pointers" accesskey="n" rel="next">Smart Pointers</a>, Previous: <a href="Source-Code-Layout.html#Source-Code-Layout" accesskey="p" rel="prev">Source Code Layout</a>, Up: <a href="index.html#Top" accesskey="u" rel="up">Top</a> &nbsp; [<a href="index.html#SEC_Contents" title="Table of contents" rel="contents">Contents</a>]</p>
122 </div>
123
124
125
126 </body>
127 </html>