sl@0: /*
sl@0: **********************************************************************
sl@0: * Copyright (c) 2002-2004, International Business Machines
sl@0: * Corporation and others.  All Rights Reserved.
sl@0: **********************************************************************
sl@0: * Author: Alan Liu
sl@0: * Created: November 11 2002
sl@0: * Since: ICU 2.4
sl@0: **********************************************************************
sl@0: */
sl@0: #ifndef _USTRENUM_H_
sl@0: #define _USTRENUM_H_
sl@0: 
sl@0: #include "unicode/uenum.h"
sl@0: #include "unicode/strenum.h"
sl@0: 
sl@0: /**
sl@0:  * Given a StringEnumeration, wrap it in a UEnumeration.  The
sl@0:  * StringEnumeration is adopted; after this call, the caller must not
sl@0:  * delete it (regardless of error status).
sl@0:  */
sl@0: U_CAPI UEnumeration* U_EXPORT2
sl@0: uenum_openStringEnumeration(StringEnumeration* adopted, UErrorCode* ec);
sl@0: 
sl@0: /**
sl@0:  * Given an array of const char* strings (invariant chars only),
sl@0:  * return a UEnumeration.  Must have strings[i] != 0 for i in
sl@0:  * 0..count-1.
sl@0:  */
sl@0: U_CAPI UEnumeration* U_EXPORT2
sl@0: uenum_openCharStringsEnumeration(const char** strings, int32_t count,
sl@0:                                  UErrorCode* ec);
sl@0: 
sl@0: //----------------------------------------------------------------------
sl@0: U_NAMESPACE_BEGIN
sl@0: 
sl@0: /**
sl@0:  * A wrapper to make a UEnumeration into a StringEnumeration.  The
sl@0:  * wrapper adopts the UEnumeration is wraps.
sl@0:  */
sl@0: class U_COMMON_API UStringEnumeration : public StringEnumeration {
sl@0: 
sl@0: public:
sl@0:     /**
sl@0:      * Constructor.  This constructor adopts its UEnumeration
sl@0:      * argument.
sl@0:      * @param uenum a UEnumeration object.  This object takes
sl@0:      * ownership of 'uenum' and will close it in its destructor.  The
sl@0:      * caller must not call uenum_close on 'uenum' after calling this
sl@0:      * constructor.
sl@0:      */
sl@0:     UStringEnumeration(UEnumeration* uenum);
sl@0: 
sl@0:     /**
sl@0:      * Destructor.  This closes the UEnumeration passed in to the
sl@0:      * constructor.
sl@0:      */
sl@0:     virtual ~UStringEnumeration();
sl@0: 
sl@0:     /**
sl@0:      * Return the number of elements that the iterator traverses.
sl@0:      * @param status the error code.
sl@0:      * @return number of elements in the iterator.
sl@0:      */
sl@0:     virtual int32_t count(UErrorCode& status) const;
sl@0: 
sl@0:     /**
sl@0:      * Returns the next element a UnicodeString*.  If there are no
sl@0:      * more elements, returns NULL.
sl@0:      * @param status the error code.
sl@0:      * @return a pointer to the string, or NULL.
sl@0:      */
sl@0:     virtual const UnicodeString* snext(UErrorCode& status);
sl@0: 
sl@0:     /**
sl@0:      * Resets the iterator.
sl@0:      * @param status the error code.
sl@0:      */
sl@0:     virtual void reset(UErrorCode& status);
sl@0: 
sl@0:     /**
sl@0:      * ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.
sl@0:      */
sl@0:     virtual UClassID getDynamicClassID() const;
sl@0: 
sl@0:     /**
sl@0:      * ICU4C "poor man's RTTI", returns a UClassID for this ICU class.
sl@0:      */
sl@0:     static UClassID U_EXPORT2 getStaticClassID();
sl@0: 
sl@0: private:
sl@0:     UEnumeration *uenum; // owned
sl@0: };
sl@0: 
sl@0: U_NAMESPACE_END
sl@0: 
sl@0: #endif
sl@0: