comparison MemoryDBLink.cpp @ 1:aae83c0a771d

Refactor: -Rename all Db to DB. Add setup script Add support for Sqlite3 in configuration.
author Tom Fredrik Blenning Klaussen <bfg@blenning.no>
date Mon, 20 Aug 2012 17:32:58 +0200
parents MemoryDbLink.cpp@a3834af36579
children d6fdca3bf24e
comparison
equal deleted inserted replaced
0:a3834af36579 1:aae83c0a771d
1 #include "MemoryDBLink.hpp"
2
3 #include <QtCore/QStringList>
4
5 void MemoryDBLink::addFile(const QString& path, qint64 size, const QDateTime& dtime, const QCryptographicHash& hash)
6 {
7 addFile(DBInfo(path, size, dtime, hash.result()));
8 }
9
10 bool MemoryDBLink::tryAddFile(const DBInfo& dbinfo)
11 {
12 QMap<QString, QSharedPointer<DBInfo> >::iterator pos;
13 pos = entries.find(dbinfo.path());
14 if (pos == entries.end()) {
15 entries.insert(dbinfo.path(), QSharedPointer<DBInfo>(new DBInfo(dbinfo)));
16 return true;
17 }
18 return false;
19 }
20
21 void MemoryDBLink::addFile(const DBInfo& dbinfo)
22 {
23 if (!tryAddFile(dbinfo)) {
24 abort(); //Should throw exception
25 }
26 }
27
28
29 QStringList MemoryDBLink::toStringList()
30 {
31 QStringList list;
32 foreach(QSharedPointer<DBInfo> info, entries) {
33 list << info->serialize();
34 }
35 return list;
36 }
37
38 const QList<QSharedPointer<FileDBLink::DBInfo> > MemoryDBLink::values() const
39 {
40 return entries.values();
41 }