Imported Upstream version 0.60.6.1
[platform/upstream/aspell.git] / manual / aspell-dev.html / Strings.html
1 <html lang="en">
2 <head>
3 <title>Strings - Aspell Developer's Manual</title>
4 <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
5 <meta name="description" content="Aspell spell checker developer's manual.">
6 <meta name="generator" content="makeinfo 4.8">
7 <link title="Top" rel="start" href="index.html#Top">
8 <link rel="prev" href="Source-Code-Layout.html#Source-Code-Layout" title="Source Code Layout">
9 <link rel="next" href="Smart-Pointers.html#Smart-Pointers" title="Smart Pointers">
10 <link href="http://www.gnu.org/software/texinfo/" rel="generator-home" title="Texinfo Homepage">
11 <!--
12 This is the developer's manual for Aspell.
13
14 Copyright (C) 2002, 2003, 2004, 2006 Kevin Atkinson.
15
16      Permission is granted to copy, distribute and/or modify this
17      document under the terms of the GNU Free Documentation License,
18      Version 1.1 or any later version published by the Free Software
19      Foundation; with no Invariant Sections, no Front-Cover Texts and
20      no Back-Cover Texts.  A copy of the license is included in the
21      section entitled "GNU Free Documentation License".
22    -->
23 <meta http-equiv="Content-Style-Type" content="text/css">
24 <style type="text/css"><!--
25   pre.display { font-family:inherit }
26   pre.format  { font-family:inherit }
27   pre.smalldisplay { font-family:inherit; font-size:smaller }
28   pre.smallformat  { font-family:inherit; font-size:smaller }
29   pre.smallexample { font-size:smaller }
30   pre.smalllisp    { font-size:smaller }
31   span.sc    { font-variant:small-caps }
32   span.roman { font-family:serif; font-weight:normal; } 
33   span.sansserif { font-family:sans-serif; font-weight:normal; } 
34 --></style>
35 </head>
36 <body>
37 <div class="node">
38 <p>
39 <a name="Strings"></a>
40 Next:&nbsp;<a rel="next" accesskey="n" href="Smart-Pointers.html#Smart-Pointers">Smart Pointers</a>,
41 Previous:&nbsp;<a rel="previous" accesskey="p" href="Source-Code-Layout.html#Source-Code-Layout">Source Code Layout</a>,
42 Up:&nbsp;<a rel="up" accesskey="u" href="index.html#Top">Top</a>
43 <hr>
44 </div>
45
46 <h2 class="chapter">7 Strings</h2>
47
48 <h3 class="section">7.1 String</h3>
49
50 <p>The <code>String</code> class provided the same functionality of the C++
51 string except for fewer constructors.  It also inherits <code>OStream</code>
52 so that you can write to it with the <code>&lt;&lt;</code> operator.  It is
53 defined in <code>string.hpp</code>.
54
55 <h3 class="section">7.2 ParmString</h3>
56
57 <p>ParmString is a special string class that is designed to be used as a
58 parameter for a function that is expecting a string.  It is defined in
59 <code>parm_string.hpp</code>.  It will allow either a <code>const char *</code> or
60 <code>String</code> class to be passed in.  It will automatically convert to
61 a <code>const char *</code>.  The string can also be accessed via the
62 <code>str</code> method.  Usage example:
63 <pre class="verbatim">
64 void foo(ParmString s1, ParmString s2) {
65    const char * str0 = s1;
66    unsigned int size0 = s2.size()
67    if (s1 == s2 || s2 == "bar") {
68      ...
69    }
70 }
71 ...
72 String s1 = "...";
73 foo(s1);
74 const char * s2 = "...";
75 foo(s2);
76 </pre>
77
78    <p>This class should be used when a string is being passed in as a
79 parameter.  It is faster than using <code>const String &amp;</code> (as that
80 will create an unnecessary temporary when a <code>const char *</code> is
81 passed in), and is less annoying than using <code>const char *</code> (as it
82 doesn't require the <code>c_str()</code> method to be used when a
83 <code>String</code> is passed in).
84
85 <h3 class="section">7.3 CharVector</h3>
86
87 <p>A character vector is basically a <code>Vector&lt;char&gt;</code> but it has a few
88 additional methods for dealing with strings which <code>Vector</code> does
89 not provide.  It, like <code>String</code>, is also inherits <code>OStream</code>
90 so that you can write to it with the <code>&lt;&lt;</code> operator.  It is
91 defined in <code>char_vector.hpp</code>.  Use it when ever you need a string
92 which is guaranteed to be in a continuous block of memory which you
93 can write to.
94
95    </body></html>
96