patternprops.h 3.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  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. #ifndef __PATTERNPROPS_H__
  17. #define __PATTERNPROPS_H__
  18. #include "unicode/unistr.h"
  19. #include "unicode/utypes.h"
  20. U_NAMESPACE_BEGIN
  21. /**
  22. * Implements the immutable Unicode properties Pattern_Syntax and Pattern_White_Space.
  23. * Hardcodes these properties, does not load data, does not depend on other ICU classes.
  24. * <p>
  25. * Note: Both properties include ASCII as well as non-ASCII, non-Latin-1 code points,
  26. * and both properties only include BMP code points (no supplementary ones).
  27. * Pattern_Syntax includes some unassigned code points.
  28. * <p>
  29. * [:Pattern_White_Space:] =
  30. * [\u0009-\u000D\ \u0085\u200E\u200F\u2028\u2029]
  31. * <p>
  32. * [:Pattern_Syntax:] =
  33. * [!-/\:-@\[-\^`\{-~\u00A1-\u00A7\u00A9\u00AB\u00AC\u00AE
  34. * \u00B0\u00B1\u00B6\u00BB\u00BF\u00D7\u00F7
  35. * \u2010-\u2027\u2030-\u203E\u2041-\u2053\u2055-\u205E
  36. * \u2190-\u245F\u2500-\u2775\u2794-\u2BFF\u2E00-\u2E7F
  37. * \u3001-\u3003\u3008-\u3020\u3030\uFD3E\uFD3F\uFE45\uFE46]
  38. * @author mscherer
  39. */
  40. class U_COMMON_API PatternProps {
  41. public:
  42. /**
  43. * @return TRUE if c is a Pattern_Syntax code point.
  44. */
  45. static UBool isSyntax(UChar32 c);
  46. /**
  47. * @return TRUE if c is a Pattern_Syntax or Pattern_White_Space code point.
  48. */
  49. static UBool isSyntaxOrWhiteSpace(UChar32 c);
  50. /**
  51. * @return TRUE if c is a Pattern_White_Space character.
  52. */
  53. static UBool isWhiteSpace(UChar32 c);
  54. /**
  55. * Skips over Pattern_White_Space starting at s.
  56. * @return The smallest pointer at or after s with a non-white space character.
  57. */
  58. static const UChar *skipWhiteSpace(const UChar *s, int32_t length);
  59. /**
  60. * Skips over Pattern_White_Space starting at index start in s.
  61. * @return The smallest index at or after start with a non-white space character.
  62. */
  63. static int32_t skipWhiteSpace(const UnicodeString &s, int32_t start);
  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. * Tests whether the string contains a "pattern identifier", that is,
  70. * whether it contains only non-Pattern_White_Space, non-Pattern_Syntax characters.
  71. * @return TRUE if there are no Pattern_White_Space or Pattern_Syntax characters in s.
  72. */
  73. static UBool isIdentifier(const UChar *s, int32_t length);
  74. /**
  75. * Skips over a "pattern identifier" starting at index s.
  76. * @return The smallest pointer at or after s with
  77. * a Pattern_White_Space or Pattern_Syntax character.
  78. */
  79. static const UChar *skipIdentifier(const UChar *s, int32_t length);
  80. private:
  81. PatternProps(); // no constructor: all static methods
  82. };
  83. U_NAMESPACE_END
  84. #endif // __PATTERNPROPS_H__