KLdap

ldapobject.h
1/*
2 This file is part of libkldap.
3 SPDX-FileCopyrightText: 2004-2006 Szombathelyi György <gyurco@freemail.hu>
4
5 SPDX-License-Identifier: LGPL-2.0-or-later
6*/
7
8#pragma once
9
10#include <QList>
11#include <QMap>
12#include <QSharedDataPointer>
13#include <QString>
14class LdapObjectPrivate;
15
16#include "kldap_core_export.h"
17#include "ldapdn.h"
18
19// clazy:excludeall=copyable-polymorphic
20
21namespace KLDAPCore
22{
23using LdapAttrValue = QList<QByteArray>;
24using LdapAttrMap = QMap<QString, LdapAttrValue>;
25
26/**
27 * @brief
28 * This class represents an LDAP Object
29 */
30class KLDAP_CORE_EXPORT LdapObject
31{
32public:
33 LdapObject();
34 explicit LdapObject(const QString &dn);
36
37 LdapObject(const LdapObject &that);
38 LdapObject &operator=(const LdapObject &that);
39
40 /**
41 * Returns the text presentation (LDIF format) of the object.
42 */
43 [[nodiscard]] QString toString() const;
44
45 /**
46 * Clears the name and attributes of the object.
47 */
48 void clear();
49 /**
50 * Sets the Distinguished Name of the object.
51 */
52 void setDn(const LdapDN &dn);
53 /**
54 * Sets the Distinguished Name of the object.
55 */
56 void setDn(const QString &dn);
57 /**
58 * Sets the attributes and attribute values of the object.
59 */
60 void setAttributes(const LdapAttrMap &attrs);
61 /**
62 * Sets the given attribute values. If the given attribute not exists,
63 * then it's created, if exists, it's overwritten.
64 * @param attributeName the attribute name for which to set values
65 * @param values the values of attribute to set
66 */
67 void setValues(const QString &attributeName, const LdapAttrValue &values);
68 /**
69 * Adds the given value to the specified attribute. If the given attribute
70 * not exists, then it's created.
71 * @param attributeName the attribute for which to add a value
72 * @param value the attribute value to add
73 */
74 void addValue(const QString &attributeName, const QByteArray &value);
75 /**
76 * Return the Distinguished Name of the object.
77 */
78 [[nodiscard]] LdapDN dn() const;
79 /**
80 * Returns the attributes and their values.
81 */
82 const LdapAttrMap &attributes() const;
83 /**
84 * Returns all values of the attribute with the given name.
85 */
86 [[nodiscard]] LdapAttrValue values(const QString &attributeName) const;
87 /**
88 * Returns the first value of the attribute with the given name
89 * or an empty byte array if the attribute does not exists.
90 */
91 [[nodiscard]] QByteArray value(const QString &attributeName) const;
92 /**
93 * Returns true if the given attributethe exists, false otherwise.
94 */
95 [[nodiscard]] bool hasAttribute(const QString &attributeName) const;
96
97private:
99};
100
102}
This class represents an LDAP Object.
Definition ldapobject.h:31
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Tue Mar 26 2024 11:18:34 by doxygen 1.10.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.