Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:06:48

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