deimos.python.stringobject

Mirrors stringobject.h

Type PyStringObject represents a character string. An extra zero byte is reserved at the end to ensure it is zero-terminated, but a size is present so strings with null bytes in them can be represented. This is an immutable object type.

There are functions to create new string objects, to test an object for string-ness, and to get the string value. The latter function returns a null pointer if the object is not of the proper type. There is a variant that takes an explicit size as well as a variant that assumes a zero-terminated string. Note that none of the functions should be applied to nil objects.

Note stringobject goes away in python 3 (well, sort of; it gets moved to bytesobject.h - look there for portability)

Members

Functions

PyString_AS_STRING
const(char)* PyString_AS_STRING(PyObject* op)

Macro, trading safety for speed Availability: 2.*

PyString_AsDecodedObject
PyObject* PyString_AsDecodedObject(PyObject* str, const(char)* encoding, const(char)* errors)

Availability: 2.*

PyString_AsEncodedObject
PyObject* PyString_AsEncodedObject(PyObject* str, const(char)* encoding, const(char)* errors)

Availability: 2.*

PyString_AsString
const(char)* PyString_AsString(PyObject* )

Availability: 2.*

PyString_AsStringAndSize
int PyString_AsStringAndSize(PyObject* obj, char** s, Py_ssize_t* len)

Availability: 2.*

PyString_CHECK_INTERNED
int PyString_CHECK_INTERNED(PyObject* op)

Use only if you know it's a string Availability: 2.*

PyString_Check
int PyString_Check(PyObject* op)

Availability: 2.*

PyString_CheckExact
int PyString_CheckExact(PyObject* op)

Availability: 2.*

PyString_Concat
void PyString_Concat(PyObject** , PyObject* )

Availability: 2.*

PyString_ConcatAndDel
void PyString_ConcatAndDel(PyObject** , PyObject* )

Availability: 2.*

PyString_Decode
PyObject* PyString_Decode(const(char)* s, Py_ssize_t size, const(char)* encoding, const(char)* errors)

Availability: 2.*

PyString_DecodeEscape
PyObject* PyString_DecodeEscape(const(char)* , Py_ssize_t , const(char)* , Py_ssize_t , const(char)* )

Availability: 2.*

PyString_Encode
PyObject* PyString_Encode(const(char)* s, Py_ssize_t size, const(char)* encoding, const(char)* errors)

Availability: 2.*

PyString_Format
PyObject* PyString_Format(PyObject* , PyObject* )

Availability: 2.*

PyString_FromFormat
PyObject* PyString_FromFormat(const(char)* , ...)

Availability: 2.*

PyString_FromFormatV
PyObject* PyString_FromFormatV(const(char)* , va_list )

Availability: 2.*

PyString_FromString
PyObject* PyString_FromString(const(char)* )

For PyString_FromString(), the parameter `str' points to a null-terminated string containing exactly `size' bytes.

PyString_FromStringAndSize
PyObject* PyString_FromStringAndSize(const(char)* , Py_ssize_t )

For PyString_FromString(), the parameter `str' points to a null-terminated string containing exactly `size' bytes.

PyString_GET_SIZE
Py_ssize_t PyString_GET_SIZE(PyObject* op)

Availability: 2.*

PyString_InternFromString
PyObject* PyString_InternFromString(const(char)* )

Availability: 2.*

PyString_InternImmortal
void PyString_InternImmortal(PyObject** )

Availability: 2.*

PyString_InternInPlace
void PyString_InternInPlace(PyObject** )

Availability: 2.*

PyString_Repr
PyObject* PyString_Repr(PyObject* , int )

Availability: 2.*

PyString_Size
Py_ssize_t PyString_Size(PyObject* )

Availability: 2.*

_PyBytes_FormatAdvanced
PyObject* _PyBytes_FormatAdvanced(PyObject* obj, char* format_spec, Py_ssize_t format_spec_len)

Format the object based on the format_spec, as defined in PEP 3101 Availability: 2.6, 2.7 (Advanced String Formatting).

_PyString_Eq
int _PyString_Eq(PyObject* , PyObject* )

Availability: 2.*

_PyString_FormatLong
PyObject* _PyString_FormatLong(PyObject* , int , int , int , char** , int* )

Availability: 2.*

_PyString_InsertThousandsGrouping
int _PyString_InsertThousandsGrouping(char* buffer, Py_ssize_t n_buffer, Py_ssize_t n_digits, Py_ssize_t buf_size, Py_ssize_t* count, int append_zero_char)

Using the current locale, insert the thousands grouping into the string pointed to by buffer. For the argument descriptions, Availability: 2.6, 2.7 see Objects/stringlib/localeutil.h

_PyString_Join
PyObject* _PyString_Join(PyObject* sep, PyObject* x)

Availability: 2.*

_PyString_Resize
int _PyString_Resize(PyObject** , Py_ssize_t )

Availability: 2.*

Structs

PyStringObject
struct PyStringObject

Invariants: ob_sval contains space for 'ob_size+1' elements. ob_svalob_size == 0. ob_shash is the hash of the string or -1 if not computed yet. ob_sstate != 0 iff the string object is in stringobject.c's 'interned' dictionary; in this case the two references from 'interned' to this object are *not counted* in ob_refcnt.

Meta