KDESu

repo.h
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 */
28{
29public:
30 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:
59 typedef QMap<QByteArray, Data_entry>::Iterator RepoIterator;
61 unsigned head_time;
62};
63
64#endif
String repository.
Definition repo.h:28
void add(const QByteArray &key, Data_entry &data)
Add a data element.
Definition repo.cpp:25
int remove(const QByteArray &key)
Delete a data element.
Definition repo.cpp:40
int expire()
Remove data elements which are expired.
Definition repo.cpp:151
QByteArray findKeys(const QByteArray &group, const char *sep="-") const
Returns the key values for the given group.
Definition repo.cpp:107
QByteArray find(const QByteArray &key) const
Return a data value.
Definition repo.cpp:138
int removeGroup(const QByteArray &group)
Delete all data entries having the given group.
Definition repo.cpp:75
int removeSpecialKey(const QByteArray &key)
Delete all data entries based on key.
Definition repo.cpp:56
int hasGroup(const QByteArray &group) const
Checks for the existence of the specified group.
Definition repo.cpp:94
ConstIterator
Used internally.
Definition repo.h:16
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Mon Nov 18 2024 12:08:50 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.