ICU 77.1  77.1
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
strenum.h
Go to the documentation of this file.
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-2012, International Business Machines
7 * Corporation and others. All Rights Reserved.
8 *
9 *******************************************************************************
10 */
11 
12 #ifndef STRENUM_H
13 #define STRENUM_H
14 
15 #include "unicode/utypes.h"
16 
17 #if U_SHOW_CPLUSPLUS_API
18 
19 #include "unicode/uobject.h"
20 #include "unicode/unistr.h"
21 
27 U_NAMESPACE_BEGIN
28 
62 public:
67  virtual ~StringEnumeration();
68 
81  virtual StringEnumeration *clone() const;
82 
100  virtual int32_t count(UErrorCode& status) const = 0;
101 
132  virtual const char* next(int32_t *resultLength, UErrorCode& status);
133 
157  virtual const char16_t* unext(int32_t *resultLength, UErrorCode& status);
158 
179  virtual const UnicodeString* snext(UErrorCode& status);
180 
193  virtual void reset(UErrorCode& status) = 0;
194 
202  virtual bool operator==(const StringEnumeration& that)const;
210  virtual bool operator!=(const StringEnumeration& that)const;
211 
212 protected:
222  char charsBuffer[32];
228  char *chars;
233  int32_t charsCapacity;
234 
240 
249  void ensureCharsCapacity(int32_t capacity, UErrorCode &status);
250 
273  UnicodeString *setChars(const char *s, int32_t length, UErrorCode &status);
274 };
275 
276 U_NAMESPACE_END
277 
278 #endif /* U_SHOW_CPLUSPLUS_API */
279 
280 /* STRENUM_H */
281 #endif
Base class for 'pure' C++ implementations of uenum api.
Definition: strenum.h:61
UnicodeString * setChars(const char *s, int32_t length, UErrorCode &status)
Converts s to Unicode and sets unistr to the result.
int32_t charsCapacity
Capacity of chars, for use with default implementations and subclasses.
Definition: strenum.h:233
char * chars
char * buffer for use with default implementations and subclasses.
Definition: strenum.h:228
StringEnumeration()
Default constructor for use with default implementations and subclasses.
virtual const char16_t * unext(int32_t *resultLength, UErrorCode &status)
void ensureCharsCapacity(int32_t capacity, UErrorCode &status)
Ensures that chars is at least as large as the requested capacity.
UnicodeString unistr
UnicodeString field for use with default implementations and subclasses.
Definition: strenum.h:217
virtual int32_t count(UErrorCode &status) const =0
virtual StringEnumeration * clone() const
Clone this object, an instance of a subclass of StringEnumeration.
virtual const char * next(int32_t *resultLength, UErrorCode &status)
virtual ~StringEnumeration()
Destructor.
virtual const UnicodeString * snext(UErrorCode &status)
virtual void reset(UErrorCode &status)=0
virtual bool operator==(const StringEnumeration &that) const
Compares this enumeration to other to check if both are equal.
virtual bool operator!=(const StringEnumeration &that) const
Compares this enumeration to other to check if both are not equal.
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:296
C++ API: Unicode String.
C++ API: Common ICU base class UObject.
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:430
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside.
Definition: utypes.h:315