ctkLDAPSearchFilter.cpp 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*=============================================================================
  2. Library: CTK
  3. Copyright (c) 2010 German Cancer Research Center,
  4. Division of Medical and Biological Informatics
  5. Licensed under the Apache License, Version 2.0 (the "License");
  6. you may not use this file except in compliance with the License.
  7. You may obtain a copy of the License at
  8. http://www.apache.org/licenses/LICENSE-2.0
  9. Unless required by applicable law or agreed to in writing, software
  10. distributed under the License is distributed on an "AS IS" BASIS,
  11. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. See the License for the specific language governing permissions and
  13. limitations under the License.
  14. =============================================================================*/
  15. #include "ctkLDAPSearchFilter.h"
  16. #include "ctkLDAPExpr.h"
  17. class ctkLDAPSearchFilterPrivate {
  18. public:
  19. ctkLDAPSearchFilterPrivate(const QString& filter)
  20. : ref(1), ldapExpr(filter)
  21. {}
  22. QAtomicInt ref;
  23. ctkLDAPExpr ldapExpr;
  24. };
  25. ctkLDAPSearchFilter::ctkLDAPSearchFilter(const QString& filter)
  26. : d(new ctkLDAPSearchFilterPrivate(filter))
  27. {
  28. }
  29. ctkLDAPSearchFilter::ctkLDAPSearchFilter(const ctkLDAPSearchFilter& filter)
  30. : d(filter.d)
  31. {
  32. d->ref.ref();
  33. }
  34. ctkLDAPSearchFilter::~ctkLDAPSearchFilter()
  35. {
  36. if (!d->ref.deref())
  37. delete d;
  38. }
  39. bool ctkLDAPSearchFilter::match(const ctkDictionary& dictionary) const
  40. {
  41. return d->ldapExpr.evaluate(dictionary, false);
  42. }
  43. bool ctkLDAPSearchFilter::matchCase(const ctkDictionary& dictionary) const
  44. {
  45. return d->ldapExpr.evaluate(dictionary, true);
  46. }
  47. bool ctkLDAPSearchFilter::operator==(const ctkLDAPSearchFilter& other) const
  48. {
  49. return d->ldapExpr.toString() == other.d->ldapExpr.toString();
  50. }
  51. ctkLDAPSearchFilter& ctkLDAPSearchFilter::operator=(const ctkLDAPSearchFilter& filter)
  52. {
  53. if (d != filter.d)
  54. {
  55. if (!d->ref.deref())
  56. delete d;
  57. d = filter.d;
  58. d->ref.ref();
  59. }
  60. return *this;
  61. }