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