1 [section boost/python/str.hpp]
3 Exposes a [link concepts.objectwrapper.typewrapper_concept_requirements TypeWrapper] for the Python [@http://www.python.org/dev/doc/devel/lib/string-methods.html `str`] type.
6 Exposes the [@http://www.python.org/dev/doc/devel/lib/string-methods.html string methods] of Python's built-in `str` 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 [link concepts.objectwrapper.typewrapper_concept_requirements TypeWrapper] concept definition. Since str is publicly derived from [link object_wrappers.boost_python_object_hpp.class_object `object`], the public `object` interface applies to `str` instances as well.
8 namespace boost { namespace python
10 class str : public object
15 str(char const* s); // new str
17 str(char const* start, char const* finish); // new str
18 str(char const* start, std::size_t length); // new str
21 explicit str(T const& other);
23 str capitalize() const;
26 str center(T const& width) const;
29 long count(T const& sub) const;
30 template<class T1, class T2>
31 long count(T1 const& sub,T2 const& start) const;
32 template<class T1, class T2, class T3>
33 long count(T1 const& sub,T2 const& start, T3 const& end) const;
35 object decode() const;
37 object decode(T const& encoding) const;
38 template<class T1, class T2>
39 object decode(T1 const& encoding, T2 const& errors) const;
41 object encode() const;
43 object encode(T const& encoding) const;
44 template <class T1, class T2>
45 object encode(T1 const& encoding, T2 const& errors) const;
48 bool endswith(T const& suffix) const;
49 template <class T1, class T2>
50 bool endswith(T1 const& suffix, T2 const& start) const;
51 template <class T1, class T2, class T3>
52 bool endswith(T1 const& suffix, T2 const& start, T3 const& end) const;
54 str expandtabs() const;
56 str expandtabs(T const& tabsize) const;
59 long find(T const& sub) const;
60 template <class T1, class T2>
61 long find(T1 const& sub, T2 const& start) const;
62 template <class T1, class T2, class T3>
63 long find(T1 const& sub, T2 const& start, T3 const& end) const;
66 long index(T const& sub) const;
67 template <class T1, class T2>
68 long index(T1 const& sub, T2 const& start) const;
69 template <class T1, class T2, class T3>
70 long index(T1 const& sub, T2 const& start, T3 const& end) const;
81 str join(T const& sequence) const;
84 str ljust(T const& width) const;
89 template <class T1, class T2>
90 str replace(T1 const& old, T2 const& new_) const;
91 template <class T1, class T2, class T3>
92 str replace(T1 const& old, T2 const& new_, T3 const& maxsplit) const;
95 long rfind(T const& sub) const;
96 template <class T1, class T2>
97 long rfind(T1 const& sub, T2 const& start) const;
98 template <class T1, class T2, class T3>
99 long rfind(T1 const& sub, T2 const& start, T3 const& end) const;
102 long rindex(T const& sub) const;
103 template <class T1, class T2>
104 long rindex(T1 const& sub, T2 const& start) const;
105 template <class T1, class T2, class T3>
106 long rindex(T1 const& sub, T2 const& start, T3 const& end) const;
109 str rjust(T const& width) const;
115 list split(T const& sep) const;
116 template <class T1, class T2>
117 list split(T1 const& sep, T2 const& maxsplit) const;
119 list splitlines() const;
121 list splitlines(T const& keepends) const;
124 bool startswith(T const& prefix) const;
125 template <class T1, class T2>
126 bool startswidth(T1 const& prefix, T2 const& start) const;
127 template <class T1, class T2, class T3>
128 bool startswidth(T1 const& prefix, T2 const& start, T3 const& end) const;
131 str swapcase() const;
135 str translate(T const& table) const;
136 template <class T1, class T2>
137 str translate(T1 const& table, T2 const& deletechars) const;
146 using namespace boost::python;
147 str remove_angle_brackets(str x)
149 return x.strip('<').strip('>');