kexi

kexidbcursor.cpp

00001 /***************************************************************************
00002  * kexidbcursor.cpp
00003  * This file is part of the KDE project
00004  * copyright (C)2004-2005 by Sebastian Sauer (mail@dipe.org)
00005  *
00006  * This program is free software; you can redistribute it and/or
00007  * modify it under the terms of the GNU Library General Public
00008  * License as published by the Free Software Foundation; either
00009  * version 2 of the License, or (at your option) any later version.
00010  * This program is distributed in the hope that it will be useful,
00011  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00012  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013  * Library General Public License for more details.
00014  * You should have received a copy of the GNU Library General Public License
00015  * along with this program; see the file COPYING.  If not, write to
00016  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
00017  * Boston, MA 02110-1301, USA.
00018  ***************************************************************************/
00019 
00020 #include "kexidbcursor.h"
00021 #include "kexidbconnection.h"
00022 
00023 #include <kdebug.h>
00024 
00025 using namespace Kross::KexiDB;
00026 
00027 KexiDBCursor::KexiDBCursor(KexiDBConnection* connection, ::KexiDB::Cursor* cursor)
00028     : Kross::Api::Class<KexiDBCursor>("KexiDBCursor", connection)
00029     , m_cursor(cursor)
00030 {
00031     // Opens the cursor.
00032     this->addProxyFunction< Kross::Api::ProxyValue<Kross::Api::Variant,bool> >
00033         ("open", m_cursor, &::KexiDB::Cursor::open );
00034 
00035     // Returns true if the cursor is opened else false.
00036     this->addProxyFunction< Kross::Api::ProxyValue<Kross::Api::Variant,bool> >
00037         ("isOpened", m_cursor, &::KexiDB::Cursor::isOpened );
00038 
00039     // Closes and then opens again the same cursor.
00040     this->addProxyFunction< Kross::Api::ProxyValue<Kross::Api::Variant,bool> >
00041         ("reopen", m_cursor, &::KexiDB::Cursor::reopen );
00042 
00043     // Closes previously opened cursor.
00044     this->addProxyFunction< Kross::Api::ProxyValue<Kross::Api::Variant,bool> >
00045         ("close", m_cursor, &::KexiDB::Cursor::close );
00046 
00047     // Moves current position to the first record and retrieves it.
00048     this->addProxyFunction< Kross::Api::ProxyValue<Kross::Api::Variant,bool> >
00049         ("moveFirst", m_cursor, &::KexiDB::Cursor::moveFirst );
00050 
00051     // Moves current position to the last record and retrieves it.
00052     this->addProxyFunction< Kross::Api::ProxyValue<Kross::Api::Variant,bool> >
00053         ("moveLast", m_cursor, &::KexiDB::Cursor::moveLast );
00054 
00055     // Moves current position to the previous record and retrieves it.
00056     this->addProxyFunction< Kross::Api::ProxyValue<Kross::Api::Variant,bool> >
00057         ("movePrev", m_cursor, &::KexiDB::Cursor::movePrev );
00058 
00059     // Moves current position to the next record and retrieves it.
00060     this->addProxyFunction< Kross::Api::ProxyValue<Kross::Api::Variant,bool> >
00061         ("moveNext", m_cursor, &::KexiDB::Cursor::moveNext );
00062 
00063     // Returns true if current position is before first record.
00064     this->addProxyFunction< Kross::Api::ProxyValue<Kross::Api::Variant,bool> >
00065         ("bof", m_cursor, &::KexiDB::Cursor::bof );
00066 
00067     // Returns true if current position is after last record.
00068     this->addProxyFunction< Kross::Api::ProxyValue<Kross::Api::Variant,bool> >
00069         ("eof", m_cursor, &::KexiDB::Cursor::eof );
00070 
00071     // Returns current internal position of the cursor's query. Records 
00072     // are numbered from 0; the value -1 means that the cursor does not 
00073     // point to a valid record.
00074     this->addProxyFunction< Kross::Api::ProxyValue<Kross::Api::Variant,Q_LLONG> >
00075         ("at", m_cursor, &::KexiDB::Cursor::at );
00076 
00077     // Returns the number of fields available for this cursor.
00078     this->addProxyFunction< Kross::Api::ProxyValue<Kross::Api::Variant,uint> >
00079         ("fieldCount", m_cursor, &::KexiDB::Cursor::fieldCount );
00080 
00081     // Returns the value stored in the passed column number (counting from 0).
00082     this->addProxyFunction< Kross::Api::ProxyValue<Kross::Api::Variant,QVariant>, Kross::Api::ProxyValue<Kross::Api::Variant,uint> >
00083         ("value", m_cursor, &::KexiDB::Cursor::value );
00084 }
00085 
00086 KexiDBCursor::~KexiDBCursor()
00087 {
00089     //delete m_cursor;
00090 }
00091 
00092 const QString KexiDBCursor::getClassName() const
00093 {
00094     return "Kross::KexiDB::KexiDBCursor";
00095 }
00096 
KDE Home | KDE Accessibility Home | Description of Access Keys