Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-11-19 09:50:53

0001 // Bytes object interface
0002 
0003 #ifndef Py_BYTESOBJECT_H
0004 #define Py_BYTESOBJECT_H
0005 #ifdef __cplusplus
0006 extern "C" {
0007 #endif
0008 
0009 /*
0010 Type PyBytesObject represents a byte string.  An extra zero byte is
0011 reserved at the end to ensure it is zero-terminated, but a size is
0012 present so strings with null bytes in them can be represented.  This
0013 is an immutable object type.
0014 
0015 There are functions to create new bytes objects, to test
0016 an object for bytes-ness, and to get the
0017 byte string value.  The latter function returns a null pointer
0018 if the object is not of the proper type.
0019 There is a variant that takes an explicit size as well as a
0020 variant that assumes a zero-terminated string.  Note that none of the
0021 functions should be applied to NULL pointer.
0022 */
0023 
0024 PyAPI_DATA(PyTypeObject) PyBytes_Type;
0025 PyAPI_DATA(PyTypeObject) PyBytesIter_Type;
0026 
0027 #define PyBytes_Check(op) \
0028                  PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_BYTES_SUBCLASS)
0029 #define PyBytes_CheckExact(op) Py_IS_TYPE((op), &PyBytes_Type)
0030 
0031 PyAPI_FUNC(PyObject *) PyBytes_FromStringAndSize(const char *, Py_ssize_t);
0032 PyAPI_FUNC(PyObject *) PyBytes_FromString(const char *);
0033 PyAPI_FUNC(PyObject *) PyBytes_FromObject(PyObject *);
0034 PyAPI_FUNC(PyObject *) PyBytes_FromFormatV(const char*, va_list)
0035                                 Py_GCC_ATTRIBUTE((format(printf, 1, 0)));
0036 PyAPI_FUNC(PyObject *) PyBytes_FromFormat(const char*, ...)
0037                                 Py_GCC_ATTRIBUTE((format(printf, 1, 2)));
0038 PyAPI_FUNC(Py_ssize_t) PyBytes_Size(PyObject *);
0039 PyAPI_FUNC(char *) PyBytes_AsString(PyObject *);
0040 PyAPI_FUNC(PyObject *) PyBytes_Repr(PyObject *, int);
0041 PyAPI_FUNC(void) PyBytes_Concat(PyObject **, PyObject *);
0042 PyAPI_FUNC(void) PyBytes_ConcatAndDel(PyObject **, PyObject *);
0043 PyAPI_FUNC(PyObject *) PyBytes_DecodeEscape(const char *, Py_ssize_t,
0044                                             const char *, Py_ssize_t,
0045                                             const char *);
0046 
0047 /* Provides access to the internal data buffer and size of a bytes object.
0048    Passing NULL as len parameter will force the string buffer to be
0049    0-terminated (passing a string with embedded NUL characters will
0050    cause an exception).  */
0051 PyAPI_FUNC(int) PyBytes_AsStringAndSize(
0052     PyObject *obj,      /* bytes object */
0053     char **s,           /* pointer to buffer variable */
0054     Py_ssize_t *len     /* pointer to length variable or NULL */
0055     );
0056 
0057 #ifndef Py_LIMITED_API
0058 #  define Py_CPYTHON_BYTESOBJECT_H
0059 #  include "cpython/bytesobject.h"
0060 #  undef Py_CPYTHON_BYTESOBJECT_H
0061 #endif
0062 
0063 #ifdef __cplusplus
0064 }
0065 #endif
0066 #endif /* !Py_BYTESOBJECT_H */