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