1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 *******************************************************************************
5 * Copyright (C) 2010-2012, International Business Machines
6 * Corporation and others. All Rights Reserved.
7 *******************************************************************************
8 * file name: udicttrie.h
10 * tab size: 8 (not used)
13 * created on: 2010dec17
14 * created by: Markus W. Scherer
17 #ifndef __USTRINGTRIE_H__
18 #define __USTRINGTRIE_H__
22 * \brief C API: Helper definitions for dictionary trie APIs.
25 #include "unicode/utypes.h"
29 * Return values for BytesTrie::next(), UCharsTrie::next() and similar methods.
30 * @see USTRINGTRIE_MATCHES
31 * @see USTRINGTRIE_HAS_VALUE
32 * @see USTRINGTRIE_HAS_NEXT
35 enum UStringTrieResult
{
37 * The input unit(s) did not continue a matching string.
38 * Once current()/next() return USTRINGTRIE_NO_MATCH,
39 * all further calls to current()/next() will also return USTRINGTRIE_NO_MATCH,
40 * until the trie is reset to its original state or to a saved state.
45 * The input unit(s) continued a matching string
46 * but there is no value for the string so far.
47 * (It is a prefix of a longer string.)
52 * The input unit(s) continued a matching string
53 * and there is a value for the string so far.
54 * This value will be returned by getValue().
55 * No further input byte/unit can continue a matching string.
58 USTRINGTRIE_FINAL_VALUE
,
60 * The input unit(s) continued a matching string
61 * and there is a value for the string so far.
62 * This value will be returned by getValue().
63 * Another input byte/unit can continue a matching string.
66 USTRINGTRIE_INTERMEDIATE_VALUE
70 * Same as (result!=USTRINGTRIE_NO_MATCH).
71 * @param result A result from BytesTrie::first(), UCharsTrie::next() etc.
72 * @return true if the input bytes/units so far are part of a matching string/byte sequence.
75 #define USTRINGTRIE_MATCHES(result) ((result)!=USTRINGTRIE_NO_MATCH)
78 * Equivalent to (result==USTRINGTRIE_INTERMEDIATE_VALUE || result==USTRINGTRIE_FINAL_VALUE) but
79 * this macro evaluates result exactly once.
80 * @param result A result from BytesTrie::first(), UCharsTrie::next() etc.
81 * @return true if there is a value for the input bytes/units so far.
82 * @see BytesTrie::getValue
83 * @see UCharsTrie::getValue
86 #define USTRINGTRIE_HAS_VALUE(result) ((result)>=USTRINGTRIE_FINAL_VALUE)
89 * Equivalent to (result==USTRINGTRIE_NO_VALUE || result==USTRINGTRIE_INTERMEDIATE_VALUE) but
90 * this macro evaluates result exactly once.
91 * @param result A result from BytesTrie::first(), UCharsTrie::next() etc.
92 * @return true if another input byte/unit can continue a matching string.
95 #define USTRINGTRIE_HAS_NEXT(result) ((result)&1)
97 #endif /* __USTRINGTRIE_H__ */