Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:aualin:kde
kdeaddons3
use-db.diff
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File use-db.diff of Package kdeaddons3
--- noatun-plugins/oblique/base.cpp +++ noatun-plugins/oblique/base.cpp @@ -14,14 +14,13 @@ #include <cstdlib> #include <assert.h> -#include <db_cxx.h> - - +#include <iostream> +#include <db.h> struct Base::Private { - Private() : db(0, DB_CXX_NO_EXCEPTIONS) { } - Db db; + Private() : db(0) { db_create(&db, NULL, 0); } + DB* db; typedef KDbt<FileId> Key; typedef KDbt<QStringList> Data; @@ -43,17 +42,15 @@ Base::Base(const QString &file) QCString filename = QFile::encodeName(file); bool create = true; - if (d->db.open( -#if DB_VERSION_MINOR > 0 && DB_VERSION_MAJOR >= 4 + if (d->db->open( d->db, NULL, -#endif filename, 0, DB_BTREE, DB_NOMMAP, 0 - )==0) + )== 0) { // success Private::Data data; Private::Key key(0); - if (d->db.get(0, &key, &data, 0)==0) + if (d->db->get(d->db, NULL, &key, &data, 0)==0) { QStringList strs; data.get(strs); @@ -72,10 +69,9 @@ Base::Base(const QString &file) if (create) { // failure QFile(filename).remove(); - d->db.open( -#if DB_VERSION_MINOR > 0 && DB_VERSION_MAJOR >= 4 + d->db->open( + d->db, NULL, -#endif filename,0, DB_BTREE, DB_NOMMAP|DB_CREATE,0 ); @@ -91,7 +87,7 @@ Base::Base(const QString &file) // "the high extreme (auto-increment counter in SQL terminology)", // "the metaxml" // } - d->db.put(0, &key, &data, 0); + d->db->put(d->db, 0, &key, &data, 0); } } @@ -108,9 +104,9 @@ Base::~Base() Private::Data data(strs); Private::Key key(0); - d->db.put(0, &key, &data, 0); - d->db.sync(0); - d->db.close(0); + d->db->put(d->db, 0, &key, &data, 0); + d->db->sync(d->db, 0); + d->db->close(d->db, 0); delete d; } @@ -121,7 +117,7 @@ File Base::add(const QString &file) properties << "file" << file; Private::Data data(properties); - unless (d->db.put(0, &key, &data, 0)) + unless (d->db->put(d->db, 0, &key, &data, 0)) { // success ! File f(this, d->high); @@ -140,7 +136,7 @@ File Base::find(FileId id) Private::Key key(id); Private::Data data; - unless (d->db.get(0, &key, &data, 0)) + unless (d->db->get(d->db, 0, &key, &data, 0)) { // exists return File(this, id); @@ -205,8 +201,8 @@ void Base::setProperty(FileId id, const Private::Data data(props); Private::Key dbkey(id); - d->db.put(0, &dbkey, &data, 0); - d->db.sync(0); + d->db->put(d->db, 0, &dbkey, &data, 0); + d->db->sync(d->db, 0); emit modified(File(this, id)); } @@ -243,8 +239,8 @@ void Base::clearProperty(FileId id, cons Private::Data data(props); Private::Key dbkey(id); - d->db.put(0, &dbkey, &data, 0); - d->db.sync(0); + d->db->put(d->db, 0, &dbkey, &data, 0); + d->db->sync(d->db, 0); emit modified(File(this, id)); } @@ -253,7 +249,7 @@ void Base::remove(File file) { Private::Key key(file.id()); - unless (d->db.del(0, &key, 0)) + unless (d->db->del(d->db, 0, &key, 0)) { emit removed(file); if (file.id() == d->high) @@ -261,7 +257,7 @@ void Base::remove(File file) d->high--; // optimization } } - d->db.sync(0); + d->db->sync(d->db, 0); } void Base::loadIntoCache(FileId id) const @@ -273,7 +269,7 @@ void Base::loadIntoCache(FileId id) cons Private::Key key(id); Private::Data data; - unless (d->db.get(0, &key, &data, 0)) + unless (d->db->get(d->db, 0, &key, &data, 0)) { QStringList props; data.get(props); @@ -317,14 +313,14 @@ void Base::move(FileId oldid, FileId new { Private::Key key(oldid); Private::Data data; - unless (d->db.get(0, &key, &data, 0)) + unless (d->db->get(d->db, 0, &key, &data, 0)) { QStringList props; data.get(props); - d->db.del(0, &key, 0); + d->db->del(d->db, 0, &key, 0); Private::Key key2(newid); - d->db.put(0, &key2, &data, 0); + d->db->put(d->db, 0, &key2, &data, 0); } } --- noatun-plugins/oblique/configure.in.in +++ noatun-plugins/oblique/configure.in.in @@ -1,29 +1,29 @@ AC_ARG_WITH(berkeley-db, - [AC_HELP_STRING([--with-berkeley-db],[enable support for Berkeley DB++ @<:@default=check@:>@])], + [AC_HELP_STRING([--with-berkeley-db],[enable support for Berkeley DB @<:@default=check@:>@])], [], with_berkeley_db=check) AC_ARG_WITH(db-lib, - [AC_HELP_STRING([--with-db-lib=NAME],[name of the Berkeley DB++ library @<:@default=db_cxx@:>@])], - [ac_db_name="$withval"], [ac_db_name="db_cxx"]) + [AC_HELP_STRING([--with-db-lib=NAME],[name of the Berkeley DB library @<:@default=db@:>@])], + [ac_db_name="$withval"], [ac_db_name="db"]) berkeley_db=no if test "x$with_berkeley_db" != xno; then berkeley_db=yes - KDE_CHECK_HEADER([db_cxx.h], + KDE_CHECK_HEADER([db.h], [:], [berkeley_db=no]) AC_CHECK_LIB([$ac_db_name], [main], [:], [berkeley_db=no]) if test "x$berkeley_db" = xyes; then - AC_DEFINE(BERKELEY_DB, 1, [Define if you have Berkeley DB++ installed]) + AC_DEFINE(BERKELEY_DB, 1, [Define if you have Berkeley DB installed]) BERKELEY_DB_LIBS="-l$ac_db_name" AC_SUBST(BERKELEY_DB_LIBS) fi if test "x$with_berkeley_db" != xcheck && test "x$berkeley_db" != xyes; then - AC_MSG_ERROR([--with-berkeley-db was given, but test for Berkeley DB++ failed]) + AC_MSG_ERROR([--with-berkeley-db was given, but test for Berkeley DB failed]) fi fi --- noatun-plugins/oblique/kdbt.h +++ noatun-plugins/oblique/kdbt.h @@ -6,17 +6,17 @@ #ifndef KDbt_Interface #define KDbt_Interface -#include <db_cxx.h> #include <qdatastream.h> #include <qbuffer.h> #include "kbuffer.h" +#include "db.h" /**A generic wrapper for "database thang" class that abstracts binary streaming operations. *@author Eray Ozkural (exa) */ template <typename T> -class KDbt : public Dbt { +class KDbt : public DBT { public: /* assume streaming operators on QDataStream QDataStream & operator>> ( QDataStream& >>, T &); @@ -28,32 +28,24 @@ public: KDbt(const T& obj) { set(obj); } -// operator Dbt() { -// return Dbt(thang.data(), thang.size()); -// } /** set "thang" to the contents of obj */ void set(const T& obj) { -// KBuffer buffer(thang); - QDataStream ds(&thang); + QDataStream ds(thang, IO_WriteOnly); ds << obj; -// std::cerr << "thang size " << thang.size() << endl; -// buffer.close(); -// set_data(thang.data()); -// set_size(buffer.size()); - set_data(thang.data()); - set_size(thang.size()); + data = thang.data(); + size = thang.size(); } + void get(T& obj) { QByteArray buffer; - buffer.setRawData((char*)get_data(),get_size()); + buffer.setRawData((char*)data,size); QDataStream ds(buffer,IO_ReadWrite); ds >> obj; - buffer.resetRawData((char*)get_data(),get_size()); + buffer.resetRawData((char*)data,size); } private: /** Internal data */ -// QByteArray thang; - KBuffer thang; + QByteArray thang; }; #endif
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor