10#include "ldap_core_debug.h"
13using namespace KLDAPCore;
15class Q_DECL_HIDDEN LdapDN::LdapDNPrivate
18 LdapDNPrivate() =
default;
20 ~LdapDNPrivate() =
default;
22 [[nodiscard]]
bool isValidRDNString(
const QString &rdn)
const;
28bool LdapDN::LdapDNPrivate::isValidRDNString(
const QString &rdn)
const
30 qCDebug(LDAP_CORE_LOG) <<
"Testing rdn:" << rdn;
34 const int rdnPartsSize(rdnParts.
size());
35 if (rdnPartsSize > 1) {
36 for (
int i = 0; i < rdnPartsSize; i++) {
37 if (!isValidRDNString(rdnParts.
at(i))) {
46 if (components.size() != 2) {
58 int strPartStartIndex = 0;
59 while ((index = str.
indexOf(ch, searchFrom)) != -1) {
60 const QChar prev = str[std::max(0, index - 1)];
64 QString tmp = str.
mid(strPartStartIndex, index - strPartStartIndex);
67 strPartStartIndex = index + 1;
70 searchFrom = index + 1;
82 : d(new LdapDNPrivate)
86LdapDN::LdapDN(
const QString &dn)
87 : d(new LdapDNPrivate)
92LdapDN::LdapDN(
const LdapDN &that)
93 : d(new LdapDNPrivate)
98LdapDN &LdapDN::operator=(
const LdapDN &that)
108LdapDN::~LdapDN() =
default;
115bool LdapDN::isEmpty()
const
117 return d->m_dn.isEmpty();
120QString LdapDN::toString()
const
125QString LdapDN::toString(
int depth)
const
128 if (depth >= rdns.
size()) {
134 for (
int i = depth; i >= 0; i--) {
136 qCDebug(LDAP_CORE_LOG) <<
"dn =" << dn;
143QString LdapDN::rdnString()
const
150QString LdapDN::rdnString(
int depth)
const
153 if (depth >= rdns.
size()) {
156 return rdns.
at(rdns.
size() - 1 - depth);
159bool LdapDN::isValid()
const
161 qCDebug(LDAP_CORE_LOG) <<
"Testing dn:" << d->m_dn;
167 const int rdnsSize(rdns.
size());
168 for (
int i = 0; i < rdnsSize; i++) {
169 if (!d->isValidRDNString(rdns.
at(i))) {
177int LdapDN::depth()
const
183bool LdapDN::operator==(
const LdapDN &rhs)
const
185 return d->m_dn == rhs.d->m_dn;
188bool LdapDN::operator!=(
const LdapDN &rhs)
const
190 return d->m_dn != rhs.d->m_dn;
void append(QList< T > &&value)
const_reference at(qsizetype i) const const
qsizetype size() const const
qsizetype indexOf(QChar ch, qsizetype from, Qt::CaseSensitivity cs) const const
QString mid(qsizetype position, qsizetype n) const const
QList< QStringView > split(QChar sep, Qt::SplitBehavior behavior, Qt::CaseSensitivity cs) const const