Home | History | Annotate | Download | only in unicode
      1 /*
      2 *******************************************************************************
      3 *   Copyright (C) 2010-2011, 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  * Return values for BytesTrie::next(), UCharsTrie::next() and similar methods.
     27  * @see USTRINGTRIE_MATCHES
     28  * @see USTRINGTRIE_HAS_VALUE
     29  * @see USTRINGTRIE_HAS_NEXT
     30  * @draft ICU 4.8
     31  */
     32 enum UStringTrieResult {
     33     /**
     34      * The input unit(s) did not continue a matching string.
     35      * Once current()/next() return USTRINGTRIE_NO_MATCH,
     36      * all further calls to current()/next() will also return USTRINGTRIE_NO_MATCH,
     37      * until the trie is reset to its original state or to a saved state.
     38      * @draft ICU 4.8
     39      */
     40     USTRINGTRIE_NO_MATCH,
     41     /**
     42      * The input unit(s) continued a matching string
     43      * but there is no value for the string so far.
     44      * (It is a prefix of a longer string.)
     45      * @draft ICU 4.8
     46      */
     47     USTRINGTRIE_NO_VALUE,
     48     /**
     49      * The input unit(s) continued a matching string
     50      * and there is a value for the string so far.
     51      * This value will be returned by getValue().
     52      * No further input byte/unit can continue a matching string.
     53      * @draft ICU 4.8
     54      */
     55     USTRINGTRIE_FINAL_VALUE,
     56     /**
     57      * The input unit(s) continued a matching string
     58      * and there is a value for the string so far.
     59      * This value will be returned by getValue().
     60      * Another input byte/unit can continue a matching string.
     61      * @draft ICU 4.8
     62      */
     63     USTRINGTRIE_INTERMEDIATE_VALUE
     64 };
     65 
     66 /**
     67  * Same as (result!=USTRINGTRIE_NO_MATCH).
     68  * @param result A result from BytesTrie::first(), UCharsTrie::next() etc.
     69  * @return true if the input bytes/units so far are part of a matching string/byte sequence.
     70  * @draft ICU 4.8
     71  */
     72 #define USTRINGTRIE_MATCHES(result) ((result)!=USTRINGTRIE_NO_MATCH)
     73 
     74 /**
     75  * Equivalent to (result==USTRINGTRIE_INTERMEDIATE_VALUE || result==USTRINGTRIE_FINAL_VALUE) but
     76  * this macro evaluates result exactly once.
     77  * @param result A result from BytesTrie::first(), UCharsTrie::next() etc.
     78  * @return true if there is a value for the input bytes/units so far.
     79  * @see BytesTrie::getValue
     80  * @see UCharsTrie::getValue
     81  * @draft ICU 4.8
     82  */
     83 #define USTRINGTRIE_HAS_VALUE(result) ((result)>=USTRINGTRIE_FINAL_VALUE)
     84 
     85 /**
     86  * Equivalent to (result==USTRINGTRIE_NO_VALUE || result==USTRINGTRIE_INTERMEDIATE_VALUE) but
     87  * this macro evaluates result exactly once.
     88  * @param result A result from BytesTrie::first(), UCharsTrie::next() etc.
     89  * @return true if another input byte/unit can continue a matching string.
     90  * @draft ICU 4.8
     91  */
     92 #define USTRINGTRIE_HAS_NEXT(result) ((result)&1)
     93 
     94 #endif  /* __USTRINGTRIE_H__ */
     95