Mercurial > dedupe
comparison MemoryDbLink.cpp @ 0:a3834af36579
Working with memory backend.
| author | Tom Fredrik Blenning Klaussen <bfg@blenning.no> |
|---|---|
| date | Mon, 20 Aug 2012 15:49:48 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| -1:000000000000 | 0:a3834af36579 |
|---|---|
| 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 } |
