149fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters/* cursor.h - definitions for the cursor type
249fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters *
3c934f32e0a2b5f9f2bc0b55573a6860626025d63Florent Xicluna * Copyright (C) 2004-2010 Gerhard Häring <gh@ghaering.de>
449fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters *
549fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters * This file is part of pysqlite.
649fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters *
749fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters * This software is provided 'as-is', without any express or implied
849fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters * warranty.  In no event will the authors be held liable for any damages
949fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters * arising from the use of this software.
1049fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters *
1149fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters * Permission is granted to anyone to use this software for any purpose,
1249fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters * including commercial applications, and to alter it and redistribute it
1349fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters * freely, subject to the following restrictions:
1449fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters *
1549fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters * 1. The origin of this software must not be misrepresented; you must not
1649fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters *    claim that you wrote the original software. If you use this software
1749fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters *    in a product, an acknowledgment in the product documentation would be
1849fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters *    appreciated but is not required.
1949fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters * 2. Altered source versions must be plainly marked as such, and must not be
2049fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters *    misrepresented as being the original software.
2149fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters * 3. This notice may not be removed or altered from any source distribution.
2249fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters */
2349fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters
2449fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters#ifndef PYSQLITE_CURSOR_H
2549fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters#define PYSQLITE_CURSOR_H
2649fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters#include "Python.h"
2749fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters
2849fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters#include "statement.h"
2949fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters#include "connection.h"
3049fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters#include "module.h"
3149fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters
3249fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouterstypedef struct
3349fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters{
3449fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters    PyObject_HEAD
35fc7bb8c786fd9cb3b1ab84e1976620d0ab545777Thomas Wouters    pysqlite_Connection* connection;
3649fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters    PyObject* description;
3749fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters    PyObject* row_cast_map;
3849fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters    int arraysize;
3949fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters    PyObject* lastrowid;
40f78e02b79862ac555fe052240bda55fa770a2d6fGeorg Brandl    long rowcount;
4149fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters    PyObject* row_factory;
42fc7bb8c786fd9cb3b1ab84e1976620d0ab545777Thomas Wouters    pysqlite_Statement* statement;
43f9cee224461273307ca9f8a0e690a527496534abGerhard Häring    int closed;
44f9cee224461273307ca9f8a0e690a527496534abGerhard Häring    int reset;
45936d518dc8fb8fb094de1391d5a0703287db694eGerhard Haering    int locked;
46f9cee224461273307ca9f8a0e690a527496534abGerhard Häring    int initialized;
4749fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters
4849fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters    /* the next row to be returned, NULL if no next row available */
4949fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters    PyObject* next_row;
50f9cee224461273307ca9f8a0e690a527496534abGerhard Häring
51f9cee224461273307ca9f8a0e690a527496534abGerhard Häring    PyObject* in_weakreflist; /* List of weak references */
52fc7bb8c786fd9cb3b1ab84e1976620d0ab545777Thomas Wouters} pysqlite_Cursor;
5349fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters
54fc7bb8c786fd9cb3b1ab84e1976620d0ab545777Thomas Woutersextern PyTypeObject pysqlite_CursorType;
5549fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters
56fc7bb8c786fd9cb3b1ab84e1976620d0ab545777Thomas WoutersPyObject* pysqlite_cursor_execute(pysqlite_Cursor* self, PyObject* args);
57fc7bb8c786fd9cb3b1ab84e1976620d0ab545777Thomas WoutersPyObject* pysqlite_cursor_executemany(pysqlite_Cursor* self, PyObject* args);
58fc7bb8c786fd9cb3b1ab84e1976620d0ab545777Thomas WoutersPyObject* pysqlite_cursor_getiter(pysqlite_Cursor *self);
59fc7bb8c786fd9cb3b1ab84e1976620d0ab545777Thomas WoutersPyObject* pysqlite_cursor_iternext(pysqlite_Cursor *self);
60fc7bb8c786fd9cb3b1ab84e1976620d0ab545777Thomas WoutersPyObject* pysqlite_cursor_fetchone(pysqlite_Cursor* self, PyObject* args);
61e7ea7451a84636655927da4b9731d2eb37d1cf34Gerhard HäringPyObject* pysqlite_cursor_fetchmany(pysqlite_Cursor* self, PyObject* args, PyObject* kwargs);
62fc7bb8c786fd9cb3b1ab84e1976620d0ab545777Thomas WoutersPyObject* pysqlite_cursor_fetchall(pysqlite_Cursor* self, PyObject* args);
63fc7bb8c786fd9cb3b1ab84e1976620d0ab545777Thomas WoutersPyObject* pysqlite_noop(pysqlite_Connection* self, PyObject* args);
64fc7bb8c786fd9cb3b1ab84e1976620d0ab545777Thomas WoutersPyObject* pysqlite_cursor_close(pysqlite_Cursor* self, PyObject* args);
6549fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters
66fc7bb8c786fd9cb3b1ab84e1976620d0ab545777Thomas Woutersint pysqlite_cursor_setup_types(void);
6749fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters
6849fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters#define UNKNOWN (-1)
6949fd7fa4431da299196d74087df4a04f99f9c46fThomas Wouters#endif
70