ctkCaseInsensitiveString.cpp 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  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 "ctkCaseInsensitiveString.h"
  16. #include <QHash> // for qHash(const QString&)
  17. ctkCaseInsensitiveString::ctkCaseInsensitiveString()
  18. {
  19. }
  20. ctkCaseInsensitiveString::ctkCaseInsensitiveString(const QString& str)
  21. : str(str)
  22. {
  23. }
  24. ctkCaseInsensitiveString::ctkCaseInsensitiveString(const ctkCaseInsensitiveString& str)
  25. : str(str.str)
  26. {
  27. }
  28. ctkCaseInsensitiveString& ctkCaseInsensitiveString::operator=(const ctkCaseInsensitiveString& str)
  29. {
  30. this->str = str.str;
  31. return *this;
  32. }
  33. bool ctkCaseInsensitiveString::operator==(const ctkCaseInsensitiveString& str) const
  34. {
  35. return this->str.toLower() == str.str.toLower();
  36. }
  37. bool ctkCaseInsensitiveString::operator<(const ctkCaseInsensitiveString& str) const
  38. {
  39. return this->str.toLower() < str.str.toLower();
  40. }
  41. ctkCaseInsensitiveString::operator QString() const
  42. {
  43. return this->str;
  44. }
  45. uint qHash(const ctkCaseInsensitiveString& str)
  46. {
  47. return qHash(QString(str).toLower());
  48. }