CaseInsensitive.h 1.6 KB

1234567891011121314151617181920212223242526272829
  1. //-------------------------------------------------------------------------------------------------------
  2. // Copyright (C) Microsoft. All rights reserved.
  3. // Licensed under the MIT license. See LICENSE.txt file in the project root for full license information.
  4. //-------------------------------------------------------------------------------------------------------
  5. namespace UnifiedRegex
  6. {
  7. namespace CaseInsensitive
  8. {
  9. // It turns out there are many upper-case characters with three lower-case variants, thus
  10. // the maximum size of an equivalence class is four.
  11. static const int EquivClassSize = 4;
  12. enum class MappingSource : uint8
  13. {
  14. UnicodeData,
  15. CaseFolding
  16. };
  17. // Following two functions return equivalents from UnicodeData (for char16) and CaseFolding
  18. // (for codepoint_t) files. Their names don't have anything distinguishing them so that
  19. // they can be called easily from template functions.
  20. bool RangeToEquivClass(uint& tblidx, uint l, uint h, uint& acth, __out_ecount(EquivClassSize) char16 equivl[EquivClassSize]);
  21. bool RangeToEquivClass(uint& tblidx, uint l, uint h, uint& acth, __out_ecount(EquivClassSize) codepoint_t equivl[EquivClassSize]);
  22. // Returns equivalents only from the given source. Some case-folding mappings already exist in
  23. // UnicodeData, so this function doesn't return them when CaseFolding is passed as the source.
  24. bool RangeToEquivClassOnlyInSource(MappingSource mappingSource, uint& tblidx, uint l, uint h, uint& acth, __out_ecount(EquivClassSize) char16 equivl[EquivClassSize]);
  25. }
  26. }