| 1 |
// © 2016 and later: Unicode, Inc. and others. |
| 2 |
// License & terms of use: http://www.unicode.org/copyright.html |
| 3 |
/* |
| 4 |
******************************************************************************* |
| 5 |
* Copyright (C) 2011, International Business Machines |
| 6 |
* Corporation and others. All Rights Reserved. |
| 7 |
******************************************************************************* |
| 8 |
* file name: patternprops.h |
| 9 |
* encoding: UTF-8 |
| 10 |
* 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 |
|
| 20 |
#include "unicode/unistr.h" |
| 21 |
#include "unicode/utypes.h" |
| 22 |
|
| 23 |
U_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 |
*/ |
| 44 |
class U_COMMON_API PatternProps { |
| 45 |
public: |
| 46 |
/** |
| 47 |
* @return true if c is a Pattern_Syntax code point. |
| 48 |
*/ |
| 49 |
static UBool isSyntax(UChar32 c); |
| 50 |
|
| 51 |
/** |
| 52 |
* @return true if c is a Pattern_Syntax or Pattern_White_Space code point. |
| 53 |
*/ |
| 54 |
static UBool isSyntaxOrWhiteSpace(UChar32 c); |
| 55 |
|
| 56 |
/** |
| 57 |
* @return true if c is a Pattern_White_Space character. |
| 58 |
*/ |
| 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 char16_t *skipWhiteSpace(const char16_t *s, int32_t length); |
| 66 |
|
| 67 |
/** |
| 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. |
| 70 |
*/ |
| 71 |
static int32_t skipWhiteSpace(const UnicodeString &s, int32_t start); |
| 72 |
|
| 73 |
/** |
| 74 |
* @return s except with leading and trailing Pattern_White_Space removed and length adjusted. |
| 75 |
*/ |
| 76 |
static const char16_t *trimWhiteSpace(const char16_t *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. |
| 81 |
* @return true if there are no Pattern_White_Space or Pattern_Syntax characters in s. |
| 82 |
*/ |
| 83 |
static UBool isIdentifier(const char16_t *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 char16_t *skipIdentifier(const char16_t *s, int32_t length); |
| 91 |
|
| 92 |
private: |
| 93 |
PatternProps() = delete; // no constructor: all static methods |
| 94 |
}; |
| 95 |
|
| 96 |
U_NAMESPACE_END |
| 97 |
|
| 98 |
#endif // __PATTERNPROPS_H__ |