• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 **********************************************************************
5 * Copyright (c) 2002-2014, International Business Machines
6 * Corporation and others.  All Rights Reserved.
7 **********************************************************************
8 * Author: Alan Liu
9 * Created: November 11 2002
10 * Since: ICU 2.4
11 **********************************************************************
12 */
13 #ifndef _USTRENUM_H_
14 #define _USTRENUM_H_
15 
16 #include "unicode/uenum.h"
17 #include "unicode/strenum.h"
18 
19 //----------------------------------------------------------------------
20 U_NAMESPACE_BEGIN
21 
22 /**
23  * A wrapper to make a UEnumeration into a StringEnumeration.  The
24  * wrapper adopts the UEnumeration is wraps.
25  */
26 class U_COMMON_API UStringEnumeration : public StringEnumeration {
27 
28 public:
29     /**
30      * Constructor.  This constructor adopts its UEnumeration
31      * argument.
32      * @param uenum a UEnumeration object.  This object takes
33      * ownership of 'uenum' and will close it in its destructor.  The
34      * caller must not call uenum_close on 'uenum' after calling this
35      * constructor.
36      */
37     UStringEnumeration(UEnumeration* uenum);
38 
39     /**
40      * Destructor.  This closes the UEnumeration passed in to the
41      * constructor.
42      */
43     virtual ~UStringEnumeration();
44 
45     /**
46      * Return the number of elements that the iterator traverses.
47      * @param status the error code.
48      * @return number of elements in the iterator.
49      */
50     virtual int32_t count(UErrorCode& status) const;
51 
52     virtual const char* next(int32_t *resultLength, UErrorCode& status);
53 
54     /**
55      * Returns the next element a UnicodeString*.  If there are no
56      * more elements, returns NULL.
57      * @param status the error code.
58      * @return a pointer to the string, or NULL.
59      */
60     virtual const UnicodeString* snext(UErrorCode& status);
61 
62     /**
63      * Resets the iterator.
64      * @param status the error code.
65      */
66     virtual void reset(UErrorCode& status);
67 
68     /**
69      * ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.
70      */
71     virtual UClassID getDynamicClassID() const;
72 
73     /**
74      * ICU4C "poor man's RTTI", returns a UClassID for this ICU class.
75      */
76     static UClassID U_EXPORT2 getStaticClassID();
77 
78     static UStringEnumeration * U_EXPORT2 fromUEnumeration(
79             UEnumeration *enumToAdopt, UErrorCode &status);
80 private:
81     UEnumeration *uenum; // owned
82 };
83 
84 U_NAMESPACE_END
85 
86 #endif
87 
88