summaryrefslogtreecommitdiffstats
path: root/store/database.h
blob: 2bf055696b2ed7e78ec88322439f88fffcf95b87 (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
#pragma once

#include <string>
#include <QString>

class Database {
public:
    enum TransactionType { ReadOnly, ReadWrite };

    Database(const QString &path);
    ~Database();
    bool isInTransaction() const;
    bool startTransaction(TransactionType type = ReadWrite);
    bool commitTransaction();
    void abortTransaction();
    bool write(const std::string &sKey, const std::string &sValue);
    //Perhaps prefer iterators (assuming we need to be able to match multiple values
    void read(const std::string &sKey, const std::function<void(const std::string &value)> &);
    void read(const std::string &sKey, const std::function<void(void *ptr, int size)> &);

private:
    class Private;
    Private * const d;
};