intl/icu/source/common/unicode/ustringtrie.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/intl/icu/source/common/unicode/ustringtrie.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,95 @@
     1.4 +/*
     1.5 +*******************************************************************************
     1.6 +*   Copyright (C) 2010-2012, International Business Machines
     1.7 +*   Corporation and others.  All Rights Reserved.
     1.8 +*******************************************************************************
     1.9 +*   file name:  udicttrie.h
    1.10 +*   encoding:   US-ASCII
    1.11 +*   tab size:   8 (not used)
    1.12 +*   indentation:4
    1.13 +*
    1.14 +*   created on: 2010dec17
    1.15 +*   created by: Markus W. Scherer
    1.16 +*/
    1.17 +
    1.18 +#ifndef __USTRINGTRIE_H__
    1.19 +#define __USTRINGTRIE_H__
    1.20 +
    1.21 +/**
    1.22 + * \file
    1.23 + * \brief C API: Helper definitions for dictionary trie APIs.
    1.24 + */
    1.25 +
    1.26 +#include "unicode/utypes.h"
    1.27 +
    1.28 +
    1.29 +/**
    1.30 + * Return values for BytesTrie::next(), UCharsTrie::next() and similar methods.
    1.31 + * @see USTRINGTRIE_MATCHES
    1.32 + * @see USTRINGTRIE_HAS_VALUE
    1.33 + * @see USTRINGTRIE_HAS_NEXT
    1.34 + * @stable ICU 4.8
    1.35 + */
    1.36 +enum UStringTrieResult {
    1.37 +    /**
    1.38 +     * The input unit(s) did not continue a matching string.
    1.39 +     * Once current()/next() return USTRINGTRIE_NO_MATCH,
    1.40 +     * all further calls to current()/next() will also return USTRINGTRIE_NO_MATCH,
    1.41 +     * until the trie is reset to its original state or to a saved state.
    1.42 +     * @stable ICU 4.8
    1.43 +     */
    1.44 +    USTRINGTRIE_NO_MATCH,
    1.45 +    /**
    1.46 +     * The input unit(s) continued a matching string
    1.47 +     * but there is no value for the string so far.
    1.48 +     * (It is a prefix of a longer string.)
    1.49 +     * @stable ICU 4.8
    1.50 +     */
    1.51 +    USTRINGTRIE_NO_VALUE,
    1.52 +    /**
    1.53 +     * The input unit(s) continued a matching string
    1.54 +     * and there is a value for the string so far.
    1.55 +     * This value will be returned by getValue().
    1.56 +     * No further input byte/unit can continue a matching string.
    1.57 +     * @stable ICU 4.8
    1.58 +     */
    1.59 +    USTRINGTRIE_FINAL_VALUE,
    1.60 +    /**
    1.61 +     * The input unit(s) continued a matching string
    1.62 +     * and there is a value for the string so far.
    1.63 +     * This value will be returned by getValue().
    1.64 +     * Another input byte/unit can continue a matching string.
    1.65 +     * @stable ICU 4.8
    1.66 +     */
    1.67 +    USTRINGTRIE_INTERMEDIATE_VALUE
    1.68 +};
    1.69 +
    1.70 +/**
    1.71 + * Same as (result!=USTRINGTRIE_NO_MATCH).
    1.72 + * @param result A result from BytesTrie::first(), UCharsTrie::next() etc.
    1.73 + * @return true if the input bytes/units so far are part of a matching string/byte sequence.
    1.74 + * @stable ICU 4.8
    1.75 + */
    1.76 +#define USTRINGTRIE_MATCHES(result) ((result)!=USTRINGTRIE_NO_MATCH)
    1.77 +
    1.78 +/**
    1.79 + * Equivalent to (result==USTRINGTRIE_INTERMEDIATE_VALUE || result==USTRINGTRIE_FINAL_VALUE) but
    1.80 + * this macro evaluates result exactly once.
    1.81 + * @param result A result from BytesTrie::first(), UCharsTrie::next() etc.
    1.82 + * @return true if there is a value for the input bytes/units so far.
    1.83 + * @see BytesTrie::getValue
    1.84 + * @see UCharsTrie::getValue
    1.85 + * @stable ICU 4.8
    1.86 + */
    1.87 +#define USTRINGTRIE_HAS_VALUE(result) ((result)>=USTRINGTRIE_FINAL_VALUE)
    1.88 +
    1.89 +/**
    1.90 + * Equivalent to (result==USTRINGTRIE_NO_VALUE || result==USTRINGTRIE_INTERMEDIATE_VALUE) but
    1.91 + * this macro evaluates result exactly once.
    1.92 + * @param result A result from BytesTrie::first(), UCharsTrie::next() etc.
    1.93 + * @return true if another input byte/unit can continue a matching string.
    1.94 + * @stable ICU 4.8
    1.95 + */
    1.96 +#define USTRINGTRIE_HAS_NEXT(result) ((result)&1)
    1.97 +
    1.98 +#endif  /* __USTRINGTRIE_H__ */

mercurial