unesctrn.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. // © 2016 and later: Unicode, Inc. and others.
  2. // License & terms of use: http://www.unicode.org/copyright.html
  3. /*
  4. **********************************************************************
  5. * Copyright (c) 2001-2007, International Business Machines
  6. * Corporation and others. All Rights Reserved.
  7. **********************************************************************
  8. * Date Name Description
  9. * 11/20/2001 aliu Creation.
  10. **********************************************************************
  11. */
  12. #ifndef UNESCTRN_H
  13. #define UNESCTRN_H
  14. #include "unicode/utypes.h"
  15. #if !UCONFIG_NO_TRANSLITERATION
  16. #include "unicode/translit.h"
  17. U_NAMESPACE_BEGIN
  18. /**
  19. * A transliterator that converts Unicode escape forms to the
  20. * characters they represent. Escape forms have a prefix, a suffix, a
  21. * radix, and minimum and maximum digit counts.
  22. *
  23. * <p>This class is package private. It registers several standard
  24. * variants with the system which are then accessed via their IDs.
  25. *
  26. * @author Alan Liu
  27. */
  28. class UnescapeTransliterator : public Transliterator {
  29. private:
  30. /**
  31. * The encoded pattern specification. The pattern consists of
  32. * zero or more forms. Each form consists of a prefix, suffix,
  33. * radix, minimum digit count, and maximum digit count. These
  34. * values are stored as a five character header. That is, their
  35. * numeric values are cast to 16-bit characters and stored in the
  36. * string. Following these five characters, the prefix
  37. * characters, then suffix characters are stored. Each form thus
  38. * takes n+5 characters, where n is the total length of the prefix
  39. * and suffix. The end is marked by a header of length one
  40. * consisting of the character END.
  41. */
  42. UChar* spec; // owned; may not be NULL
  43. public:
  44. /**
  45. * Registers standard variants with the system. Called by
  46. * Transliterator during initialization.
  47. */
  48. static void registerIDs();
  49. /**
  50. * Constructor. Takes the encoded spec array (does not adopt it).
  51. * @param ID the string identifier for this transliterator
  52. * @param spec the encoded spec array
  53. */
  54. UnescapeTransliterator(const UnicodeString& ID,
  55. const UChar *spec);
  56. /**
  57. * Copy constructor.
  58. */
  59. UnescapeTransliterator(const UnescapeTransliterator&);
  60. /**
  61. * Destructor.
  62. */
  63. virtual ~UnescapeTransliterator();
  64. /**
  65. * Transliterator API.
  66. */
  67. virtual UnescapeTransliterator* clone() const;
  68. /**
  69. * ICU "poor man's RTTI", returns a UClassID for the actual class.
  70. */
  71. virtual UClassID getDynamicClassID() const;
  72. /**
  73. * ICU "poor man's RTTI", returns a UClassID for this class.
  74. */
  75. U_I18N_API static UClassID U_EXPORT2 getStaticClassID();
  76. protected:
  77. /**
  78. * Implements {@link Transliterator#handleTransliterate}.
  79. * @param text the buffer holding transliterated and
  80. * untransliterated text
  81. * @param offset the start and limit of the text, the position
  82. * of the cursor, and the start and limit of transliteration.
  83. * @param incremental if true, assume more text may be coming after
  84. * pos.contextLimit. Otherwise, assume the text is complete.
  85. */
  86. virtual void handleTransliterate(Replaceable& text, UTransPosition& offset,
  87. UBool isIncremental) const;
  88. };
  89. U_NAMESPACE_END
  90. #endif /* #if !UCONFIG_NO_TRANSLITERATION */
  91. #endif