1 /* 2 This file is part of libkldap. 3 SPDX-FileCopyrightText: 2006 Sean Harmer <sh@theharmers.co.uk> 4 5 SPDX-License-Identifier: LGPL-2.0-or-later 6 */ 7 8 #pragma once 9 10 #include "kldap_export.h" 11 #include <QString> 12 #include <memory> 13 namespace KLDAP 14 { 15 class KLDAP_EXPORT LdapDN 16 { 17 public: 18 explicit LdapDN(); 19 explicit LdapDN(const QString &dn); 20 21 LdapDN(const LdapDN &that); 22 LdapDN &operator=(const LdapDN &that); 23 24 ~LdapDN(); 25 26 void clear(); 27 28 bool isEmpty() const; 29 30 /** 31 * \returns A QString representing the DN. 32 */ 33 Q_REQUIRED_RESULT QString toString() const; 34 35 /** 36 * \param depth The depth of the DN to return using a zero-based index. 37 * \returns A QString representing the DN levels deep in the directory. 38 */ 39 Q_REQUIRED_RESULT QString toString(int depth) const; 40 41 /** 42 * \returns A QString representing the RDN of this DN. 43 */ 44 Q_REQUIRED_RESULT QString rdnString() const; 45 46 /** 47 * \param depth The depth of the RDN to return using a zero-based index. 48 * \returns A QString representing the RDN levels deep in the directory. 49 */ 50 Q_REQUIRED_RESULT QString rdnString(int depth) const; 51 52 /** 53 * \returns True if this is a valid DN, false otherwise. 54 */ 55 Q_REQUIRED_RESULT bool isValid() const; 56 57 /** 58 * \returns The depth of this DN in the directory. 59 */ 60 Q_REQUIRED_RESULT int depth() const; 61 62 Q_REQUIRED_RESULT bool operator==(const LdapDN &rhs) const; 63 64 Q_REQUIRED_RESULT bool operator!=(const LdapDN &rhs) const; 65 66 private: 67 class LdapDNPrivate; 68 std::unique_ptr<LdapDNPrivate> const d; 69 }; 70 } 71 72