summaryrefslogtreecommitdiff
path: root/libs/python/doc/v2/str.html
blob: 11810d841866867a5c082a165e8f650ee9bc1401 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<!-- Copyright David Abrahams 2006. Distributed under the Boost -->
<!-- Software License, Version 1.0. (See accompanying -->
<!-- file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) -->
<html>
  <head>
    <meta name="generator" content=
    "HTML Tidy for Windows (vers 1st August 2002), see www.w3.org">
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <link rel="stylesheet" type="text/css" href="../boost.css">

    <title>Boost.Python - &lt;boost/python/str.hpp&gt;</title>
  </head>

  <body>
    <table border="0" cellpadding="7" cellspacing="0" width="100%" summary=
    "header">
      <tr>
        <td valign="top" width="300">
          <h3><a href="../../../../index.htm"><img height="86" width="277"
          alt="C++ Boost" src="../../../../boost.png" border="0"></a></h3>
        </td>

        <td valign="top">
          <h1 align="center"><a href="../index.html">Boost.Python</a></h1>

          <h2 align="center">Header &lt;boost/python/str.hpp&gt;</h2>
        </td>
      </tr>
    </table>
    <hr>

    <h2>Contents</h2>

    <dl class="page-index">
      <dt><a href="#introduction">Introduction</a></dt>

      <dt><a href="#classes">Classes</a></dt>

      <dd>
        <dl class="page-index">
          <dt><a href="#str-spec">Class <code>str</code></a></dt>

          <dd>
            <dl class="page-index">
              <dt><a href="#str-spec-synopsis">Class <code>str</code>
              synopsis</a></dt>
            </dl>
          </dd>
        </dl>
      </dd>

      <dt><a href="#examples">Example(s)</a></dt>
    </dl>
    <hr>

    <h2><a name="introduction"></a>Introduction</h2>

    <p>Exposes a <a href=
    "ObjectWrapper.html#TypeWrapper-concept">TypeWrapper</a> for the Python
    <a href=
    "http://www.python.org/dev/doc/devel/lib/string-methods.html">str</a>
    type.</p>

    <h2><a name="classes"></a>Classes</h2>

    <h3><a name="str-spec"></a>Class <code>str</code></h3>

    <p>Exposes the <a href=
    "http://www.python.org/dev/doc/devel/lib/string-methods.html">string
    methods</a> of Python's built-in <code>str</code> type. The
    semantics of the constructors and member functions defined below,
    except for the two-argument constructors which construct str
    objects from a range of characters, can be fully understood by
    reading the <a href=
    "ObjectWrapper.html#TypeWrapper-concept">TypeWrapper</a> concept
    definition. Since <code>str</code> is publicly derived from
    <code><a href="object.html#object-spec">object</a></code>, the
    public object interface applies to <code>str</code> instances as
    well.</p>

    <h4><a name="str-spec-synopsis"></a>Class <code>str</code>
    synopsis</h4>
<pre>
namespace boost { namespace python
{
  class str : public object
  {
   public:
      str(); // new str

      str(char const* s); // new str

      str(char const* start, char const* finish); // new str
      str(char const* start, std::size_t length); // new str

      template &lt;class T&gt;
      explicit str(T const&amp; other);

      str capitalize() const;

      template &lt;class T&gt;
      str center(T const&amp; width) const;

      template&lt;class T&gt;
      long count(T const&amp; sub) const;
      template&lt;class T1, class T2&gt;
      long count(T1 const&amp; sub,T2 const&amp; start) const;
      template&lt;class T1, class T2, class T3&gt;
      long count(T1 const&amp; sub,T2 const&amp; start, T3 const&amp; end) const;

      object decode() const;
      template&lt;class T&gt;
      object decode(T const&amp; encoding) const;
      template&lt;class T1, class T2&gt;
      object decode(T1 const&amp; encoding, T2 const&amp; errors) const;

      object encode() const;
      template &lt;class T&gt;
      object encode(T const&amp; encoding) const;
      template &lt;class T1, class T2&gt;
      object encode(T1 const&amp; encoding, T2 const&amp; errors) const;

      template &lt;class T&gt;
      bool endswith(T const&amp; suffix) const;
      template &lt;class T1, class T2&gt;
      bool endswith(T1 const&amp; suffix, T2 const&amp; start) const;
      template &lt;class T1, class T2, class T3&gt;
      bool endswith(T1 const&amp; suffix, T2 const&amp; start, T3 const&amp; end) const;

      str expandtabs() const;
      template &lt;class T&gt;
      str expandtabs(T const&amp; tabsize) const;

      template &lt;class T&gt;
      long find(T const&amp; sub) const;
      template &lt;class T1, class T2&gt;
      long find(T1 const&amp; sub, T2 const&amp; start) const;
      template &lt;class T1, class T2, class T3&gt;
      long find(T1 const&amp; sub, T2 const&amp; start, T3 const&amp; end) const;

      template &lt;class T&gt;
      long index(T const&amp; sub) const;
      template &lt;class T1, class T2&gt;
      long index(T1 const&amp; sub, T2 const&amp; start) const;
      template &lt;class T1, class T2, class T3&gt;
      long index(T1 const&amp; sub, T2 const&amp; start, T3 const&amp; end) const;

      bool isalnum() const;
      bool isalpha() const;
      bool isdigit() const;
      bool islower() const;
      bool isspace() const;
      bool istitle() const;
      bool isupper() const;

      template &lt;class T&gt;
      str join(T const&amp; sequence) const;

      template &lt;class T&gt;
      str ljust(T const&amp; width) const;

      str lower() const;
      str lstrip() const;

      template &lt;class T1, class T2&gt;
      str replace(T1 const&amp; old, T2 const&amp; new_) const;
      template &lt;class T1, class T2, class T3&gt;
      str replace(T1 const&amp; old, T2 const&amp; new_, T3 const&amp; maxsplit) const;

      template &lt;class T&gt;
      long rfind(T const&amp; sub) const;
      template &lt;class T1, class T2&gt;
      long rfind(T1 const&amp; sub, T2 const&amp; start) const;
      template &lt;class T1, class T2, class T3&gt;
      long rfind(T1 const&amp; sub, T2 const&amp; start, T3 const&amp; end) const;

      template &lt;class T&gt;
      long rindex(T const&amp; sub) const;
      template &lt;class T1, class T2&gt;
      long rindex(T1 const&amp; sub, T2 const&amp; start) const;
      template &lt;class T1, class T2, class T3&gt;
      long rindex(T1 const&amp; sub, T2 const&amp; start, T3 const&amp; end) const;

      template &lt;class T&gt;
      str rjust(T const&amp; width) const;

      str rstrip() const;

      list split() const; 
      template &lt;class T&gt;
      list split(T const&amp; sep) const;
      template &lt;class T1, class T2&gt;
      list split(T1 const&amp; sep, T2 const&amp; maxsplit) const;

      list splitlines() const;
      template &lt;class T&gt;
      list splitlines(T const&amp; keepends) const;

      template &lt;class T&gt;
      bool startswith(T const&amp; prefix) const;
      template &lt;class T1, class T2&gt;
      bool startswidth(T1 const&amp; prefix, T2 const&amp; start) const;
      template &lt;class T1, class T2, class T3&gt;
      bool startswidth(T1 const&amp; prefix, T2 const&amp; start, T3 const&amp; end) const;

      str strip() const;
      str swapcase() const;
      str title() const;

      template &lt;class T&gt;
      str translate(T const&amp; table) const;
      template &lt;class T1, class T2&gt;
      str translate(T1 const&amp; table, T2 const&amp; deletechars) const;

      str upper() const;
  };
}}
</pre>

    <h2><a name="examples"></a>Example</h2>
<pre>
using namespace boost::python;
str remove_angle_brackets(str x)
{
  return x.strip('&lt;').strip('&gt;');
}
</pre>

    <p>Revised 3 October, 2002</p>

    <p><i>&copy; Copyright <a href=
    "http://www.boost.org/people/dave_abrahams.htm">Dave Abrahams</a> 2002.</i></p>
  </body>
</html>