|
@@ -21,35 +21,50 @@
|
|
|
|
|
|
#include "ctkLDAPSearchFilter.h"
|
|
|
|
|
|
-#include "ctkLDAPExpr.h"
|
|
|
+#include "ctkLDAPExpr_p.h"
|
|
|
+#include "ctkServiceReferencePrivate.h"
|
|
|
|
|
|
|
|
|
-class ctkLDAPSearchFilterPrivate {
|
|
|
+class ctkLDAPSearchFilterData : public QSharedData
|
|
|
+{
|
|
|
public:
|
|
|
|
|
|
- ctkLDAPSearchFilterPrivate(const QString& filter)
|
|
|
- : ref(1), ldapExpr(filter)
|
|
|
+ ctkLDAPSearchFilterData()
|
|
|
+ {}
|
|
|
+
|
|
|
+ ctkLDAPSearchFilterData(const QString& filter)
|
|
|
+ : ldapExpr(filter)
|
|
|
+ {}
|
|
|
+
|
|
|
+ ctkLDAPSearchFilterData(const ctkLDAPSearchFilterData& other)
|
|
|
+ : QSharedData(other), ldapExpr(other.ldapExpr)
|
|
|
{}
|
|
|
|
|
|
- QAtomicInt ref;
|
|
|
ctkLDAPExpr ldapExpr;
|
|
|
};
|
|
|
|
|
|
+ctkLDAPSearchFilter::ctkLDAPSearchFilter()
|
|
|
+ : d(new ctkLDAPSearchFilterData())
|
|
|
+{
|
|
|
+}
|
|
|
+
|
|
|
ctkLDAPSearchFilter::ctkLDAPSearchFilter(const QString& filter)
|
|
|
- : d(new ctkLDAPSearchFilterPrivate(filter))
|
|
|
+ : d(new ctkLDAPSearchFilterData(filter))
|
|
|
{
|
|
|
}
|
|
|
|
|
|
-ctkLDAPSearchFilter::ctkLDAPSearchFilter(const ctkLDAPSearchFilter& filter)
|
|
|
- : d(filter.d)
|
|
|
+ctkLDAPSearchFilter::ctkLDAPSearchFilter(const ctkLDAPSearchFilter& other)
|
|
|
+ : d(other.d)
|
|
|
{
|
|
|
- d->ref.ref();
|
|
|
}
|
|
|
|
|
|
ctkLDAPSearchFilter::~ctkLDAPSearchFilter()
|
|
|
{
|
|
|
- if (!d->ref.deref())
|
|
|
- delete d;
|
|
|
+}
|
|
|
+
|
|
|
+bool ctkLDAPSearchFilter::match(const ctkServiceReference& reference) const
|
|
|
+{
|
|
|
+ return d->ldapExpr.evaluate(reference.d_func()->getProperties(), true);
|
|
|
}
|
|
|
|
|
|
bool ctkLDAPSearchFilter::match(const ctkDictionary& dictionary) const
|
|
@@ -62,6 +77,11 @@ bool ctkLDAPSearchFilter::matchCase(const ctkDictionary& dictionary) const
|
|
|
return d->ldapExpr.evaluate(dictionary, true);
|
|
|
}
|
|
|
|
|
|
+QString ctkLDAPSearchFilter::toString() const
|
|
|
+{
|
|
|
+ return d->ldapExpr.toString();
|
|
|
+}
|
|
|
+
|
|
|
bool ctkLDAPSearchFilter::operator==(const ctkLDAPSearchFilter& other) const
|
|
|
{
|
|
|
return d->ldapExpr.toString() == other.d->ldapExpr.toString();
|
|
@@ -69,14 +89,13 @@ bool ctkLDAPSearchFilter::operator==(const ctkLDAPSearchFilter& other) const
|
|
|
|
|
|
ctkLDAPSearchFilter& ctkLDAPSearchFilter::operator=(const ctkLDAPSearchFilter& filter)
|
|
|
{
|
|
|
- if (d != filter.d)
|
|
|
- {
|
|
|
- if (!d->ref.deref())
|
|
|
- delete d;
|
|
|
-
|
|
|
- d = filter.d;
|
|
|
- d->ref.ref();
|
|
|
- }
|
|
|
+ d = filter.d;
|
|
|
|
|
|
return *this;
|
|
|
}
|
|
|
+
|
|
|
+QDebug operator<<(QDebug dbg, const ctkLDAPSearchFilter& filter)
|
|
|
+{
|
|
|
+ dbg << filter.toString();
|
|
|
+ return dbg.maybeSpace();
|
|
|
+}
|