ustringtrie.h 3.0 KB

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