xref: /aosp_15_r20/external/icu/libicu/cts_headers/patternprops.h (revision 0e209d3975ff4a8c132096b14b0e9364a753506e)
1*0e209d39SAndroid Build Coastguard Worker // © 2016 and later: Unicode, Inc. and others.
2*0e209d39SAndroid Build Coastguard Worker // License & terms of use: http://www.unicode.org/copyright.html
3*0e209d39SAndroid Build Coastguard Worker /*
4*0e209d39SAndroid Build Coastguard Worker *******************************************************************************
5*0e209d39SAndroid Build Coastguard Worker *   Copyright (C) 2011, International Business Machines
6*0e209d39SAndroid Build Coastguard Worker *   Corporation and others.  All Rights Reserved.
7*0e209d39SAndroid Build Coastguard Worker *******************************************************************************
8*0e209d39SAndroid Build Coastguard Worker *   file name:  patternprops.h
9*0e209d39SAndroid Build Coastguard Worker *   encoding:   UTF-8
10*0e209d39SAndroid Build Coastguard Worker *   tab size:   8 (not used)
11*0e209d39SAndroid Build Coastguard Worker *   indentation:4
12*0e209d39SAndroid Build Coastguard Worker *
13*0e209d39SAndroid Build Coastguard Worker *   created on: 2011mar13
14*0e209d39SAndroid Build Coastguard Worker *   created by: Markus W. Scherer
15*0e209d39SAndroid Build Coastguard Worker */
16*0e209d39SAndroid Build Coastguard Worker 
17*0e209d39SAndroid Build Coastguard Worker #ifndef __PATTERNPROPS_H__
18*0e209d39SAndroid Build Coastguard Worker #define __PATTERNPROPS_H__
19*0e209d39SAndroid Build Coastguard Worker 
20*0e209d39SAndroid Build Coastguard Worker #include "unicode/unistr.h"
21*0e209d39SAndroid Build Coastguard Worker #include "unicode/utypes.h"
22*0e209d39SAndroid Build Coastguard Worker 
23*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_BEGIN
24*0e209d39SAndroid Build Coastguard Worker 
25*0e209d39SAndroid Build Coastguard Worker /**
26*0e209d39SAndroid Build Coastguard Worker  * Implements the immutable Unicode properties Pattern_Syntax and Pattern_White_Space.
27*0e209d39SAndroid Build Coastguard Worker  * Hardcodes these properties, does not load data, does not depend on other ICU classes.
28*0e209d39SAndroid Build Coastguard Worker  * <p>
29*0e209d39SAndroid Build Coastguard Worker  * Note: Both properties include ASCII as well as non-ASCII, non-Latin-1 code points,
30*0e209d39SAndroid Build Coastguard Worker  * and both properties only include BMP code points (no supplementary ones).
31*0e209d39SAndroid Build Coastguard Worker  * Pattern_Syntax includes some unassigned code points.
32*0e209d39SAndroid Build Coastguard Worker  * <p>
33*0e209d39SAndroid Build Coastguard Worker  * [:Pattern_White_Space:] =
34*0e209d39SAndroid Build Coastguard Worker  *   [\u0009-\u000D\ \u0085\u200E\u200F\u2028\u2029]
35*0e209d39SAndroid Build Coastguard Worker  * <p>
36*0e209d39SAndroid Build Coastguard Worker  * [:Pattern_Syntax:] =
37*0e209d39SAndroid Build Coastguard Worker  *   [!-/\:-@\[-\^`\{-~\u00A1-\u00A7\u00A9\u00AB\u00AC\u00AE
38*0e209d39SAndroid Build Coastguard Worker  *    \u00B0\u00B1\u00B6\u00BB\u00BF\u00D7\u00F7
39*0e209d39SAndroid Build Coastguard Worker  *    \u2010-\u2027\u2030-\u203E\u2041-\u2053\u2055-\u205E
40*0e209d39SAndroid Build Coastguard Worker  *    \u2190-\u245F\u2500-\u2775\u2794-\u2BFF\u2E00-\u2E7F
41*0e209d39SAndroid Build Coastguard Worker  *    \u3001-\u3003\u3008-\u3020\u3030\uFD3E\uFD3F\uFE45\uFE46]
42*0e209d39SAndroid Build Coastguard Worker  * @author mscherer
43*0e209d39SAndroid Build Coastguard Worker  */
44*0e209d39SAndroid Build Coastguard Worker class U_COMMON_API PatternProps {
45*0e209d39SAndroid Build Coastguard Worker public:
46*0e209d39SAndroid Build Coastguard Worker     /**
47*0e209d39SAndroid Build Coastguard Worker      * @return true if c is a Pattern_Syntax code point.
48*0e209d39SAndroid Build Coastguard Worker      */
49*0e209d39SAndroid Build Coastguard Worker     static UBool isSyntax(UChar32 c);
50*0e209d39SAndroid Build Coastguard Worker 
51*0e209d39SAndroid Build Coastguard Worker     /**
52*0e209d39SAndroid Build Coastguard Worker      * @return true if c is a Pattern_Syntax or Pattern_White_Space code point.
53*0e209d39SAndroid Build Coastguard Worker      */
54*0e209d39SAndroid Build Coastguard Worker     static UBool isSyntaxOrWhiteSpace(UChar32 c);
55*0e209d39SAndroid Build Coastguard Worker 
56*0e209d39SAndroid Build Coastguard Worker     /**
57*0e209d39SAndroid Build Coastguard Worker      * @return true if c is a Pattern_White_Space character.
58*0e209d39SAndroid Build Coastguard Worker      */
59*0e209d39SAndroid Build Coastguard Worker     static UBool isWhiteSpace(UChar32 c);
60*0e209d39SAndroid Build Coastguard Worker 
61*0e209d39SAndroid Build Coastguard Worker     /**
62*0e209d39SAndroid Build Coastguard Worker      * Skips over Pattern_White_Space starting at s.
63*0e209d39SAndroid Build Coastguard Worker      * @return The smallest pointer at or after s with a non-white space character.
64*0e209d39SAndroid Build Coastguard Worker      */
65*0e209d39SAndroid Build Coastguard Worker     static const char16_t *skipWhiteSpace(const char16_t *s, int32_t length);
66*0e209d39SAndroid Build Coastguard Worker 
67*0e209d39SAndroid Build Coastguard Worker     /**
68*0e209d39SAndroid Build Coastguard Worker      * Skips over Pattern_White_Space starting at index start in s.
69*0e209d39SAndroid Build Coastguard Worker      * @return The smallest index at or after start with a non-white space character.
70*0e209d39SAndroid Build Coastguard Worker      */
71*0e209d39SAndroid Build Coastguard Worker     static int32_t skipWhiteSpace(const UnicodeString &s, int32_t start);
72*0e209d39SAndroid Build Coastguard Worker 
73*0e209d39SAndroid Build Coastguard Worker     /**
74*0e209d39SAndroid Build Coastguard Worker      * @return s except with leading and trailing Pattern_White_Space removed and length adjusted.
75*0e209d39SAndroid Build Coastguard Worker      */
76*0e209d39SAndroid Build Coastguard Worker     static const char16_t *trimWhiteSpace(const char16_t *s, int32_t &length);
77*0e209d39SAndroid Build Coastguard Worker 
78*0e209d39SAndroid Build Coastguard Worker     /**
79*0e209d39SAndroid Build Coastguard Worker      * Tests whether the string contains a "pattern identifier", that is,
80*0e209d39SAndroid Build Coastguard Worker      * whether it contains only non-Pattern_White_Space, non-Pattern_Syntax characters.
81*0e209d39SAndroid Build Coastguard Worker      * @return true if there are no Pattern_White_Space or Pattern_Syntax characters in s.
82*0e209d39SAndroid Build Coastguard Worker      */
83*0e209d39SAndroid Build Coastguard Worker     static UBool isIdentifier(const char16_t *s, int32_t length);
84*0e209d39SAndroid Build Coastguard Worker 
85*0e209d39SAndroid Build Coastguard Worker     /**
86*0e209d39SAndroid Build Coastguard Worker      * Skips over a "pattern identifier" starting at index s.
87*0e209d39SAndroid Build Coastguard Worker      * @return The smallest pointer at or after s with
88*0e209d39SAndroid Build Coastguard Worker      *         a Pattern_White_Space or Pattern_Syntax character.
89*0e209d39SAndroid Build Coastguard Worker      */
90*0e209d39SAndroid Build Coastguard Worker     static const char16_t *skipIdentifier(const char16_t *s, int32_t length);
91*0e209d39SAndroid Build Coastguard Worker 
92*0e209d39SAndroid Build Coastguard Worker private:
93*0e209d39SAndroid Build Coastguard Worker     PatternProps() = delete;  // no constructor: all static methods
94*0e209d39SAndroid Build Coastguard Worker };
95*0e209d39SAndroid Build Coastguard Worker 
96*0e209d39SAndroid Build Coastguard Worker U_NAMESPACE_END
97*0e209d39SAndroid Build Coastguard Worker 
98*0e209d39SAndroid Build Coastguard Worker #endif  // __PATTERNPROPS_H__
99