~ibmcharmers/charms/xenial/ibm-db2/trunk

« back to all changes in this revision

Viewing changes to .tox/py35/include/python3.5m/bytesobject.h

  • Committer: Rajith Venkata
  • Date: 2017-02-22 09:37:48 UTC
  • Revision ID: rajith.pv@in.ibm.com-20170222093748-fibtdsahuug31ra5
2ndcheckin for IBM-DB2 charm

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
 
 
2
/* Bytes (String) object interface */
 
3
 
 
4
#ifndef Py_BYTESOBJECT_H
 
5
#define Py_BYTESOBJECT_H
 
6
#ifdef __cplusplus
 
7
extern "C" {
 
8
#endif
 
9
 
 
10
#include <stdarg.h>
 
11
 
 
12
/*
 
13
Type PyBytesObject represents a character string.  An extra zero byte is
 
14
reserved at the end to ensure it is zero-terminated, but a size is
 
15
present so strings with null bytes in them can be represented.  This
 
16
is an immutable object type.
 
17
 
 
18
There are functions to create new string objects, to test
 
19
an object for string-ness, and to get the
 
20
string value.  The latter function returns a null pointer
 
21
if the object is not of the proper type.
 
22
There is a variant that takes an explicit size as well as a
 
23
variant that assumes a zero-terminated string.  Note that none of the
 
24
functions should be applied to nil objects.
 
25
*/
 
26
 
 
27
/* Caching the hash (ob_shash) saves recalculation of a string's hash value.
 
28
   This significantly speeds up dict lookups. */
 
29
 
 
30
#ifndef Py_LIMITED_API
 
31
typedef struct {
 
32
    PyObject_VAR_HEAD
 
33
    Py_hash_t ob_shash;
 
34
    char ob_sval[1];
 
35
 
 
36
    /* Invariants:
 
37
     *     ob_sval contains space for 'ob_size+1' elements.
 
38
     *     ob_sval[ob_size] == 0.
 
39
     *     ob_shash is the hash of the string or -1 if not computed yet.
 
40
     */
 
41
} PyBytesObject;
 
42
#endif
 
43
 
 
44
PyAPI_DATA(PyTypeObject) PyBytes_Type;
 
45
PyAPI_DATA(PyTypeObject) PyBytesIter_Type;
 
46
 
 
47
#define PyBytes_Check(op) \
 
48
                 PyType_FastSubclass(Py_TYPE(op), Py_TPFLAGS_BYTES_SUBCLASS)
 
49
#define PyBytes_CheckExact(op) (Py_TYPE(op) == &PyBytes_Type)
 
50
 
 
51
PyAPI_FUNC(PyObject *) PyBytes_FromStringAndSize(const char *, Py_ssize_t);
 
52
PyAPI_FUNC(PyObject *) PyBytes_FromString(const char *);
 
53
PyAPI_FUNC(PyObject *) PyBytes_FromObject(PyObject *);
 
54
PyAPI_FUNC(PyObject *) PyBytes_FromFormatV(const char*, va_list)
 
55
                                Py_GCC_ATTRIBUTE((format(printf, 1, 0)));
 
56
PyAPI_FUNC(PyObject *) PyBytes_FromFormat(const char*, ...)
 
57
                                Py_GCC_ATTRIBUTE((format(printf, 1, 2)));
 
58
PyAPI_FUNC(Py_ssize_t) PyBytes_Size(PyObject *);
 
59
PyAPI_FUNC(char *) PyBytes_AsString(PyObject *);
 
60
PyAPI_FUNC(PyObject *) PyBytes_Repr(PyObject *, int);
 
61
PyAPI_FUNC(void) PyBytes_Concat(PyObject **, PyObject *);
 
62
PyAPI_FUNC(void) PyBytes_ConcatAndDel(PyObject **, PyObject *);
 
63
#ifndef Py_LIMITED_API
 
64
PyAPI_FUNC(int) _PyBytes_Resize(PyObject **, Py_ssize_t);
 
65
PyAPI_FUNC(PyObject *) _PyBytes_Format(PyObject *, PyObject *);
 
66
#endif
 
67
PyAPI_FUNC(PyObject *) PyBytes_DecodeEscape(const char *, Py_ssize_t,
 
68
                                                   const char *, Py_ssize_t,
 
69
                                                   const char *);
 
70
 
 
71
/* Macro, trading safety for speed */
 
72
#ifndef Py_LIMITED_API
 
73
#define PyBytes_AS_STRING(op) (assert(PyBytes_Check(op)), \
 
74
                                (((PyBytesObject *)(op))->ob_sval))
 
75
#define PyBytes_GET_SIZE(op)  (assert(PyBytes_Check(op)),Py_SIZE(op))
 
76
#endif
 
77
 
 
78
/* _PyBytes_Join(sep, x) is like sep.join(x).  sep must be PyBytesObject*,
 
79
   x must be an iterable object. */
 
80
#ifndef Py_LIMITED_API
 
81
PyAPI_FUNC(PyObject *) _PyBytes_Join(PyObject *sep, PyObject *x);
 
82
#endif
 
83
 
 
84
/* Provides access to the internal data buffer and size of a string
 
85
   object or the default encoded version of a Unicode object. Passing
 
86
   NULL as *len parameter will force the string buffer to be
 
87
   0-terminated (passing a string with embedded NULL characters will
 
88
   cause an exception).  */
 
89
PyAPI_FUNC(int) PyBytes_AsStringAndSize(
 
90
    PyObject *obj,      /* string or Unicode object */
 
91
    char **s,           /* pointer to buffer variable */
 
92
    Py_ssize_t *len     /* pointer to length variable or NULL
 
93
                           (only possible for 0-terminated
 
94
                           strings) */
 
95
    );
 
96
 
 
97
/* Using the current locale, insert the thousands grouping
 
98
   into the string pointed to by buffer.  For the argument descriptions,
 
99
   see Objects/stringlib/localeutil.h */
 
100
#ifndef Py_LIMITED_API
 
101
PyAPI_FUNC(Py_ssize_t) _PyBytes_InsertThousandsGroupingLocale(char *buffer,
 
102
                                                   Py_ssize_t n_buffer,
 
103
                                                   char *digits,
 
104
                                                   Py_ssize_t n_digits,
 
105
                                                   Py_ssize_t min_width);
 
106
 
 
107
/* Using explicit passed-in values, insert the thousands grouping
 
108
   into the string pointed to by buffer.  For the argument descriptions,
 
109
   see Objects/stringlib/localeutil.h */
 
110
PyAPI_FUNC(Py_ssize_t) _PyBytes_InsertThousandsGrouping(char *buffer,
 
111
                                                   Py_ssize_t n_buffer,
 
112
                                                   char *digits,
 
113
                                                   Py_ssize_t n_digits,
 
114
                                                   Py_ssize_t min_width,
 
115
                                                   const char *grouping,
 
116
                                                   const char *thousands_sep);
 
117
#endif
 
118
 
 
119
/* Flags used by string formatting */
 
120
#define F_LJUST (1<<0)
 
121
#define F_SIGN  (1<<1)
 
122
#define F_BLANK (1<<2)
 
123
#define F_ALT   (1<<3)
 
124
#define F_ZERO  (1<<4)
 
125
 
 
126
#ifdef __cplusplus
 
127
}
 
128
#endif
 
129
#endif /* !Py_BYTESOBJECT_H */