ustrenum.h 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. // © 2016 and later: Unicode, Inc. and others.
  2. // License & terms of use: http://www.unicode.org/copyright.html
  3. /*
  4. **********************************************************************
  5. * Copyright (c) 2002-2014, International Business Machines
  6. * Corporation and others. All Rights Reserved.
  7. **********************************************************************
  8. * Author: Alan Liu
  9. * Created: November 11 2002
  10. * Since: ICU 2.4
  11. **********************************************************************
  12. */
  13. #ifndef _USTRENUM_H_
  14. #define _USTRENUM_H_
  15. #include "unicode/uenum.h"
  16. #include "unicode/strenum.h"
  17. //----------------------------------------------------------------------
  18. U_NAMESPACE_BEGIN
  19. /**
  20. * A wrapper to make a UEnumeration into a StringEnumeration. The
  21. * wrapper adopts the UEnumeration is wraps.
  22. */
  23. class U_COMMON_API UStringEnumeration : public StringEnumeration {
  24. public:
  25. /**
  26. * Constructor. This constructor adopts its UEnumeration
  27. * argument.
  28. * @param uenum a UEnumeration object. This object takes
  29. * ownership of 'uenum' and will close it in its destructor. The
  30. * caller must not call uenum_close on 'uenum' after calling this
  31. * constructor.
  32. */
  33. UStringEnumeration(UEnumeration* uenum);
  34. /**
  35. * Destructor. This closes the UEnumeration passed in to the
  36. * constructor.
  37. */
  38. virtual ~UStringEnumeration();
  39. /**
  40. * Return the number of elements that the iterator traverses.
  41. * @param status the error code.
  42. * @return number of elements in the iterator.
  43. */
  44. virtual int32_t count(UErrorCode& status) const;
  45. virtual const char* next(int32_t *resultLength, UErrorCode& status);
  46. /**
  47. * Returns the next element a UnicodeString*. If there are no
  48. * more elements, returns NULL.
  49. * @param status the error code.
  50. * @return a pointer to the string, or NULL.
  51. */
  52. virtual const UnicodeString* snext(UErrorCode& status);
  53. /**
  54. * Resets the iterator.
  55. * @param status the error code.
  56. */
  57. virtual void reset(UErrorCode& status);
  58. /**
  59. * ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.
  60. */
  61. virtual UClassID getDynamicClassID() const;
  62. /**
  63. * ICU4C "poor man's RTTI", returns a UClassID for this ICU class.
  64. */
  65. static UClassID U_EXPORT2 getStaticClassID();
  66. static UStringEnumeration * U_EXPORT2 fromUEnumeration(
  67. UEnumeration *enumToAdopt, UErrorCode &status);
  68. private:
  69. UEnumeration *uenum; // owned
  70. };
  71. U_NAMESPACE_END
  72. #endif