~ubuntu-branches/debian/sid/kexi/sid

« back to all changes in this revision

Viewing changes to src/plugins/scripting/kexidb/kexidbparser.h

  • Committer: Package Import Robot
  • Author(s): Pino Toscano
  • Date: 2017-06-24 20:10:10 UTC
  • Revision ID: package-import@ubuntu.com-20170624201010-5lrzd5r2vwthwifp
Tags: upstream-3.0.1.1
ImportĀ upstreamĀ versionĀ 3.0.1.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/***************************************************************************
 
2
 * kexidbparser.h
 
3
 * This file is part of the KDE project
 
4
 * copyright (C)2004-2006 by Sebastian Sauer (mail@dipe.org)
 
5
 *
 
6
 * This program is free software; you can redistribute it and/or
 
7
 * modify it under the terms of the GNU Library General Public
 
8
 * License as published by the Free Software Foundation; either
 
9
 * version 2 of the License, or (at your option) any later version.
 
10
 * This program is distributed in the hope that it will be useful,
 
11
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
12
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 
13
 * Library General Public License for more details.
 
14
 * You should have received a copy of the GNU Library General Public License
 
15
 * along with this program; see the file COPYING.  If not, write to
 
16
 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 
17
 * Boston, MA 02110-1301, USA.
 
18
 ***************************************************************************/
 
19
 
 
20
#ifndef SCRIPTING_KEXIDBPARSER_H
 
21
#define SCRIPTING_KEXIDBPARSER_H
 
22
 
 
23
#include <QString>
 
24
#include <QObject>
 
25
#include <QPointer>
 
26
 
 
27
#include <KDbDriverManager>
 
28
#include <KDbParser>
 
29
 
 
30
namespace Scripting
 
31
{
 
32
 
 
33
// Forward declaration.
 
34
class KexiDBConnection;
 
35
class KexiDBTableSchema;
 
36
class KexiDBQuerySchema;
 
37
 
 
38
/**
 
39
* The KexiDBParser could be used to parse SQL-statements.
 
40
*
 
41
* Example (in Python) ;
 
42
* @code
 
43
* # First we need a parser object.
 
44
* parser = connection.parser()
 
45
* # Parse a SQL-statement.
 
46
* parser.parse("SELECT * from table1")
 
47
* # The operation could be e.g. SELECT or INSERT.
 
48
* if parser.operation() == 'Error':
 
49
*     raise parser.errorMsg()
 
50
* # Print some feedback.
 
51
* print "Successfully parsed the SQL-statement %s" % parser.statement()
 
52
* @endcode
 
53
*/
 
54
class KexiDBParser : public QObject
 
55
{
 
56
    Q_OBJECT
 
57
public:
 
58
    KexiDBParser(KexiDBConnection* connection, KDbParser* parser, bool owner);
 
59
    virtual ~KexiDBParser();
 
60
 
 
61
public Q_SLOTS:
 
62
 
 
63
    /** Clears previous results and runs the parser on the SQL statement passed as an argument. */
 
64
    bool parse(const QString& sql);
 
65
    /** Clears parsing results. */
 
66
    void clear();
 
67
    /** Returns the resulting operation. */
 
68
    const QString operation();
 
69
 
 
70
    /** Returns the \a KexiDBTableSchema object on a CREATE TABLE operation. */
 
71
    QObject* table();
 
72
    /** Returns the \a KexiDBQuerySchema object on a SELECT operation. */
 
73
    QObject* query();
 
74
    /** Returns the \a KexiDBConnection object pointing to the used database connection. */
 
75
    QObject* connection();
 
76
    /** Returns the SQL query statement. */
 
77
    const QString statement();
 
78
 
 
79
    /** Returns the type string of the last error. */
 
80
    const QString errorType();
 
81
    /** Returns the message of the last error. */
 
82
    const QString errorMsg();
 
83
    /** Returns the position where the last error occurred. */
 
84
    int errorAt();
 
85
 
 
86
private:
 
87
    QPointer<KexiDBConnection> m_connection;
 
88
    KDbParser* m_parser;
 
89
    bool m_owner;
 
90
};
 
91
 
 
92
}
 
93
 
 
94
#endif
 
95