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