1/* vi: ts=8 sts=4 sw=4
2
3 This file is part of the KDE project, module kdesu.
4 SPDX-FileCopyrightText: 1999, 2000 Geert Jansen <jansen@kde.org>
5*/
6
7#ifndef __Repo_h_included__
8#define __Repo_h_included__
9
10#include <QByteArray>
11#include <QMap>
12
13/**
14 * Used internally.
15 */
16struct Data_entry {
17 QByteArray value;
18 QByteArray group;
19 unsigned int timeout;
20};
21
22/**
23 * String repository.
24 *
25 * This class implements a string repository with expiration.
26 */
27class Repository
28{
29public:
30 Repository();
31 ~Repository();
32
33 /** Remove data elements which are expired. */
34 int expire();
35
36 /** Add a data element */
37 void add(const QByteArray &key, Data_entry &data);
38
39 /** Delete a data element. */
40 int remove(const QByteArray &key);
41
42 /** Delete all data entries having the given group. */
43 int removeGroup(const QByteArray &group);
44
45 /** Delete all data entries based on key. */
46 int removeSpecialKey(const QByteArray &key);
47
48 /** Checks for the existence of the specified group. */
49 int hasGroup(const QByteArray &group) const;
50
51 /** Return a data value. */
52 QByteArray find(const QByteArray &key) const;
53
54 /** Returns the key values for the given group. */
55 QByteArray findKeys(const QByteArray &group, const char *sep = "-") const;
56
57private:
58 QMap<QByteArray, Data_entry> repo;
59 typedef QMap<QByteArray, Data_entry>::Iterator RepoIterator;
60 typedef QMap<QByteArray, Data_entry>::ConstIterator RepoCIterator;
61 unsigned head_time;
62};
63
64#endif
65

source code of kdesu/src/kdesud/repo.h