Imported Upstream version 0.60.8
[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 table:not([class]), table:not([class]) th, table:not([class]) td {
55     padding: 2px 0.3em 2px 0.3em;
56     border: thin solid #D0D0D0;
57     border-collapse: collapse;
58 }
59
60 -->
61 </style>
62
63 <meta name=viewport content="width=device-width, initial-scale=1">
64 </head>
65
66 <body lang="en" bgcolor="#FFFFFF" text="#000000" link="#0000FF" vlink="#800080" alink="#FF0000">
67 <a name="Strings"></a>
68 <div class="header">
69 <p>
70 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>
71 </div>
72 <hr>
73 <a name="Strings-1"></a>
74 <h2 class="chapter">7 Strings</h2>
75
76 <a name="String"></a>
77 <h3 class="section">7.1 String</h3>
78
79 <p>The <code>String</code> class provided the same functionality of the C++
80 string except for fewer constructors.  It also inherits <code>OStream</code>
81 so that you can write to it with the <code>&lt;&lt;</code> operator.  It is
82 defined in <code>string.hpp</code>.
83 </p>
84 <a name="ParmString"></a>
85 <h3 class="section">7.2 ParmString</h3>
86
87 <p>ParmString is a special string class that is designed to be used as a
88 parameter for a function that is expecting a string.  It is defined in
89 <code>parm_string.hpp</code>.  It will allow either a <code>const char *</code> or
90 <code>String</code> class to be passed in.  It will automatically convert to
91 a <code>const char *</code>.  The string can also be accessed via the
92 <code>str</code> method.  Usage example:
93 </p><pre class="verbatim">void foo(ParmString s1, ParmString s2) {
94    const char * str0 = s1;
95    unsigned int size0 = s2.size()
96    if (s1 == s2 || s2 == &quot;bar&quot;) {
97      ...
98    }
99 }
100 ...
101 String s1 = &quot;...&quot;;
102 foo(s1);
103 const char * s2 = &quot;...&quot;;
104 foo(s2);
105 </pre>
106 <p>This class should be used when a string is being passed in as a
107 parameter.  It is faster than using <code>const String &amp;</code> (as that
108 will create an unnecessary temporary when a <code>const char *</code> is
109 passed in), and is less annoying than using <code>const char *</code> (as it
110 doesn&rsquo;t require the <code>c_str()</code> method to be used when a
111 <code>String</code> is passed in).
112 </p>
113 <a name="CharVector"></a>
114 <h3 class="section">7.3 CharVector</h3>
115
116 <p>A character vector is basically a <code>Vector&lt;char&gt;</code> but it has a few
117 additional methods for dealing with strings which <code>Vector</code> does
118 not provide.  It, like <code>String</code>, is also inherits <code>OStream</code>
119 so that you can write to it with the <code>&lt;&lt;</code> operator.  It is
120 defined in <code>char_vector.hpp</code>.  Use it when ever you need a string
121 which is guaranteed to be in a continuous block of memory which you
122 can write to.
123 </p>
124 <hr>
125 <div class="header">
126 <p>
127 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>
128 </div>
129
130
131
132 </body>
133 </html>