]>
git.saurik.com Git - apple/icu.git/blob - icuSources/i18n/unifltlg.cpp
2 **********************************************************************
3 * Copyright (C) 1999-2001, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 **********************************************************************
6 * Date Name Description
7 * 11/17/99 aliu Creation.
8 **********************************************************************
11 //////////////////////////////////////////////////////////////
13 // NOTICE - Do not use
15 // This entire file has been deprecated as of ICU 2.4.
17 //////////////////////////////////////////////////////////////
19 #include "unicode/utypes.h"
21 #if !UCONFIG_NO_TRANSLITERATION
23 #include "unicode/unifltlg.h"
24 #include "unicode/unifilt.h"
29 * This class stubs out UnicodeMatcher API that we don't implement.
31 class _UF
: public UnicodeFilter
{
34 virtual UnicodeString
& toPattern(UnicodeString
& result
,
35 UBool escapeUnprintable
) const {
38 virtual UBool
matchesIndexValue(uint8_t v
) const {
41 virtual void addMatchSetTo(UnicodeSet
& toUnionTo
) const {}
45 * A NullFilter always returns a fixed value, either TRUE or FALSE.
46 * A filter value of 0 (that is, a UnicodeFilter* f, where f == 0)
47 * is equivalent to a NullFilter(TRUE).
49 static const char gNullFilterClassID
= 0;
50 class NullFilter
: public _UF
{
53 virtual UClassID
getDynamicClassID() const { return getStaticClassID(); }
54 static inline UClassID
getStaticClassID() { return (UClassID
)&gNullFilterClassID
; }
55 NullFilter(UBool r
) { result
= r
; }
56 NullFilter(const NullFilter
& f
) : _UF(f
) { result
= f
.result
; }
57 virtual ~NullFilter() {}
58 virtual UBool
contains(UChar32
/*c*/) const { return result
; }
59 virtual UnicodeFunctor
* clone() const { return new NullFilter(*this); }
62 static const char gUnicodeNotFilterClassID
= 0;
63 class UnicodeNotFilter
: public _UF
{
66 virtual UClassID
getDynamicClassID() const { return getStaticClassID(); }
67 static inline UClassID
getStaticClassID() { return (UClassID
)&gUnicodeNotFilterClassID
; }
68 UnicodeNotFilter(UnicodeFilter
* adopted
);
69 UnicodeNotFilter(const UnicodeNotFilter
&);
70 virtual ~UnicodeNotFilter();
71 virtual UBool
contains(UChar32 c
) const;
72 virtual UnicodeFunctor
* clone() const;
75 UnicodeNotFilter::UnicodeNotFilter(UnicodeFilter
* adopted
) : filt(adopted
) {}
76 UnicodeNotFilter::UnicodeNotFilter(const UnicodeNotFilter
& f
)
77 : _UF(f
), filt((UnicodeFilter
*) f
.filt
->clone()) {}
78 UnicodeNotFilter::~UnicodeNotFilter() { delete filt
; }
79 UBool
UnicodeNotFilter::contains(UChar32 c
) const { return !filt
->contains(c
); }
80 UnicodeFunctor
* UnicodeNotFilter::clone() const { return new UnicodeNotFilter(*this); }
83 * Returns a <tt>UnicodeFilter</tt> that implements the inverse of
86 UnicodeFilter
* UnicodeFilterLogic::createNot(const UnicodeFilter
* f
) {
88 return new NullFilter(FALSE
);
90 return new UnicodeNotFilter((UnicodeFilter
*)f
->clone());
94 static const char gUnicodeAndFilterClassID
= 0;
95 class UnicodeAndFilter
: public _UF
{
99 virtual UClassID
getDynamicClassID() const { return getStaticClassID(); }
100 static inline UClassID
getStaticClassID() { return (UClassID
)&gUnicodeAndFilterClassID
; }
101 UnicodeAndFilter(UnicodeFilter
* adopted1
, UnicodeFilter
* adopted2
);
102 UnicodeAndFilter(const UnicodeAndFilter
&);
103 virtual ~UnicodeAndFilter();
104 virtual UBool
contains(UChar32 c
) const;
105 virtual UnicodeFunctor
* clone() const;
108 UnicodeAndFilter::UnicodeAndFilter(UnicodeFilter
* f1
, UnicodeFilter
* f2
) : filt1(f1
), filt2(f2
) {}
109 UnicodeAndFilter::UnicodeAndFilter(const UnicodeAndFilter
& f
)
110 : _UF(f
), filt1((UnicodeFilter
*)f
.filt1
->clone()), filt2((UnicodeFilter
*)f
.filt2
->clone()) {}
111 UnicodeAndFilter::~UnicodeAndFilter() { delete filt1
; delete filt2
; }
112 UBool
UnicodeAndFilter::contains(UChar32 c
) const { return filt1
->contains(c
) && filt2
->contains(c
); }
113 UnicodeFunctor
* UnicodeAndFilter::clone() const { return new UnicodeAndFilter(*this); }
116 * Returns a <tt>UnicodeFilter</tt> that implements a short
117 * circuit AND of the result of the two given filters. That is,
118 * if <tt>f.contains()</tt> is <tt>false</tt>, then <tt>g.contains()</tt>
119 * is not called, and <tt>contains()</tt> returns <tt>false</tt>.
121 UnicodeFilter
* UnicodeFilterLogic::createAnd(const UnicodeFilter
* f
,
122 const UnicodeFilter
* g
) {
127 return (UnicodeFilter
*)g
->clone();
130 return (UnicodeFilter
*)f
->clone();
132 return new UnicodeAndFilter((UnicodeFilter
*)f
->clone(), (UnicodeFilter
*)g
->clone());
136 * Returns a <tt>UnicodeFilter</tt> that implements a short
137 * circuit AND of the result of the two given filters. That is,
138 * if <tt>f.contains()</tt> is <tt>false</tt>, then <tt>g.contains()</tt>
139 * is not called, and <tt>contains()</tt> returns <tt>false</tt>.
141 * ADOPTS both arguments.
143 UnicodeFilter
* UnicodeFilterLogic::createAdoptingAnd(UnicodeFilter
* f
,
154 return new UnicodeAndFilter(f
, g
);
157 static const char gUnicodeOrFilterClassID
= 0;
158 class UnicodeOrFilter
: public _UF
{
159 UnicodeFilter
* filt1
;
160 UnicodeFilter
* filt2
;
162 virtual UClassID
getDynamicClassID() const { return getStaticClassID(); }
163 static inline UClassID
getStaticClassID() { return (UClassID
)&gUnicodeOrFilterClassID
; }
164 UnicodeOrFilter(UnicodeFilter
* adopted1
, UnicodeFilter
* adopted2
);
165 UnicodeOrFilter(const UnicodeOrFilter
&);
166 virtual ~UnicodeOrFilter();
167 virtual UBool
contains(UChar32 c
) const;
168 virtual UnicodeFunctor
* clone() const;
171 UnicodeOrFilter::UnicodeOrFilter(UnicodeFilter
* f1
, UnicodeFilter
* f2
) : filt1(f1
), filt2(f2
) {}
172 UnicodeOrFilter::UnicodeOrFilter(const UnicodeOrFilter
& f
)
173 : _UF(f
), filt1((UnicodeFilter
*)f
.filt1
->clone()), filt2((UnicodeFilter
*)f
.filt2
->clone()) {}
174 UnicodeOrFilter::~UnicodeOrFilter() { delete filt1
; delete filt2
; }
175 UBool
UnicodeOrFilter::contains(UChar32 c
) const { return filt1
->contains(c
) || filt2
->contains(c
); }
176 UnicodeFunctor
* UnicodeOrFilter::clone() const { return new UnicodeOrFilter(*this); }
179 * Returns a <tt>UnicodeFilter</tt> that implements a short
180 * circuit OR of the result of the two given filters. That is, if
181 * <tt>f.contains()</tt> is <tt>true</tt>, then <tt>g.contains()</tt> is
182 * not called, and <tt>contains()</tt> returns <tt>true</tt>.
184 UnicodeFilter
* UnicodeFilterLogic::createOr(const UnicodeFilter
* f
,
185 const UnicodeFilter
* g
) {
190 return (UnicodeFilter
*)g
->clone();
193 return (UnicodeFilter
*)f
->clone();
195 return new UnicodeOrFilter((UnicodeFilter
*)f
->clone(), (UnicodeFilter
*)g
->clone());
200 #endif /* #if !UCONFIG_NO_TRANSLITERATION */