summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/btree/qt/qbtreetxn.h
blob: f402307d707d07aa50e5c388efade80aa322d497 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef QBTREETXN_H
#define QBTREETXN_H

#include "qbtreedata.h"

class QBtree;
struct btree_txn;

class QBtreeTxn
{
public:
    bool get(const QByteArray &baKey, QByteArray *baValue) const;
    bool get(const char *key, int keySize, QBtreeData *value) const;
    bool get(const QBtreeData &key, QBtreeData *value) const;
    bool put(const QByteArray &baKey, const QByteArray &baValue);
    bool put(const char *key, int keySize, const char *value, int valueSize);
    bool put(const QBtreeData &baKey, const QBtreeData &baValue);
    bool remove(const QByteArray &baKey);
    bool remove(const QBtreeData &baKey);
    bool remove(const char *key, int keySize);

    bool commit(quint32 tag);
    void abort();

    quint32 tag() const;

    inline QBtree *btree() const { return mBtree; }
    inline btree_txn *handle() const { return mTxn; }

    bool isReadOnly() const;
    bool isReadWrite() const;

private:
    QBtree *mBtree;
    btree_txn *mTxn;

    QBtreeTxn(QBtree *btree, btree_txn *txn);
    ~QBtreeTxn();
    QBtreeTxn(const QBtreeTxn &); // forbid copy constructor
    friend class QBtree;
};

#endif // QBTREETXN_H