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