1ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/* 2ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru******************************************************************************* 3ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* 4ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* Copyright (C) 2002-2007, International Business Machines 5ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* Corporation and others. All Rights Reserved. 6ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* 7ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru******************************************************************************* 8ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru*/ 9ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 10ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#ifndef STRENUM_H 11ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#define STRENUM_H 12ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 13ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/uobject.h" 14ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#include "unicode/unistr.h" 15ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 16ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/** 17ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \file 18ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \brief C++ API: String Enumeration 19ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 20ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 21ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_NAMESPACE_BEGIN 22ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 23ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/** 24ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Base class for 'pure' C++ implementations of uenum api. Adds a 25ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * method that returns the next UnicodeString since in C++ this can 26ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * be a common storage format for strings. 27ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 28ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>The model is that the enumeration is over strings maintained by 29ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * a 'service.' At any point, the service might change, invalidating 30ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * the enumerator (though this is expected to be rare). The iterator 31ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * returns an error if this has occurred. Lack of the error is no 32ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * guarantee that the service didn't change immediately after the 33ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * call, so the returned string still might not be 'valid' on 34ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * subsequent use.</p> 35ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 36ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>Strings may take the form of const char*, const UChar*, or const 37ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * UnicodeString*. The type you get is determine by the variant of 38ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 'next' that you call. In general the StringEnumeration is 39ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * optimized for one of these types, but all StringEnumerations can 40ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * return all types. Returned strings are each terminated with a NUL. 41ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Depending on the service data, they might also include embedded NUL 42ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * characters, so API is provided to optionally return the true 43ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * length, counting the embedded NULs but not counting the terminating 44ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * NUL.</p> 45ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 46ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>The pointers returned by next, unext, and snext become invalid 47ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * upon any subsequent call to the enumeration's destructor, next, 48ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * unext, snext, or reset.</p> 49ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 50ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * ICU 2.8 adds some default implementations and helper functions 51ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * for subclasses. 52ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 53ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.4 54ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 55ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruclass U_COMMON_API StringEnumeration : public UObject { 56ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Querupublic: 57ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 58ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Destructor. 59ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.4 60ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 61ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual ~StringEnumeration(); 62ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 63ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 64ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Clone this object, an instance of a subclass of StringEnumeration. 65ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Clones can be used concurrently in multiple threads. 66ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * If a subclass does not implement clone(), or if an error occurs, 67ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * then NULL is returned. 68ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * The clone functions in all subclasses return a base class pointer 69ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * because some compilers do not support covariant (same-as-this) 70ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * return types; cast to the appropriate subclass if necessary. 71ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * The caller must delete the clone. 72ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 73ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return a clone of this object 74ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 75ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @see getDynamicClassID 76ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.8 77ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 78ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual StringEnumeration *clone() const; 79ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 80ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 81ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>Return the number of elements that the iterator traverses. If 82ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * the iterator is out of sync with its service, status is set to 83ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * U_ENUM_OUT_OF_SYNC_ERROR, and the return value is zero.</p> 84ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 85ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>The return value will not change except possibly as a result of 86ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * a subsequent call to reset, or if the iterator becomes out of sync.</p> 87ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 88ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>This is a convenience function. It can end up being very 89ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * expensive as all the items might have to be pre-fetched 90ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * (depending on the storage format of the data being 91ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * traversed).</p> 92ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 93ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param status the error code. 94ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return number of elements in the iterator. 95ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 96ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.4 */ 97ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual int32_t count(UErrorCode& status) const = 0; 98ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 99ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 100ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>Returns the next element as a NUL-terminated char*. If there 101ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * are no more elements, returns NULL. If the resultLength pointer 102ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * is not NULL, the length of the string (not counting the 103ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * terminating NUL) is returned at that address. If an error 104ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * status is returned, the value at resultLength is undefined.</p> 105ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 106ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>The returned pointer is owned by this iterator and must not be 107ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * deleted by the caller. The pointer is valid until the next call 108ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * to next, unext, snext, reset, or the enumerator's destructor.</p> 109ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 110ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>If the iterator is out of sync with its service, status is set 111ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * to U_ENUM_OUT_OF_SYNC_ERROR and NULL is returned.</p> 112ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 113ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>If the native service string is a UChar* string, it is 114ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * converted to char* with the invariant converter. If the 115ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * conversion fails (because a character cannot be converted) then 116ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * status is set to U_INVARIANT_CONVERSION_ERROR and the return 117ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * value is undefined (though not NULL).</p> 118ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 119ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Starting with ICU 2.8, the default implementation calls snext() 120ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * and handles the conversion. 121ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 122ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param status the error code. 123ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param resultLength a pointer to receive the length, can be NULL. 124ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return a pointer to the string, or NULL. 125ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 126ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.4 127ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 128ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual const char* next(int32_t *resultLength, UErrorCode& status); 129ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 130ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 131ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>Returns the next element as a NUL-terminated UChar*. If there 132ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * are no more elements, returns NULL. If the resultLength pointer 133ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * is not NULL, the length of the string (not counting the 134ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * terminating NUL) is returned at that address. If an error 135ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * status is returned, the value at resultLength is undefined.</p> 136ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 137ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>The returned pointer is owned by this iterator and must not be 138ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * deleted by the caller. The pointer is valid until the next call 139ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * to next, unext, snext, reset, or the enumerator's destructor.</p> 140ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 141ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>If the iterator is out of sync with its service, status is set 142ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * to U_ENUM_OUT_OF_SYNC_ERROR and NULL is returned.</p> 143ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 144ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Starting with ICU 2.8, the default implementation calls snext() 145ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * and handles the conversion. 146ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 147ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param status the error code. 148ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param resultLength a ponter to receive the length, can be NULL. 149ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return a pointer to the string, or NULL. 150ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 151ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.4 152ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 153ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual const UChar* unext(int32_t *resultLength, UErrorCode& status); 154ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 155ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 156ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>Returns the next element a UnicodeString*. If there are no 157ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * more elements, returns NULL.</p> 158ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 159ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>The returned pointer is owned by this iterator and must not be 160ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * deleted by the caller. The pointer is valid until the next call 161ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * to next, unext, snext, reset, or the enumerator's destructor.</p> 162ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 163ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>If the iterator is out of sync with its service, status is set 164ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * to U_ENUM_OUT_OF_SYNC_ERROR and NULL is returned.</p> 165ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 166ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param status the error code. 167ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return a pointer to the string, or NULL. 168ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 169ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.4 170ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 171ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual const UnicodeString* snext(UErrorCode& status) = 0; 172ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 173ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 174ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>Resets the iterator. This re-establishes sync with the 175ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * service and rewinds the iterator to start at the first 176ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * element.</p> 177ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 178ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>Previous pointers returned by next, unext, or snext become 179ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * invalid, and the value returned by count might change.</p> 180ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 181ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param status the error code. 182ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 183ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.4 184ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 185ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void reset(UErrorCode& status) = 0; 186ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 187ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 188ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Compares this enumeration to other to check if both are equal 189ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 190ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param that The other string enumeration to compare this object to 191ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return TRUE if the enumerations are equal. FALSE if not. 192ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 3.6 193ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 194ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual UBool operator==(const StringEnumeration& that)const; 195ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 196ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Compares this enumeration to other to check if both are not equal 197ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 198ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param that The other string enumeration to compare this object to 199ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return TRUE if the enumerations are equal. FALSE if not. 200ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 3.6 201ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 202ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual UBool operator!=(const StringEnumeration& that)const; 203ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 204ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruprotected: 205ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 206ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * UnicodeString field for use with default implementations and subclasses. 207ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.8 208ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 209ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UnicodeString unistr; 210ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 211ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * char * default buffer for use with default implementations and subclasses. 212ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.8 213ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 214ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru char charsBuffer[32]; 215ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 216ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * char * buffer for use with default implementations and subclasses. 217ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Allocated in constructor and in ensureCharsCapacity(). 218ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.8 219ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 220ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru char *chars; 221ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 222ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Capacity of chars, for use with default implementations and subclasses. 223ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.8 224ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 225ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t charsCapacity; 226ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 227ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 228ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Default constructor for use with default implementations and subclasses. 229ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.8 230ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 231ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru StringEnumeration(); 232ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 233ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 234ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Ensures that chars is at least as large as the requested capacity. 235ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * For use with default implementations and subclasses. 236ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 237ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param capacity Requested capacity. 238ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param status ICU in/out error code. 239ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.8 240ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 241ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru void ensureCharsCapacity(int32_t capacity, UErrorCode &status); 242ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 243ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 244ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Converts s to Unicode and sets unistr to the result. 245ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * For use with default implementations and subclasses, 246ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * especially for implementations of snext() in terms of next(). 247ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * This is provided with a helper function instead of a default implementation 248ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * of snext() to avoid potential infinite loops between next() and snext(). 249ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 250ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * For example: 251ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \code 252ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * const UnicodeString* snext(UErrorCode& status) { 253ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * int32_t resultLength=0; 254ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * const char *s=next(&resultLength, status); 255ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * return setChars(s, resultLength, status); 256ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * } 257ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \endcode 258ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 259ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param s String to be converted to Unicode. 260ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param length Length of the string. 261ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param status ICU in/out error code. 262ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return A pointer to unistr. 263ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.8 264ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 265ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UnicodeString *setChars(const char *s, int32_t length, UErrorCode &status); 266ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}; 267ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 268ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_NAMESPACE_END 269ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 270ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/* STRENUM_H */ 271ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif 272