name2uni.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. * 06/07/01 aliu Creation.
  10. **********************************************************************
  11. */
  12. #ifndef NAME2UNI_H
  13. #define NAME2UNI_H
  14. #include "unicode/utypes.h"
  15. #if !UCONFIG_NO_TRANSLITERATION
  16. #include "unicode/translit.h"
  17. #include "unicode/uniset.h"
  18. U_NAMESPACE_BEGIN
  19. /**
  20. * A transliterator that performs name to character mapping.
  21. * It recognizes the Perl syntax \N{name}.
  22. * @author Alan Liu
  23. */
  24. class NameUnicodeTransliterator : public Transliterator {
  25. public:
  26. /**
  27. * Constructs a transliterator.
  28. * @param adoptedFilter the filter for this transliterator.
  29. */
  30. NameUnicodeTransliterator(UnicodeFilter* adoptedFilter = 0);
  31. /**
  32. * Destructor.
  33. */
  34. virtual ~NameUnicodeTransliterator();
  35. /**
  36. * Copy constructor.
  37. */
  38. NameUnicodeTransliterator(const NameUnicodeTransliterator&);
  39. /**
  40. * Transliterator API.
  41. * @return A copy of the object.
  42. */
  43. virtual NameUnicodeTransliterator* clone() const override;
  44. /**
  45. * ICU "poor man's RTTI", returns a UClassID for the actual class.
  46. */
  47. virtual UClassID getDynamicClassID() const override;
  48. /**
  49. * ICU "poor man's RTTI", returns a UClassID for this class.
  50. */
  51. U_I18N_API static UClassID U_EXPORT2 getStaticClassID();
  52. protected:
  53. /**
  54. * Implements {@link Transliterator#handleTransliterate}.
  55. * @param text the buffer holding transliterated and
  56. * untransliterated text
  57. * @param offset the start and limit of the text, the position
  58. * of the cursor, and the start and limit of transliteration.
  59. * @param incremental if true, assume more text may be coming after
  60. * pos.contextLimit. Otherwise, assume the text is complete.
  61. */
  62. virtual void handleTransliterate(Replaceable& text, UTransPosition& offset,
  63. UBool isIncremental) const override;
  64. /**
  65. * Set of characters which occur in Unicode character names.
  66. */
  67. UnicodeSet legal;
  68. private:
  69. /**
  70. * Assignment operator.
  71. */
  72. NameUnicodeTransliterator& operator=(const NameUnicodeTransliterator&);
  73. };
  74. U_NAMESPACE_END
  75. #endif /* #if !UCONFIG_NO_TRANSLITERATION */
  76. #endif