summaryrefslogtreecommitdiffhomepage
path: root/options/group.hpp
blob: 11bab965ab5600cb0c9cb30345da268dd75a6e9d (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
#pragma once

#include "options/defs.hpp"

#include "compat/base-path.hpp"
#include "compat/library-path.hpp"
#include "compat/macros.h"
#include "compat/qhash.hpp"
#include "export.hpp"

#include <optional>
#include <unordered_map>

#include <QString>
#include <QVariant>

#include <QDebug>

// XXX TODO remove qsettings usage -sh 20180624

namespace options::detail {
    // snapshot of qsettings group at given time
    class OTR_OPTIONS_EXPORT group final
    {
        QString name;

    public:
        std::unordered_map<QString, QVariant> kvs;
        explicit group(const QString& name);
        void save() const;
        void put(const QString& s, const QVariant& d);
        void put(const QString& s, QVariant&& d);
        bool contains(const QString& s) const;

        never_inline QVariant get_variant(const QString& name) const;
    };
} // ns options::detail