2 *******************************************************************************
3 * Copyright (C) 2010-2012, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 *******************************************************************************
6 * file name: udicttrie.h
8 * tab size: 8 (not used)
11 * created on: 2010dec17
12 * created by: Markus W. Scherer
15 #ifndef __USTRINGTRIE_H__
16 #define __USTRINGTRIE_H__
20 * \brief C API: Helper definitions for dictionary trie APIs.
23 #include "unicode/utypes.h"
27 * Return values for BytesTrie::next(), UCharsTrie::next() and similar methods.
28 * @see USTRINGTRIE_MATCHES
29 * @see USTRINGTRIE_HAS_VALUE
30 * @see USTRINGTRIE_HAS_NEXT
33 enum UStringTrieResult
{
35 * The input unit(s) did not continue a matching string.
36 * Once current()/next() return USTRINGTRIE_NO_MATCH,
37 * all further calls to current()/next() will also return USTRINGTRIE_NO_MATCH,
38 * until the trie is reset to its original state or to a saved state.
43 * The input unit(s) continued a matching string
44 * but there is no value for the string so far.
45 * (It is a prefix of a longer string.)
50 * The input unit(s) continued a matching string
51 * and there is a value for the string so far.
52 * This value will be returned by getValue().
53 * No further input byte/unit can continue a matching string.
56 USTRINGTRIE_FINAL_VALUE
,
58 * The input unit(s) continued a matching string
59 * and there is a value for the string so far.
60 * This value will be returned by getValue().
61 * Another input byte/unit can continue a matching string.
64 USTRINGTRIE_INTERMEDIATE_VALUE
68 * Same as (result!=USTRINGTRIE_NO_MATCH).
69 * @param result A result from BytesTrie::first(), UCharsTrie::next() etc.
70 * @return true if the input bytes/units so far are part of a matching string/byte sequence.
73 #define USTRINGTRIE_MATCHES(result) ((result)!=USTRINGTRIE_NO_MATCH)
76 * Equivalent to (result==USTRINGTRIE_INTERMEDIATE_VALUE || result==USTRINGTRIE_FINAL_VALUE) but
77 * this macro evaluates result exactly once.
78 * @param result A result from BytesTrie::first(), UCharsTrie::next() etc.
79 * @return true if there is a value for the input bytes/units so far.
80 * @see BytesTrie::getValue
81 * @see UCharsTrie::getValue
84 #define USTRINGTRIE_HAS_VALUE(result) ((result)>=USTRINGTRIE_FINAL_VALUE)
87 * Equivalent to (result==USTRINGTRIE_NO_VALUE || result==USTRINGTRIE_INTERMEDIATE_VALUE) but
88 * this macro evaluates result exactly once.
89 * @param result A result from BytesTrie::first(), UCharsTrie::next() etc.
90 * @return true if another input byte/unit can continue a matching string.
93 #define USTRINGTRIE_HAS_NEXT(result) ((result)&1)
95 #endif /* __USTRINGTRIE_H__ */