ctkLDAPSearchFilter.cpp 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. /*=============================================================================
  2. Library: CTK
  3. Copyright (c) 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_p.h"
  17. #include "ctkServiceReferencePrivate.h"
  18. class ctkLDAPSearchFilterData : public QSharedData
  19. {
  20. public:
  21. ctkLDAPSearchFilterData()
  22. {}
  23. ctkLDAPSearchFilterData(const QString& filter)
  24. : ldapExpr(filter)
  25. {}
  26. ctkLDAPSearchFilterData(const ctkLDAPSearchFilterData& other)
  27. : QSharedData(other), ldapExpr(other.ldapExpr)
  28. {}
  29. ctkLDAPExpr ldapExpr;
  30. };
  31. ctkLDAPSearchFilter::ctkLDAPSearchFilter()
  32. : d(new ctkLDAPSearchFilterData())
  33. {
  34. }
  35. ctkLDAPSearchFilter::ctkLDAPSearchFilter(const QString& filter)
  36. : d(new ctkLDAPSearchFilterData(filter))
  37. {
  38. }
  39. ctkLDAPSearchFilter::ctkLDAPSearchFilter(const ctkLDAPSearchFilter& other)
  40. : d(other.d)
  41. {
  42. }
  43. ctkLDAPSearchFilter::~ctkLDAPSearchFilter()
  44. {
  45. }
  46. bool ctkLDAPSearchFilter::match(const ctkServiceReference& reference) const
  47. {
  48. return d->ldapExpr.evaluate(reference.d_func()->getProperties(), true);
  49. }
  50. bool ctkLDAPSearchFilter::match(const ctkDictionary& dictionary) const
  51. {
  52. return d->ldapExpr.evaluate(dictionary, false);
  53. }
  54. bool ctkLDAPSearchFilter::matchCase(const ctkDictionary& dictionary) const
  55. {
  56. return d->ldapExpr.evaluate(dictionary, true);
  57. }
  58. QString ctkLDAPSearchFilter::toString() const
  59. {
  60. return d->ldapExpr.toString();
  61. }
  62. bool ctkLDAPSearchFilter::operator==(const ctkLDAPSearchFilter& other) const
  63. {
  64. return d->ldapExpr.toString() == other.d->ldapExpr.toString();
  65. }
  66. ctkLDAPSearchFilter& ctkLDAPSearchFilter::operator=(const ctkLDAPSearchFilter& filter)
  67. {
  68. d = filter.d;
  69. return *this;
  70. }
  71. QDebug operator<<(QDebug dbg, const ctkLDAPSearchFilter& filter)
  72. {
  73. dbg << filter.toString();
  74. return dbg.maybeSpace();
  75. }