KLdap

ldapurl.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 <QStringList>
11
12#include <QUrl>
13
14#include "kldap_core_export.h"
15#include "ldapdn.h"
16
17// clazy:excludeall=copyable-polymorphic
18
19namespace KLDAPCore
20{
21/**
22 * @short A special url class for LDAP.
23 *
24 * LdapUrl implements an RFC 2255 compliant LDAP Url parser, with minimal
25 * differences. LDAP Urls implemented by this class has the following format:
26 * ldap[s]://[user[:password]@]hostname[:port]["/" [dn ["?" [attributes]
27 * ["?" [scope] ["?" [filter] ["?" extensions]]]]]]
28 */
29class KLDAP_CORE_EXPORT LdapUrl : public QUrl
30{
31public:
32 /**
33 * A class holding the extension name and state whether
34 * the extension is critical.
35 */
36 using Extension = struct {
37 QString value;
38 bool critical;
39 };
40
41 /**
42 * Describes the scope of the LDAP url.
43 */
44 using Scope = enum {
45 Base, ///< Only the same level as the url.
46 One, ///< The level of the url and the one below.
47 Sub ///< All levels below the url's level.
48 };
49
50 /**
51 * Constructs an empty LDAP url.
52 */
53 LdapUrl();
54
55 /**
56 * Constructs a LDAP url from a KUrl @p url.
57 */
58 explicit LdapUrl(const QUrl &url);
59
60 /**
61 * Constructs a LDAP url from an other url.
62 */
63 LdapUrl(const LdapUrl &other);
64
65 /**
66 * Overwrites the values of the LDAP url with values
67 * from an @p other url.
68 */
69 LdapUrl &operator=(const LdapUrl &other);
70
71 /**
72 * Destroys the LDAP url.
73 */
75
76 /**
77 * Sets the @p dn part of the LDAP url.
78 */
79 void setDn(const LdapDN &dn);
80
81 /**
82 * Returns the dn part of the LDAP url.
83 * This is equal to path() with the slash removed from the beginning.
84 */
85 [[nodiscard]] LdapDN dn() const;
86
87 /**
88 * Sets the @p attributes part of the LDAP url.
89 */
90 void setAttributes(const QStringList &attributes);
91
92 /**
93 * Returns the attributes part of the LDAP url.
94 */
95 [[nodiscard]] QStringList attributes() const;
96
97 /**
98 * Sets the scope part of the LDAP url.
99 */
100 void setScope(Scope scope);
101
102 /**
103 * Returns the scope part of the LDAP url.
104 */
105 [[nodiscard]] Scope scope() const;
106
107 /**
108 * Sets the filter part of the LDAP url.
109 */
110 void setFilter(const QString &filter);
111
112 /**
113 * Returns the filter part of the LDAP url.
114 */
115 [[nodiscard]] QString filter() const;
116
117 /**
118 * Returns whether the specified @p extension exists in the LDAP url.
119 */
120 [[nodiscard]] bool hasExtension(const QString &extension) const;
121
122 /**
123 * Returns the specified @p extension.
124 */
125 [[nodiscard]] Extension extension(const QString &extension) const;
126
127 /**
128 * Returns the specified @p extension.
129 */
130 [[nodiscard]] QString extension(const QString &extension, bool &critical) const;
131
132 /**
133 * Sets the specified extension @p key with the value and criticality in @p extension.
134 */
135 void setExtension(const QString &key, const Extension &extension);
136
137 /**
138 * Sets the specified extension @p key with the @p value and criticality specified.
139 */
140 void setExtension(const QString &key, const QString &value, bool critical = false);
141
142 /**
143 * Sets the specified extension @p key with the @p value and criticality specified.
144 */
145 void setExtension(const QString &key, int value, bool critical = false);
146
147 /**
148 * Removes the specified @p extension.
149 */
150 void removeExtension(const QString &extension);
151
152 /**
153 * Updates the query component from the attributes, scope, filter and extensions.
154 */
155 void updateQuery();
156
157 /**
158 * Parses the query argument of the URL and makes it available via the
159 * attributes(), extension(), filter() and scope() methods
160 */
161 void parseQuery();
162
163private:
164 class LdapUrlPrivate;
165 std::unique_ptr<LdapUrlPrivate> const d;
166};
167}
A special url class for LDAP.
Definition ldapurl.h:30
void setExtension(const QString &key, const Extension &extension)
Sets the specified extension key with the value and criticality in extension.
~LdapUrl()
Destroys the LDAP url.
enum { Base, One, Sub } Scope
Describes the scope of the LDAP url.
Definition ldapurl.h:44
Q_SCRIPTABLE bool setFilter(const QString &filter)
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Sat Dec 21 2024 17:03:36 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.