diff options
author | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-01-20 01:29:50 +0000 |
---|---|---|
committer | tpearson <tpearson@283d02a7-25f6-0310-bc7c-ecb5cbfe19da> | 2010-01-20 01:29:50 +0000 |
commit | 8362bf63dea22bbf6736609b0f49c152f975eb63 (patch) | |
tree | 0eea3928e39e50fae91d4e68b21b1e6cbae25604 /kexi/tests/parser | |
download | koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.tar.gz koffice-8362bf63dea22bbf6736609b0f49c152f975eb63.zip |
Added old abandoned KDE3 version of koffice
git-svn-id: svn://anonsvn.kde.org/home/kde/branches/trinity/applications/koffice@1077364 283d02a7-25f6-0310-bc7c-ecb5cbfe19da
Diffstat (limited to 'kexi/tests/parser')
-rw-r--r-- | kexi/tests/parser/Makefile.am | 13 | ||||
-rw-r--r-- | kexi/tests/parser/README | 9 | ||||
-rw-r--r-- | kexi/tests/parser/db | bin | 0 -> 17408 bytes | |||
-rw-r--r-- | kexi/tests/parser/main.cpp | 103 | ||||
-rw-r--r-- | kexi/tests/parser/parser.pro | 24 |
5 files changed, 149 insertions, 0 deletions
diff --git a/kexi/tests/parser/Makefile.am b/kexi/tests/parser/Makefile.am new file mode 100644 index 00000000..ec1a3441 --- /dev/null +++ b/kexi/tests/parser/Makefile.am @@ -0,0 +1,13 @@ +include $(top_srcdir)/kexi/Makefile.global + +bin_PROGRAMS = kexidbparser + +noinst_PROGRAMS = kexidbparser + +INCLUDES = -I$(top_srcdir)/kexi $(all_includes) + +kexidbparser_SOURCES = main.cpp +kexidbparser_LDADD = $(LIB_QT) $(LIB_KDECORE) $(top_builddir)/kexi/kexidb/libkexidb.la $(top_builddir)/kexi/kexidb/parser/libkexidbparser.la $(all_libraries) +kexidbparser_LDFLAGS = $(all_libraries) $(KDE_RPATH) $(VER_INFO) --no-undefined + + diff --git a/kexi/tests/parser/README b/kexi/tests/parser/README new file mode 100644 index 00000000..d6f2ed44 --- /dev/null +++ b/kexi/tests/parser/README @@ -0,0 +1,9 @@ +Parser - Interactive test of KEXISQL parser + +Usage: +<program_name> <driver_name> <db_name> + +Notes: +<driver_name> can be just any existing - no database is changed, but only opened +because of parser requirements. +Predefined "db" database file for sqlite is available in this dir. diff --git a/kexi/tests/parser/db b/kexi/tests/parser/db Binary files differnew file mode 100644 index 00000000..d27cda22 --- /dev/null +++ b/kexi/tests/parser/db diff --git a/kexi/tests/parser/main.cpp b/kexi/tests/parser/main.cpp new file mode 100644 index 00000000..f6ee5742 --- /dev/null +++ b/kexi/tests/parser/main.cpp @@ -0,0 +1,103 @@ +#include <iostream> +#include <string> + +#include <qfileinfo.h> + +#include <kdebug.h> +#include <kinstance.h> + +#include <kexidb/drivermanager.h> +#include <kexidb/driver.h> +#include <kexidb/connection.h> +#include <kexidb/cursor.h> +#include <kexidb/parser/parser.h> + +using namespace std; +QCString prgname; + +int main(int argc, char **argv) +{ + kdDebug() << "main()" << endl; + QFileInfo info=QFileInfo(argv[0]); + prgname = info.baseName().latin1(); + KInstance instance( prgname ); + if (argc<2) { + return 1; + } + QCString drv_name(argv[1]); + QCString db_name = QString(argv[2]).lower().latin1(); + + KexiDB::DriverManager manager; // = KexiDB::DriverManager::self(); + QStringList names = manager.driverNames(); + kdDebug() << "DRIVERS: " << endl; + for (QStringList::ConstIterator it = names.constBegin(); it != names.constEnd() ; ++it) + kdDebug() << *it << endl; + if (manager.error()) { + kdDebug() << manager.errorMsg() << endl; + return 1; + } + + //get driver + KexiDB::Driver *driver = manager.driver(drv_name); + if (!driver || manager.error()) { + kdDebug() << manager.errorMsg() << endl; + return 1; + } + + //connection data that can be later reused + KexiDB::ConnectionData conn_data; + conn_data.setFileName(db_name); + + KexiDB::Connection *conn = driver->createConnection(conn_data); + if (!conn || driver->error()) { + kdDebug() << "error: " << driver->errorMsg() << endl; + return 1; + } + if (!conn->connect()) { + kdDebug() << "error: " << conn->errorMsg() << endl; + return 1; + } + if (!conn->useDatabase( db_name )) { + kdDebug() << "error: " << conn->errorMsg() << endl; + return 1; + } + + KexiDB::Parser *parser = new KexiDB::Parser(conn); + + std::string cmd; + while(cmd != "quit") + { + std::cout << "SQL> "; + getline(std::cin, cmd); + parser->parse(cmd.c_str()); + switch(parser->operation()) + { + case KexiDB::Parser::OP_Error: + kdDebug() << "***********************" << endl; + kdDebug() << "* error *" << endl; + kdDebug() << "***********************" << endl; + break; + case KexiDB::Parser::OP_CreateTable: + { + kdDebug() << "Schema of table: " << parser->table()->name() << endl; + parser->table()->debug(); + break; + } + case KexiDB::Parser::OP_Select: + { + kdDebug() << "Select statement: " << endl; + KexiDB::QuerySchema *q = parser->query(); + q->debug(); + delete q; + break; + } + default: + kdDebug() << "main(): not implemented in main.cpp" << endl; + + + } + parser->clear(); + } + return 0; +} + diff --git a/kexi/tests/parser/parser.pro b/kexi/tests/parser/parser.pro new file mode 100644 index 00000000..4629417a --- /dev/null +++ b/kexi/tests/parser/parser.pro @@ -0,0 +1,24 @@ +TEMPLATE = app + +include( $(KEXI)/common.pro ) + +win32 { + +QMAKE_CXXFLAGS += $(KEXI_OPTIONS) + +# test specific: + LIBS += \ + $$KDELIBDESTDIR/kexidb$$KEXILIB_SUFFIX + +#allow to select target independently from debug information + CONFIG += console + CONFIG -= windows +} + +DESTDIR = . # no # $KDEDIR/bin +TARGET = parser + +SOURCES = \ +main.cpp + +HEADERS = |