ustringtrie.h 3.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. // © 2016 and later: Unicode, Inc. and others.
  2. // License & terms of use: http://www.unicode.org/copyright.html
  3. /*
  4. *******************************************************************************
  5. * Copyright (C) 2010-2012, International Business Machines
  6. * Corporation and others. All Rights Reserved.
  7. *******************************************************************************
  8. * file name: udicttrie.h
  9. * encoding: UTF-8
  10. * tab size: 8 (not used)
  11. * indentation:4
  12. *
  13. * created on: 2010dec17
  14. * created by: Markus W. Scherer
  15. */
  16. #ifndef __USTRINGTRIE_H__
  17. #define __USTRINGTRIE_H__
  18. /**
  19. * \file
  20. * \brief C API: Helper definitions for dictionary trie APIs.
  21. */
  22. #include "unicode/utypes.h"
  23. /**
  24. * Return values for BytesTrie::next(), UCharsTrie::next() and similar methods.
  25. * @see USTRINGTRIE_MATCHES
  26. * @see USTRINGTRIE_HAS_VALUE
  27. * @see USTRINGTRIE_HAS_NEXT
  28. * @stable ICU 4.8
  29. */
  30. enum UStringTrieResult {
  31. /**
  32. * The input unit(s) did not continue a matching string.
  33. * Once current()/next() return USTRINGTRIE_NO_MATCH,
  34. * all further calls to current()/next() will also return USTRINGTRIE_NO_MATCH,
  35. * until the trie is reset to its original state or to a saved state.
  36. * @stable ICU 4.8
  37. */
  38. USTRINGTRIE_NO_MATCH,
  39. /**
  40. * The input unit(s) continued a matching string
  41. * but there is no value for the string so far.
  42. * (It is a prefix of a longer string.)
  43. * @stable ICU 4.8
  44. */
  45. USTRINGTRIE_NO_VALUE,
  46. /**
  47. * The input unit(s) continued a matching string
  48. * and there is a value for the string so far.
  49. * This value will be returned by getValue().
  50. * No further input byte/unit can continue a matching string.
  51. * @stable ICU 4.8
  52. */
  53. USTRINGTRIE_FINAL_VALUE,
  54. /**
  55. * The input unit(s) continued a matching string
  56. * and there is a value for the string so far.
  57. * This value will be returned by getValue().
  58. * Another input byte/unit can continue a matching string.
  59. * @stable ICU 4.8
  60. */
  61. USTRINGTRIE_INTERMEDIATE_VALUE
  62. };
  63. /**
  64. * Same as (result!=USTRINGTRIE_NO_MATCH).
  65. * @param result A result from BytesTrie::first(), UCharsTrie::next() etc.
  66. * @return true if the input bytes/units so far are part of a matching string/byte sequence.
  67. * @stable ICU 4.8
  68. */
  69. #define USTRINGTRIE_MATCHES(result) ((result)!=USTRINGTRIE_NO_MATCH)
  70. /**
  71. * Equivalent to (result==USTRINGTRIE_INTERMEDIATE_VALUE || result==USTRINGTRIE_FINAL_VALUE) but
  72. * this macro evaluates result exactly once.
  73. * @param result A result from BytesTrie::first(), UCharsTrie::next() etc.
  74. * @return true if there is a value for the input bytes/units so far.
  75. * @see BytesTrie::getValue
  76. * @see UCharsTrie::getValue
  77. * @stable ICU 4.8
  78. */
  79. #define USTRINGTRIE_HAS_VALUE(result) ((result)>=USTRINGTRIE_FINAL_VALUE)
  80. /**
  81. * Equivalent to (result==USTRINGTRIE_NO_VALUE || result==USTRINGTRIE_INTERMEDIATE_VALUE) but
  82. * this macro evaluates result exactly once.
  83. * @param result A result from BytesTrie::first(), UCharsTrie::next() etc.
  84. * @return true if another input byte/unit can continue a matching string.
  85. * @stable ICU 4.8
  86. */
  87. #define USTRINGTRIE_HAS_NEXT(result) ((result)&1)
  88. #endif /* __USTRINGTRIE_H__ */