17db96d56Sopenharmony_ci
27db96d56Sopenharmony_ci/* Bytes object interface */
37db96d56Sopenharmony_ci
47db96d56Sopenharmony_ci#ifndef Py_BYTESOBJECT_H
57db96d56Sopenharmony_ci#define Py_BYTESOBJECT_H
67db96d56Sopenharmony_ci#ifdef __cplusplus
77db96d56Sopenharmony_ciextern "C" {
87db96d56Sopenharmony_ci#endif
97db96d56Sopenharmony_ci
107db96d56Sopenharmony_ci#include <stdarg.h>               // va_list
117db96d56Sopenharmony_ci
127db96d56Sopenharmony_ci/*
137db96d56Sopenharmony_ciType PyBytesObject represents a byte string.  An extra zero byte is
147db96d56Sopenharmony_cireserved at the end to ensure it is zero-terminated, but a size is
157db96d56Sopenharmony_cipresent so strings with null bytes in them can be represented.  This
167db96d56Sopenharmony_ciis an immutable object type.
177db96d56Sopenharmony_ci
187db96d56Sopenharmony_ciThere are functions to create new bytes objects, to test
197db96d56Sopenharmony_cian object for bytes-ness, and to get the
207db96d56Sopenharmony_cibyte string value.  The latter function returns a null pointer
217db96d56Sopenharmony_ciif the object is not of the proper type.
227db96d56Sopenharmony_ciThere is a variant that takes an explicit size as well as a
237db96d56Sopenharmony_civariant that assumes a zero-terminated string.  Note that none of the
247db96d56Sopenharmony_cifunctions should be applied to NULL pointer.
257db96d56Sopenharmony_ci*/
267db96d56Sopenharmony_ci
277db96d56Sopenharmony_ciPyAPI_DATA(PyTypeObject) PyBytes_Type;
287db96d56Sopenharmony_ciPyAPI_DATA(PyTypeObject) PyBytesIter_Type;
297db96d56Sopenharmony_ci
307db96d56Sopenharmony_ci#define PyBytes_Check(op) \
317db96d56Sopenharmony_ci                 PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_BYTES_SUBCLASS)
327db96d56Sopenharmony_ci#define PyBytes_CheckExact(op) Py_IS_TYPE(op, &PyBytes_Type)
337db96d56Sopenharmony_ci
347db96d56Sopenharmony_ciPyAPI_FUNC(PyObject *) PyBytes_FromStringAndSize(const char *, Py_ssize_t);
357db96d56Sopenharmony_ciPyAPI_FUNC(PyObject *) PyBytes_FromString(const char *);
367db96d56Sopenharmony_ciPyAPI_FUNC(PyObject *) PyBytes_FromObject(PyObject *);
377db96d56Sopenharmony_ciPyAPI_FUNC(PyObject *) PyBytes_FromFormatV(const char*, va_list)
387db96d56Sopenharmony_ci                                Py_GCC_ATTRIBUTE((format(printf, 1, 0)));
397db96d56Sopenharmony_ciPyAPI_FUNC(PyObject *) PyBytes_FromFormat(const char*, ...)
407db96d56Sopenharmony_ci                                Py_GCC_ATTRIBUTE((format(printf, 1, 2)));
417db96d56Sopenharmony_ciPyAPI_FUNC(Py_ssize_t) PyBytes_Size(PyObject *);
427db96d56Sopenharmony_ciPyAPI_FUNC(char *) PyBytes_AsString(PyObject *);
437db96d56Sopenharmony_ciPyAPI_FUNC(PyObject *) PyBytes_Repr(PyObject *, int);
447db96d56Sopenharmony_ciPyAPI_FUNC(void) PyBytes_Concat(PyObject **, PyObject *);
457db96d56Sopenharmony_ciPyAPI_FUNC(void) PyBytes_ConcatAndDel(PyObject **, PyObject *);
467db96d56Sopenharmony_ciPyAPI_FUNC(PyObject *) PyBytes_DecodeEscape(const char *, Py_ssize_t,
477db96d56Sopenharmony_ci                                            const char *, Py_ssize_t,
487db96d56Sopenharmony_ci                                            const char *);
497db96d56Sopenharmony_ci
507db96d56Sopenharmony_ci/* Provides access to the internal data buffer and size of a bytes object.
517db96d56Sopenharmony_ci   Passing NULL as len parameter will force the string buffer to be
527db96d56Sopenharmony_ci   0-terminated (passing a string with embedded NUL characters will
537db96d56Sopenharmony_ci   cause an exception).  */
547db96d56Sopenharmony_ciPyAPI_FUNC(int) PyBytes_AsStringAndSize(
557db96d56Sopenharmony_ci    PyObject *obj,      /* bytes object */
567db96d56Sopenharmony_ci    char **s,           /* pointer to buffer variable */
577db96d56Sopenharmony_ci    Py_ssize_t *len     /* pointer to length variable or NULL */
587db96d56Sopenharmony_ci    );
597db96d56Sopenharmony_ci
607db96d56Sopenharmony_ci#ifndef Py_LIMITED_API
617db96d56Sopenharmony_ci#  define Py_CPYTHON_BYTESOBJECT_H
627db96d56Sopenharmony_ci#  include "cpython/bytesobject.h"
637db96d56Sopenharmony_ci#  undef Py_CPYTHON_BYTESOBJECT_H
647db96d56Sopenharmony_ci#endif
657db96d56Sopenharmony_ci
667db96d56Sopenharmony_ci#ifdef __cplusplus
677db96d56Sopenharmony_ci}
687db96d56Sopenharmony_ci#endif
697db96d56Sopenharmony_ci#endif /* !Py_BYTESOBJECT_H */
70