Collator.h 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /*
  2. * Copyright (c) 2024, Tim Flynn <trflynn89@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/NonnullOwnPtr.h>
  8. #include <AK/StringView.h>
  9. namespace Unicode {
  10. enum class Usage {
  11. Sort,
  12. Search,
  13. };
  14. Usage usage_from_string(StringView);
  15. StringView usage_to_string(Usage);
  16. enum class Sensitivity {
  17. Base,
  18. Accent,
  19. Case,
  20. Variant,
  21. };
  22. Sensitivity sensitivity_from_string(StringView);
  23. StringView sensitivity_to_string(Sensitivity);
  24. enum class CaseFirst {
  25. Upper,
  26. Lower,
  27. False,
  28. };
  29. CaseFirst case_first_from_string(StringView);
  30. StringView case_first_to_string(CaseFirst);
  31. class Collator {
  32. public:
  33. static NonnullOwnPtr<Collator> create(
  34. StringView locale,
  35. Usage,
  36. StringView collation,
  37. Sensitivity,
  38. CaseFirst,
  39. bool numeric,
  40. bool ignore_punctuation);
  41. virtual ~Collator() = default;
  42. enum class Order {
  43. Before,
  44. Equal,
  45. After,
  46. };
  47. virtual Order compare(StringView, StringView) const = 0;
  48. protected:
  49. Collator() = default;
  50. };
  51. }