PartitionRange.h 814 B

12345678910111213141516171819202122232425262728293031323334353637
  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/Types.h>
  8. namespace Unicode {
  9. struct PartitionRange {
  10. // ICU does not contain a field enumeration for "literal" partitions. Define a custom field so that we may provide
  11. // a type for those partitions.
  12. static constexpr i32 LITERAL_FIELD = -1;
  13. constexpr bool contains(i32 position) const
  14. {
  15. return start <= position && position < end;
  16. }
  17. constexpr bool operator<(PartitionRange const& other) const
  18. {
  19. if (start < other.start)
  20. return true;
  21. if (start == other.start)
  22. return end > other.end;
  23. return false;
  24. }
  25. i32 field { LITERAL_FIELD };
  26. i32 start { 0 };
  27. i32 end { 0 };
  28. };
  29. }