1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 *******************************************************************************
5 * Copyright (C) 2011, International Business Machines
6 * Corporation and others. All Rights Reserved.
7 *******************************************************************************
8 * file name: patternprops.h
10 * tab size: 8 (not used)
13 * created on: 2011mar13
14 * created by: Markus W. Scherer
17 #ifndef __PATTERNPROPS_H__
18 #define __PATTERNPROPS_H__
20 #include "unicode/unistr.h"
21 #include "unicode/utypes.h"
26 * Implements the immutable Unicode properties Pattern_Syntax and Pattern_White_Space.
27 * Hardcodes these properties, does not load data, does not depend on other ICU classes.
29 * Note: Both properties include ASCII as well as non-ASCII, non-Latin-1 code points,
30 * and both properties only include BMP code points (no supplementary ones).
31 * Pattern_Syntax includes some unassigned code points.
33 * [:Pattern_White_Space:] =
34 * [\u0009-\u000D\ \u0085\u200E\u200F\u2028\u2029]
36 * [:Pattern_Syntax:] =
37 * [!-/\:-@\[-\^`\{-~\u00A1-\u00A7\u00A9\u00AB\u00AC\u00AE
38 * \u00B0\u00B1\u00B6\u00BB\u00BF\u00D7\u00F7
39 * \u2010-\u2027\u2030-\u203E\u2041-\u2053\u2055-\u205E
40 * \u2190-\u245F\u2500-\u2775\u2794-\u2BFF\u2E00-\u2E7F
41 * \u3001-\u3003\u3008-\u3020\u3030\uFD3E\uFD3F\uFE45\uFE46]
44 class U_COMMON_API PatternProps
{
47 * @return TRUE if c is a Pattern_Syntax code point.
49 static UBool
isSyntax(UChar32 c
);
52 * @return TRUE if c is a Pattern_Syntax or Pattern_White_Space code point.
54 static UBool
isSyntaxOrWhiteSpace(UChar32 c
);
57 * @return TRUE if c is a Pattern_White_Space character.
59 static UBool
isWhiteSpace(UChar32 c
);
62 * Skips over Pattern_White_Space starting at s.
63 * @return The smallest pointer at or after s with a non-white space character.
65 static const UChar
*skipWhiteSpace(const UChar
*s
, int32_t length
);
68 * Skips over Pattern_White_Space starting at index start in s.
69 * @return The smallest index at or after start with a non-white space character.
71 static int32_t skipWhiteSpace(const UnicodeString
&s
, int32_t start
);
74 * @return s except with leading and trailing Pattern_White_Space removed and length adjusted.
76 static const UChar
*trimWhiteSpace(const UChar
*s
, int32_t &length
);
79 * Tests whether the string contains a "pattern identifier", that is,
80 * whether it contains only non-Pattern_White_Space, non-Pattern_Syntax characters.
81 * @return TRUE if there are no Pattern_White_Space or Pattern_Syntax characters in s.
83 static UBool
isIdentifier(const UChar
*s
, int32_t length
);
86 * Skips over a "pattern identifier" starting at index s.
87 * @return The smallest pointer at or after s with
88 * a Pattern_White_Space or Pattern_Syntax character.
90 static const UChar
*skipIdentifier(const UChar
*s
, int32_t length
);
93 PatternProps(); // no constructor: all static methods
98 #endif // __PATTERNPROPS_H__