]> git.saurik.com Git - apple/icu.git/blame - icuSources/samples/translit/unaccent.h
ICU-66108.tar.gz
[apple/icu.git] / icuSources / samples / translit / unaccent.h
CommitLineData
f3c0d7a5
A
1/***********************************************************************
2 * © 2016 and later: Unicode, Inc. and others.
3 * License & terms of use: http://www.unicode.org/copyright.html#License
4 ***********************************************************************
5 ***********************************************************************
b75a7d8f
A
6 * COPYRIGHT:
7 * Copyright (c) 1999-2003, International Business Machines Corporation and
8 * others. All Rights Reserved.
f3c0d7a5 9 ***********************************************************************/
b75a7d8f
A
10
11#include "unicode/translit.h"
12#include "unicode/normlzr.h"
13
0f5d89e8
A
14using namespace icu;
15
b75a7d8f
A
16class UnaccentTransliterator : public Transliterator {
17
18 public:
19
20 /**
21 * Constructor
22 */
23 UnaccentTransliterator();
24
25 /**
26 * Destructor
27 */
28 virtual ~UnaccentTransliterator();
29
30 protected:
31
32 /**
33 * Implement Transliterator API
34 */
35 virtual void handleTransliterate(Replaceable& text,
36 UTransPosition& index,
37 UBool incremental) const;
38
39 private:
40
41 /**
42 * Unaccent a single character using normalizer.
43 */
44 UChar unaccent(UChar c) const;
45
46 Normalizer normalizer;
47
48public:
49
50 /**
51 * Return the class ID for this class. This is useful only for
52 * comparing to a return value from getDynamicClassID(). For example:
53 * <pre>
54 * . Base* polymorphic_pointer = createPolymorphicObject();
55 * . if (polymorphic_pointer->getDynamicClassID() ==
56 * . Derived::getStaticClassID()) ...
57 * </pre>
58 * @return The class ID for all objects of this class.
59 * @stable ICU 2.0
60 */
61 static inline UClassID getStaticClassID(void) { return (UClassID)&fgClassID; };
62
63 /**
64 * Returns a unique class ID <b>polymorphically</b>. This method
65 * is to implement a simple version of RTTI, since not all C++
66 * compilers support genuine RTTI. Polymorphic operator==() and
67 * clone() methods call this method.
68 *
69 * <p>Concrete subclasses of Transliterator that wish clients to
70 * be able to identify them should implement getDynamicClassID()
71 * and also a static method and data member:
72 *
73 * <pre>
74 * static UClassID getStaticClassID() { return (UClassID)&fgClassID; }
75 * static char fgClassID;
76 * </pre>
77 *
78 * Subclasses that do not implement this method will have a
79 * dynamic class ID of Transliterator::getStatisClassID().
80 *
81 * @return The class ID for this object. All objects of a given
82 * class have the same class ID. Objects of other classes have
83 * different class IDs.
84 * @stable ICU 2.0
85 */
86 virtual UClassID getDynamicClassID(void) const { return getStaticClassID(); };
87
88private:
89
90 /**
91 * Class identifier for subclasses of Transliterator that do not
92 * define their class (anonymous subclasses).
93 */
94 static const char fgClassID;
95};