]> git.saurik.com Git - apple/icu.git/blame - icuSources/common/ustrenum.h
ICU-400.42.tar.gz
[apple/icu.git] / icuSources / common / ustrenum.h
CommitLineData
b75a7d8f
A
1/*
2**********************************************************************
46f4442e 3* Copyright (c) 2002-2008, International Business Machines
b75a7d8f
A
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 */
22U_CAPI UEnumeration* U_EXPORT2
46f4442e 23uenum_openStringEnumeration(U_NAMESPACE_QUALIFIER StringEnumeration* adopted, UErrorCode* ec);
b75a7d8f 24
374ca955
A
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 */
30U_CAPI UEnumeration* U_EXPORT2
46f4442e 31uenum_openCharStringsEnumeration(const char* const* strings, int32_t count,
374ca955
A
32 UErrorCode* ec);
33
34//----------------------------------------------------------------------
35U_NAMESPACE_BEGIN
36
37/**
38 * A wrapper to make a UEnumeration into a StringEnumeration. The
39 * wrapper adopts the UEnumeration is wraps.
40 */
41class U_COMMON_API UStringEnumeration : public StringEnumeration {
42
43public:
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
91private:
92 UEnumeration *uenum; // owned
93};
94
95U_NAMESPACE_END
96
b75a7d8f 97#endif
374ca955 98