1ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/* 2ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru******************************************************************************* 3ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru* 454dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius* Copyright (C) 2002-2012, 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. 12154dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * Either next() or snext() must be implemented differently by a subclass. 122ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 123ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param status the error code. 124ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param resultLength a pointer to receive the length, can be NULL. 125ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return a pointer to the string, or NULL. 126ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 127ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.4 128ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 129ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual const char* next(int32_t *resultLength, UErrorCode& status); 130ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 131ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 132ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>Returns the next element as a NUL-terminated UChar*. If there 133ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * are no more elements, returns NULL. If the resultLength pointer 134ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * is not NULL, the length of the string (not counting the 135ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * terminating NUL) is returned at that address. If an error 136ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * status is returned, the value at resultLength is undefined.</p> 137ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 138ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>The returned pointer is owned by this iterator and must not be 139ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * deleted by the caller. The pointer is valid until the next call 140ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * to next, unext, snext, reset, or the enumerator's destructor.</p> 141ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 142ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>If the iterator is out of sync with its service, status is set 143ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * to U_ENUM_OUT_OF_SYNC_ERROR and NULL is returned.</p> 144ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 145ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Starting with ICU 2.8, the default implementation calls snext() 146ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * and handles the conversion. 147ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 148ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param status the error code. 149ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param resultLength a ponter to receive the length, can be NULL. 150ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return a pointer to the string, or NULL. 151ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 152ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.4 153ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 154ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual const UChar* unext(int32_t *resultLength, UErrorCode& status); 155ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 156ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 157ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>Returns the next element a UnicodeString*. If there are no 158ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * more elements, returns NULL.</p> 159ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 160ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>The returned pointer is owned by this iterator and must not be 161ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * deleted by the caller. The pointer is valid until the next call 162ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * to next, unext, snext, reset, or the enumerator's destructor.</p> 163ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 164ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>If the iterator is out of sync with its service, status is set 165ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * to U_ENUM_OUT_OF_SYNC_ERROR and NULL is returned.</p> 166ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 16754dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * Starting with ICU 2.8, the default implementation calls next() 16854dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * and handles the conversion. 16954dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * Either next() or snext() must be implemented differently by a subclass. 17054dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius * 171ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param status the error code. 172ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return a pointer to the string, or NULL. 173ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 174ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.4 175ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 17654dcd9b6a06071f647dac967e9e267abb9410720Craig Cornelius virtual const UnicodeString* snext(UErrorCode& status); 177ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 178ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 179ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>Resets the iterator. This re-establishes sync with the 180ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * service and rewinds the iterator to start at the first 181ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * element.</p> 182ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 183ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * <p>Previous pointers returned by next, unext, or snext become 184ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * invalid, and the value returned by count might change.</p> 185ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 186ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param status the error code. 187ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 188ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.4 189ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 190ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual void reset(UErrorCode& status) = 0; 191ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 192ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 193ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Compares this enumeration to other to check if both are equal 194ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 195ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param that The other string enumeration to compare this object to 196ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return TRUE if the enumerations are equal. FALSE if not. 197ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 3.6 198ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 199ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual UBool operator==(const StringEnumeration& that)const; 200ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 201ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Compares this enumeration to other to check if both are not equal 202ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 203ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param that The other string enumeration to compare this object to 204ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return TRUE if the enumerations are equal. FALSE if not. 205ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 3.6 206ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 207ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru virtual UBool operator!=(const StringEnumeration& that)const; 208ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 209ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queruprotected: 210ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 211ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * UnicodeString field for use with default implementations and subclasses. 212ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.8 213ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 214ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UnicodeString unistr; 215ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 216ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * char * default buffer for use with default implementations and subclasses. 217ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.8 218ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 219ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru char charsBuffer[32]; 220ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 221ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * char * buffer for use with default implementations and subclasses. 222ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Allocated in constructor and in ensureCharsCapacity(). 223ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.8 224ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 225ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru char *chars; 226ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 227ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Capacity of chars, for use with default implementations and subclasses. 228ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.8 229ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 230ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru int32_t charsCapacity; 231ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 232ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 233ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Default constructor for use with default implementations and subclasses. 234ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.8 235ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 236ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru StringEnumeration(); 237ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 238ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 239ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Ensures that chars is at least as large as the requested capacity. 240ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * For use with default implementations and subclasses. 241ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 242ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param capacity Requested capacity. 243ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param status ICU in/out error code. 244ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.8 245ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 246ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru void ensureCharsCapacity(int32_t capacity, UErrorCode &status); 247ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 248ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru /** 249ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * Converts s to Unicode and sets unistr to the result. 250ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * For use with default implementations and subclasses, 251ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * especially for implementations of snext() in terms of next(). 252ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * This is provided with a helper function instead of a default implementation 253ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * of snext() to avoid potential infinite loops between next() and snext(). 254ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 255ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * For example: 256ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \code 257ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * const UnicodeString* snext(UErrorCode& status) { 258ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * int32_t resultLength=0; 259ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * const char *s=next(&resultLength, status); 260ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * return setChars(s, resultLength, status); 261ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * } 262ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * \endcode 263ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * 264ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param s String to be converted to Unicode. 265ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param length Length of the string. 266ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @param status ICU in/out error code. 267ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @return A pointer to unistr. 268ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru * @stable ICU 2.8 269ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru */ 270ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru UnicodeString *setChars(const char *s, int32_t length, UErrorCode &status); 271ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru}; 272ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 273ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste QueruU_NAMESPACE_END 274ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru 275ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru/* STRENUM_H */ 276ac04d0bbe12b3ef54518635711412f178cb4d16Jean-Baptiste Queru#endif 277