blob: 4ead56e1cdb3648dc08cb7120b7a7c561838faa7 [file] [log] [blame]
Jungshik Shin87232d82017-05-13 21:10:13 -07001// © 2016 and later: Unicode, Inc. and others.
Jungshik Shin5feb9ad2016-10-21 12:52:48 -07002// License & terms of use: http://www.unicode.org/copyright.html
jshin@chromium.org6f31ac32014-03-26 22:15:14 +00003/*
4*******************************************************************************
5* Copyright (C) 2011, International Business Machines
6* Corporation and others. All Rights Reserved.
7*******************************************************************************
8* file name: patternprops.h
Jungshik Shin87232d82017-05-13 21:10:13 -07009* encoding: UTF-8
jshin@chromium.org6f31ac32014-03-26 22:15:14 +000010* tab size: 8 (not used)
11* indentation:4
12*
13* created on: 2011mar13
14* created by: Markus W. Scherer
15*/
16
17#ifndef __PATTERNPROPS_H__
18#define __PATTERNPROPS_H__
19
Frank Tang69c72a62019-04-03 21:41:21 -070020#include "unicode/unistr.h"
jshin@chromium.org6f31ac32014-03-26 22:15:14 +000021#include "unicode/utypes.h"
22
23U_NAMESPACE_BEGIN
24
25/**
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.
28 * <p>
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.
32 * <p>
33 * [:Pattern_White_Space:] =
34 * [\u0009-\u000D\ \u0085\u200E\u200F\u2028\u2029]
35 * <p>
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]
42 * @author mscherer
43 */
44class U_COMMON_API PatternProps {
45public:
46 /**
Frank Tangf90543d2020-10-30 19:02:04 -070047 * @return true if c is a Pattern_Syntax code point.
jshin@chromium.org6f31ac32014-03-26 22:15:14 +000048 */
49 static UBool isSyntax(UChar32 c);
50
51 /**
Frank Tangf90543d2020-10-30 19:02:04 -070052 * @return true if c is a Pattern_Syntax or Pattern_White_Space code point.
jshin@chromium.org6f31ac32014-03-26 22:15:14 +000053 */
54 static UBool isSyntaxOrWhiteSpace(UChar32 c);
55
56 /**
Frank Tangf90543d2020-10-30 19:02:04 -070057 * @return true if c is a Pattern_White_Space character.
jshin@chromium.org6f31ac32014-03-26 22:15:14 +000058 */
59 static UBool isWhiteSpace(UChar32 c);
60
61 /**
62 * Skips over Pattern_White_Space starting at s.
63 * @return The smallest pointer at or after s with a non-white space character.
64 */
65 static const UChar *skipWhiteSpace(const UChar *s, int32_t length);
66
67 /**
Frank Tang69c72a62019-04-03 21:41:21 -070068 * 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.
70 */
71 static int32_t skipWhiteSpace(const UnicodeString &s, int32_t start);
72
73 /**
jshin@chromium.org6f31ac32014-03-26 22:15:14 +000074 * @return s except with leading and trailing Pattern_White_Space removed and length adjusted.
75 */
76 static const UChar *trimWhiteSpace(const UChar *s, int32_t &length);
77
78 /**
79 * Tests whether the string contains a "pattern identifier", that is,
80 * whether it contains only non-Pattern_White_Space, non-Pattern_Syntax characters.
Frank Tangf90543d2020-10-30 19:02:04 -070081 * @return true if there are no Pattern_White_Space or Pattern_Syntax characters in s.
jshin@chromium.org6f31ac32014-03-26 22:15:14 +000082 */
83 static UBool isIdentifier(const UChar *s, int32_t length);
84
85 /**
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.
89 */
90 static const UChar *skipIdentifier(const UChar *s, int32_t length);
91
92private:
Frank Tang1f164ee2022-11-08 12:31:27 -080093 PatternProps() = delete; // no constructor: all static methods
jshin@chromium.org6f31ac32014-03-26 22:15:14 +000094};
95
96U_NAMESPACE_END
97
98#endif // __PATTERNPROPS_H__