Reset the doc date to today for the automatic doc builds
[python.git] / Include / cStringIO.h
blob25fc9dd0d817f2c3b4e4d9bc199afac46b3fa71d
1 #ifndef Py_CSTRINGIO_H
2 #define Py_CSTRINGIO_H
3 #ifdef __cplusplus
4 extern "C" {
5 #endif
6 /*
8 This header provides access to cStringIO objects from C.
9 Functions are provided for calling cStringIO objects and
10 macros are provided for testing whether you have cStringIO
11 objects.
13 Before calling any of the functions or macros, you must initialize
14 the routines with:
16 PycString_IMPORT
18 This would typically be done in your init function.
21 #define PycString_IMPORT \
22 PycStringIO = (struct PycStringIO_CAPI*)PyCObject_Import("cStringIO", \
23 "cStringIO_CAPI")
25 /* Basic functions to manipulate cStringIO objects from C */
27 static struct PycStringIO_CAPI {
29 /* Read a string from an input object. If the last argument
30 is -1, the remainder will be read.
32 int(*cread)(PyObject *, char **, Py_ssize_t);
34 /* Read a line from an input object. Returns the length of the read
35 line as an int and a pointer inside the object buffer as char** (so
36 the caller doesn't have to provide its own buffer as destination).
38 int(*creadline)(PyObject *, char **);
40 /* Write a string to an output object*/
41 int(*cwrite)(PyObject *, const char *, Py_ssize_t);
43 /* Get the output object as a Python string (returns new reference). */
44 PyObject *(*cgetvalue)(PyObject *);
46 /* Create a new output object */
47 PyObject *(*NewOutput)(int);
49 /* Create an input object from a Python string
50 (copies the Python string reference).
52 PyObject *(*NewInput)(PyObject *);
54 /* The Python types for cStringIO input and output objects.
55 Note that you can do input on an output object.
57 PyTypeObject *InputType, *OutputType;
59 } *PycStringIO;
61 /* These can be used to test if you have one */
62 #define PycStringIO_InputCheck(O) \
63 ((O)->ob_type==PycStringIO->InputType)
64 #define PycStringIO_OutputCheck(O) \
65 ((O)->ob_type==PycStringIO->OutputType)
67 #ifdef __cplusplus
69 #endif
70 #endif /* !Py_CSTRINGIO_H */