michael@0: /* michael@0: ******************************************************************************* michael@0: * Copyright (C) 2010-2012, International Business Machines michael@0: * Corporation and others. All Rights Reserved. michael@0: ******************************************************************************* michael@0: * file name: udicttrie.h michael@0: * encoding: US-ASCII michael@0: * tab size: 8 (not used) michael@0: * indentation:4 michael@0: * michael@0: * created on: 2010dec17 michael@0: * created by: Markus W. Scherer michael@0: */ michael@0: michael@0: #ifndef __USTRINGTRIE_H__ michael@0: #define __USTRINGTRIE_H__ michael@0: michael@0: /** michael@0: * \file michael@0: * \brief C API: Helper definitions for dictionary trie APIs. michael@0: */ michael@0: michael@0: #include "unicode/utypes.h" michael@0: michael@0: michael@0: /** michael@0: * Return values for BytesTrie::next(), UCharsTrie::next() and similar methods. michael@0: * @see USTRINGTRIE_MATCHES michael@0: * @see USTRINGTRIE_HAS_VALUE michael@0: * @see USTRINGTRIE_HAS_NEXT michael@0: * @stable ICU 4.8 michael@0: */ michael@0: enum UStringTrieResult { michael@0: /** michael@0: * The input unit(s) did not continue a matching string. michael@0: * Once current()/next() return USTRINGTRIE_NO_MATCH, michael@0: * all further calls to current()/next() will also return USTRINGTRIE_NO_MATCH, michael@0: * until the trie is reset to its original state or to a saved state. michael@0: * @stable ICU 4.8 michael@0: */ michael@0: USTRINGTRIE_NO_MATCH, michael@0: /** michael@0: * The input unit(s) continued a matching string michael@0: * but there is no value for the string so far. michael@0: * (It is a prefix of a longer string.) michael@0: * @stable ICU 4.8 michael@0: */ michael@0: USTRINGTRIE_NO_VALUE, michael@0: /** michael@0: * The input unit(s) continued a matching string michael@0: * and there is a value for the string so far. michael@0: * This value will be returned by getValue(). michael@0: * No further input byte/unit can continue a matching string. michael@0: * @stable ICU 4.8 michael@0: */ michael@0: USTRINGTRIE_FINAL_VALUE, michael@0: /** michael@0: * The input unit(s) continued a matching string michael@0: * and there is a value for the string so far. michael@0: * This value will be returned by getValue(). michael@0: * Another input byte/unit can continue a matching string. michael@0: * @stable ICU 4.8 michael@0: */ michael@0: USTRINGTRIE_INTERMEDIATE_VALUE michael@0: }; michael@0: michael@0: /** michael@0: * Same as (result!=USTRINGTRIE_NO_MATCH). michael@0: * @param result A result from BytesTrie::first(), UCharsTrie::next() etc. michael@0: * @return true if the input bytes/units so far are part of a matching string/byte sequence. michael@0: * @stable ICU 4.8 michael@0: */ michael@0: #define USTRINGTRIE_MATCHES(result) ((result)!=USTRINGTRIE_NO_MATCH) michael@0: michael@0: /** michael@0: * Equivalent to (result==USTRINGTRIE_INTERMEDIATE_VALUE || result==USTRINGTRIE_FINAL_VALUE) but michael@0: * this macro evaluates result exactly once. michael@0: * @param result A result from BytesTrie::first(), UCharsTrie::next() etc. michael@0: * @return true if there is a value for the input bytes/units so far. michael@0: * @see BytesTrie::getValue michael@0: * @see UCharsTrie::getValue michael@0: * @stable ICU 4.8 michael@0: */ michael@0: #define USTRINGTRIE_HAS_VALUE(result) ((result)>=USTRINGTRIE_FINAL_VALUE) michael@0: michael@0: /** michael@0: * Equivalent to (result==USTRINGTRIE_NO_VALUE || result==USTRINGTRIE_INTERMEDIATE_VALUE) but michael@0: * this macro evaluates result exactly once. michael@0: * @param result A result from BytesTrie::first(), UCharsTrie::next() etc. michael@0: * @return true if another input byte/unit can continue a matching string. michael@0: * @stable ICU 4.8 michael@0: */ michael@0: #define USTRINGTRIE_HAS_NEXT(result) ((result)&1) michael@0: michael@0: #endif /* __USTRINGTRIE_H__ */