27 using namespace KLDAP;
29 class LdapDN::LdapDNPrivate
32 LdapDNPrivate() : m_dn() {}
35 bool isValidRDNString(
const QString &rdn )
const;
41 bool LdapDN::LdapDNPrivate::isValidRDNString(
const QString &rdn )
const
43 kDebug() <<
"Testing rdn:" << rdn;
47 const int rdnPartsSize( rdnParts.
size() );
48 if ( rdnPartsSize > 1 ) {
49 for (
int i = 0; i < rdnPartsSize; i++ ) {
50 if ( !isValidRDNString( rdnParts.
at( i ) ) ) {
61 if ( components.
size() != 2 ) {
69 const QChar &ch )
const
74 int strPartStartIndex = 0;
75 while ( ( index = str.
indexOf( ch, searchFrom ) ) != -1 ) {
76 const QChar prev = str[std::max( 0, index - 1 )];
80 QString tmp = str.
mid( strPartStartIndex, index - strPartStartIndex );
83 strPartStartIndex = index + 1;
86 searchFrom = index + 1;
98 : d( new LdapDNPrivate )
103 LdapDN::LdapDN(
const QString &dn )
104 : d( new LdapDNPrivate )
109 LdapDN::LdapDN(
const LdapDN &that )
110 : d( new LdapDNPrivate )
115 LdapDN &LdapDN::operator=(
const LdapDN &that )
117 if (
this == &that ) {
135 bool LdapDN::isEmpty()
const
137 return d->m_dn.isEmpty();
140 QString LdapDN::toString()
const
145 QString LdapDN::toString(
int depth )
const
148 if ( depth >= rdns.
size() ) {
154 for (
int i = depth; i >= 0; i-- ) {
156 kDebug() <<
"dn =" << dn;
163 QString LdapDN::rdnString()
const
170 QString LdapDN::rdnString(
int depth )
const
173 if ( depth >= rdns.
size() ) {
176 return rdns.
at( rdns.
size() - 1 - depth );
179 bool LdapDN::isValid()
const
181 kDebug() <<
"Testing dn:" << d->m_dn;
187 const int rdnsSize( rdns.
size() );
188 for (
int i = 0; i < rdnsSize; i++ ) {
189 if ( !d->isValidRDNString( rdns.
at( i ) ) ) {
197 int LdapDN::depth()
const
203 bool LdapDN::operator == (
const LdapDN &rhs )
const
205 return d->m_dn == rhs.d->m_dn;
208 bool LdapDN::operator != (
const LdapDN &rhs )
const
210 return d->m_dn != rhs.d->m_dn;
int indexOf(QChar ch, int from, Qt::CaseSensitivity cs) const
QStringList split(const QString &sep, SplitBehavior behavior, Qt::CaseSensitivity cs) const
const T & at(int i) const
void append(const T &value)
QString mid(int position, int n) const
QString left(int n) const