summaryrefslogtreecommitdiffstats
path: root/src/3rdparty/btree/qt/qbtreecursor.h
blob: 7d2b5cf84838d5445f7a5dffa76775a8e2a9877f (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
44
45
46
47
#ifndef QBTREECURSOR_H
#define QBTREECURSOR_H

#include "qbtreedata.h"

class QBtree;
class QBtreeTxn;
struct cursor;

class QBtreeCursor
{
public:
    QBtreeCursor();
    explicit QBtreeCursor(QBtreeTxn *txn);
    explicit QBtreeCursor(QBtree *btree, bool commitedOnly = false);
    ~QBtreeCursor();

    QBtreeCursor(const QBtreeCursor &other);
    QBtreeCursor &operator=(const QBtreeCursor &other);

    bool current(QByteArray *baKey, QByteArray *baValue) const;
    bool current(QBtreeData *baKey, QBtreeData *baValue) const;

    const QBtreeData &key() const { return mKey; }
    const QBtreeData &value() const { return mValue; }

    bool first();
    bool last();

    bool next();
    bool previous();

    bool seek(const QByteArray &baKey);
    bool seek(const QBtreeData &key);

    bool seekRange(const QByteArray &baKey);
    bool seekRange(const QBtreeData &key);

private:
    struct cursor *mCursor;
    QBtreeData mKey;
    QBtreeData mValue;

    bool moveHelper(const char *key, int size, int cursorOp);
};

#endif // QBTREECURSOR_H