Py11  v0.2
This is a minimalist Python wrapper for C++11.
py::str Class Reference

py str. More...

#include <py11/_str.hpp>

Inheritance diagram for py::str:
py::seq py::obj

Public Member Functions

 str ()=default
 ctor.
 
 str (PyObject *p, bool borrowed=false)
 create from Py functions. More...
 
 str (const char *s)
 ctor from char*.
 
 str (const char *s, Py_ssize_t len)
 ctor from char* with length.
 
 str (const char *fmt, const obj &o)
 ctor from format
 
stroperator= (const char *s)
 =
 
long size () const
 'len' as 'size'. More...
 
const char * c_str () const
 c_str(). More...
 
const str operator[] (Py_ssize_t i) const
 get item. More...
 
str sub (int i, int j=std::numeric_limits< int >::max()) const
 slice, [i:j]. More...
 
str operator+= (const obj &o)
 op +. More...
 
str operator% (const obj &o) const
 op %. More...
 
str decode (const str &s, const char *encoding, const char *errors)
 decode More...
 
str encode (const str &s, const char *encoding, const char *errors)
 encode More...
 
- Public Member Functions inherited from py::seq
 seq ()=default
 ctor.
 
 seq (PyObject *p, bool borrowed=false)
 create from Py functions. More...
 
 seq (std::initializer_list< obj > l)
 tuple.
 
seq operator+ (const obj &o) const
 op +. More...
 
seqoperator+= (const obj &o)
 op +=. More...
 
seq operator* (Py_ssize_t t) const
 op *. More...
 
seqoperator*= (Py_ssize_t t)
 op *=. More...
 
long size () const
 'len' as 'size'. More...
 
bool has (const obj &x) const
 'in' as 'has'. More...
 
long find (const obj &o) const
 seq find a item. More...
 
long index (const obj &o) const
 seq index. More...
 
list to_list () const
 get a list clone. More...
 
tuple to_tuple () const
 get a tuple clone. More...
 
const obj operator[] (Py_ssize_t i) const
 get item. More...
 
void set_item (Py_ssize_t i, const obj &value) const
 set_item. More...
 
void del_item (Py_ssize_t i)
 del_item. More...
 
obj sub (int i, int j=std::numeric_limits< int >::max()) const
 slice, [i:j]. More...
 
- Public Member Functions inherited from py::obj
 obj (const obj &o) noexcept
 copy ctor.
 
 obj (PyObject *p, bool borrowed=false) noexcept
 create from Py functions. More...
 
 obj (obj &&o) noexcept
 move ctor.
 
 obj (std::initializer_list< obj > l)
 tuple.
 
 ~obj () noexcept
 dtor.
 
void release () noexcept
 release the contained object
 
PyObject * transfer () noexcept
 transfer the ownership of inner object. More...
 
bool operator! () const
 test null.
 
 obj (int i)
 int.
 
 obj (long i)
 long.
 
bool is_int () const
 is_int.
 
long as_long () const
 get long from obj More...
 
 obj (double v)
 double ctor.
 
bool is_float () const
 is_float.
 
double as_double () const
 as_double from obj. More...
 
 obj (const char *s)
 str.
 
const char * c_str () const
 c_str(). More...
 
obj type () const
 py object type. More...
 
bool is_a (const obj &t) const
 type check More...
 
bool has_attr (const obj &o) const
 has attr.
 
bool has_attr (const char *s) const
 has attr.
 
obj attr (const obj &o) const
 get attr. More...
 
obj attr (const char *s) const
 get attr. More...
 
obj a (const char *s) const
 get attr, short form. More...
 
void set_attr (const obj &a, const obj &v)
 set attr. More...
 
void set_attr (const char *a, const obj &v)
 set attr. More...
 
void del_attr (const obj &a)
 del attr. More...
 
void del_attr (const char *a)
 del attr. More...
 
bool operator< (const obj &o) const
 < More...
 
obj repr () const
 repr. More...
 
obj to_str () const
 str. More...
 
obj to_unicode () const
 unicode. More...
 
bool is_callable () const
 test callable.
 
template<typename... argT>
obj operator() (argT &&...a) const
 call using operator. More...
 
obj call (const obj &args) const
 call with args. More...
 
obj call (const obj &args, const obj &kw) const
 call with args, and key/value pairs. More...
 
long size () const
 'len' as 'size'. More...
 
bool has (const obj &x) const
 'in' as 'has'. More...
 
const obj operator[] (const obj &o) const
 get item. More...
 
void set_item (const obj &key, const obj &value)
 set_item. More...
 
void del_item (const obj &key)
 del_item. More...
 
iter begin () const
 get the begin iter. More...
 
iter end () const
 get the end iter.
 
obj dir () const
 py object dir. More...
 
Py_ssize_t refcnt () const
 refcnt.
 
PPyObject p () const
 get inner PyObject.
 

Detailed Description

py str.

Definition at line 5 of file _str.hpp.

Constructor & Destructor Documentation

py::str::str ( PyObject *  p,
bool  borrowed = false 
)
inline

create from Py functions.

in most of cases, need not to inc ref. please read python doc carefully

Definition at line 61 of file _str.hpp.

References py::obj::p().

Member Function Documentation

const char* py::str::c_str ( ) const
inline

c_str().

Exceptions
type_err

Definition at line 142 of file _str.hpp.

References py::obj::p().

str py::str::decode ( const str s,
const char *  encoding,
const char *  errors 
)
inline

decode

Exceptions
val_err

Definition at line 197 of file _str.hpp.

References py::obj::p().

str py::str::encode ( const str s,
const char *  encoding,
const char *  errors 
)
inline

encode

Exceptions
val_err

Definition at line 209 of file _str.hpp.

References py::obj::p().

str py::str::operator% ( const obj o) const
inline

op %.

Exceptions
type_err

Definition at line 186 of file _str.hpp.

References py::obj::p().

str py::str::operator+= ( const obj o)
inline

op +.

Exceptions
type_err

Definition at line 175 of file _str.hpp.

References py::obj::p().

const str py::str::operator[] ( Py_ssize_t  i) const
inline

get item.

Warning, a new obj will be got! not a reference to the original one!

Exceptions
index_err

Definition at line 152 of file _str.hpp.

References py::obj::p().

long py::str::size ( ) const
inline

'len' as 'size'.

Exceptions
type_err

Definition at line 131 of file _str.hpp.

str py::str::sub ( int  i,
int  j = std::numeric_limits<int>::max() 
) const
inline

slice, [i:j].

Exceptions
type_err

Definition at line 164 of file _str.hpp.

References py::obj::p().


The documentation for this class was generated from the following file: