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