|
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 |
|
15 #ifndef __USTRINGTRIE_H__ |
|
16 #define __USTRINGTRIE_H__ |
|
17 |
|
18 /** |
|
19 * \file |
|
20 * \brief C API: Helper definitions for dictionary trie APIs. |
|
21 */ |
|
22 |
|
23 #include "unicode/utypes.h" |
|
24 |
|
25 |
|
26 /** |
|
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 |
|
31 * @stable ICU 4.8 |
|
32 */ |
|
33 enum UStringTrieResult { |
|
34 /** |
|
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. |
|
39 * @stable ICU 4.8 |
|
40 */ |
|
41 USTRINGTRIE_NO_MATCH, |
|
42 /** |
|
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.) |
|
46 * @stable ICU 4.8 |
|
47 */ |
|
48 USTRINGTRIE_NO_VALUE, |
|
49 /** |
|
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. |
|
54 * @stable ICU 4.8 |
|
55 */ |
|
56 USTRINGTRIE_FINAL_VALUE, |
|
57 /** |
|
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. |
|
62 * @stable ICU 4.8 |
|
63 */ |
|
64 USTRINGTRIE_INTERMEDIATE_VALUE |
|
65 }; |
|
66 |
|
67 /** |
|
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. |
|
71 * @stable ICU 4.8 |
|
72 */ |
|
73 #define USTRINGTRIE_MATCHES(result) ((result)!=USTRINGTRIE_NO_MATCH) |
|
74 |
|
75 /** |
|
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 |
|
82 * @stable ICU 4.8 |
|
83 */ |
|
84 #define USTRINGTRIE_HAS_VALUE(result) ((result)>=USTRINGTRIE_FINAL_VALUE) |
|
85 |
|
86 /** |
|
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. |
|
91 * @stable ICU 4.8 |
|
92 */ |
|
93 #define USTRINGTRIE_HAS_NEXT(result) ((result)&1) |
|
94 |
|
95 #endif /* __USTRINGTRIE_H__ */ |