1// © 2016 and later: Unicode, Inc. and others.
2// License & terms of use: http://www.unicode.org/copyright.html
3/*
4*******************************************************************************
5*
6* Copyright (C) 2002-2006, International Business Machines
7* Corporation and others. All Rights Reserved.
8*
9*******************************************************************************
10* file name: uenumimp.h
11* encoding: UTF-8
12* tab size: 8 (not used)
13* indentation:2
14*
15* created on: 2002jul08
16* created by: Vladimir Weinstein
17*/
18
19#ifndef __UENUMIMP_H
20#define __UENUMIMP_H
21
22#include "unicode/uenum.h"
23
24U_CDECL_BEGIN
25
26/**
27 * following are the type declarations for
28 * implementations of APIs. If any of these
29 * functions are NULL, U_UNSUPPORTED_ERROR
30 * is returned. If close is NULL, the enumeration
31 * object is going to be released.
32 * Initial error checking is done in the body
33 * of API function, so the implementations
34 * need not to check the initial error condition.
35 */
36
37/**
38 * Function type declaration for uenum_close().
39 *
40 * This function should cleanup the enumerator object
41 *
42 * @param en enumeration to be closed
43 */
44typedef void U_CALLCONV
45UEnumClose(UEnumeration *en);
46
47/**
48 * Function type declaration for uenum_count().
49 *
50 * This function should count the number of elements
51 * in this enumeration
52 *
53 * @param en enumeration to be counted
54 * @param status pointer to UErrorCode variable
55 * @return number of elements in enumeration
56 */
57typedef int32_t U_CALLCONV
58UEnumCount(UEnumeration *en, UErrorCode *status);
59
60/**
61 * Function type declaration for uenum_unext().
62 *
63 * This function returns the next element as a UChar *,
64 * or NULL after all elements haven been enumerated.
65 *
66 * @param en enumeration
67 * @param resultLength pointer to result length
68 * @param status pointer to UErrorCode variable
69 * @return next element as UChar *,
70 * or NULL after all elements haven been enumerated
71 */
72typedef const UChar* U_CALLCONV
73UEnumUNext(UEnumeration* en,
74 int32_t* resultLength,
75 UErrorCode* status);
76
77/**
78 * Function type declaration for uenum_next().
79 *
80 * This function returns the next element as a char *,
81 * or NULL after all elements haven been enumerated.
82 *
83 * @param en enumeration
84 * @param resultLength pointer to result length
85 * @param status pointer to UErrorCode variable
86 * @return next element as char *,
87 * or NULL after all elements haven been enumerated
88 */
89typedef const char* U_CALLCONV
90UEnumNext(UEnumeration* en,
91 int32_t* resultLength,
92 UErrorCode* status);
93
94/**
95 * Function type declaration for uenum_reset().
96 *
97 * This function should reset the enumeration
98 * object
99 *
100 * @param en enumeration
101 * @param status pointer to UErrorCode variable
102 */
103typedef void U_CALLCONV
104UEnumReset(UEnumeration* en,
105 UErrorCode* status);
106
107
108struct UEnumeration {
109 /* baseContext. For the base class only. Don't touch! */
110 void *baseContext;
111
112 /* context. Use it for what you need */
113 void *context;
114
115 /**
116 * these are functions that will
117 * be used for APIs
118 */
119 /* called from uenum_close */
120 UEnumClose *close;
121 /* called from uenum_count */
122 UEnumCount *count;
123 /* called from uenum_unext */
124 UEnumUNext *uNext;
125 /* called from uenum_next */
126 UEnumNext *next;
127 /* called from uenum_reset */
128 UEnumReset *reset;
129};
130
131U_CDECL_END
132
133/* This is the default implementation for uenum_unext().
134 * It automatically converts the char * string to UChar *.
135 * Don't call this directly. This is called internally by uenum_unext
136 * when a UEnumeration is defined with 'uNext' pointing to this
137 * function.
138 */
139U_CAPI const UChar* U_EXPORT2
140uenum_unextDefault(UEnumeration* en,
141 int32_t* resultLength,
142 UErrorCode* status);
143
144/* This is the default implementation for uenum_next().
145 * It automatically converts the UChar * string to char *.
146 * Don't call this directly. This is called internally by uenum_next
147 * when a UEnumeration is defined with 'next' pointing to this
148 * function.
149 */
150U_CAPI const char* U_EXPORT2
151uenum_nextDefault(UEnumeration* en,
152 int32_t* resultLength,
153 UErrorCode* status);
154
155#endif
156