os/textandloc/fontservices/textshaperplugin/IcuSource/common/ustrenum.h
author sl
Tue, 10 Jun 2014 14:32:02 +0200
changeset 1 260cb5ec6c19
permissions -rw-r--r--
Update contrib.
     1 /*
     2 **********************************************************************
     3 * Copyright (c) 2002-2004, International Business Machines
     4 * Corporation and others.  All Rights Reserved.
     5 **********************************************************************
     6 * Author: Alan Liu
     7 * Created: November 11 2002
     8 * Since: ICU 2.4
     9 **********************************************************************
    10 */
    11 #ifndef _USTRENUM_H_
    12 #define _USTRENUM_H_
    13 
    14 #include "unicode/uenum.h"
    15 #include "unicode/strenum.h"
    16 
    17 /**
    18  * Given a StringEnumeration, wrap it in a UEnumeration.  The
    19  * StringEnumeration is adopted; after this call, the caller must not
    20  * delete it (regardless of error status).
    21  */
    22 U_CAPI UEnumeration* U_EXPORT2
    23 uenum_openStringEnumeration(StringEnumeration* adopted, UErrorCode* ec);
    24 
    25 /**
    26  * Given an array of const char* strings (invariant chars only),
    27  * return a UEnumeration.  Must have strings[i] != 0 for i in
    28  * 0..count-1.
    29  */
    30 U_CAPI UEnumeration* U_EXPORT2
    31 uenum_openCharStringsEnumeration(const char** strings, int32_t count,
    32                                  UErrorCode* ec);
    33 
    34 //----------------------------------------------------------------------
    35 U_NAMESPACE_BEGIN
    36 
    37 /**
    38  * A wrapper to make a UEnumeration into a StringEnumeration.  The
    39  * wrapper adopts the UEnumeration is wraps.
    40  */
    41 class U_COMMON_API UStringEnumeration : public StringEnumeration {
    42 
    43 public:
    44     /**
    45      * Constructor.  This constructor adopts its UEnumeration
    46      * argument.
    47      * @param uenum a UEnumeration object.  This object takes
    48      * ownership of 'uenum' and will close it in its destructor.  The
    49      * caller must not call uenum_close on 'uenum' after calling this
    50      * constructor.
    51      */
    52     UStringEnumeration(UEnumeration* uenum);
    53 
    54     /**
    55      * Destructor.  This closes the UEnumeration passed in to the
    56      * constructor.
    57      */
    58     virtual ~UStringEnumeration();
    59 
    60     /**
    61      * Return the number of elements that the iterator traverses.
    62      * @param status the error code.
    63      * @return number of elements in the iterator.
    64      */
    65     virtual int32_t count(UErrorCode& status) const;
    66 
    67     /**
    68      * Returns the next element a UnicodeString*.  If there are no
    69      * more elements, returns NULL.
    70      * @param status the error code.
    71      * @return a pointer to the string, or NULL.
    72      */
    73     virtual const UnicodeString* snext(UErrorCode& status);
    74 
    75     /**
    76      * Resets the iterator.
    77      * @param status the error code.
    78      */
    79     virtual void reset(UErrorCode& status);
    80 
    81     /**
    82      * ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.
    83      */
    84     virtual UClassID getDynamicClassID() const;
    85 
    86     /**
    87      * ICU4C "poor man's RTTI", returns a UClassID for this ICU class.
    88      */
    89     static UClassID U_EXPORT2 getStaticClassID();
    90 
    91 private:
    92     UEnumeration *uenum; // owned
    93 };
    94 
    95 U_NAMESPACE_END
    96 
    97 #endif
    98