1999-11-20 00:40:50 +00:00
|
|
|
/*
|
|
|
|
**********************************************************************
|
2003-11-19 21:46:30 +00:00
|
|
|
* Copyright (C) 1999-2003, International Business Machines
|
1999-11-20 00:40:50 +00:00
|
|
|
* Corporation and others. All Rights Reserved.
|
|
|
|
**********************************************************************
|
|
|
|
* Date Name Description
|
|
|
|
* 11/17/99 aliu Creation.
|
|
|
|
**********************************************************************
|
|
|
|
*/
|
2002-08-28 17:17:04 +00:00
|
|
|
|
|
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
//
|
|
|
|
// NOTICE - Do not use
|
|
|
|
//
|
|
|
|
// This entire file has been deprecated as of ICU 2.4.
|
|
|
|
//
|
|
|
|
//////////////////////////////////////////////////////////////
|
|
|
|
|
2002-09-20 01:54:48 +00:00
|
|
|
#include "unicode/utypes.h"
|
|
|
|
|
2003-11-19 21:46:30 +00:00
|
|
|
#if !UCONFIG_NO_TRANSLITERATION && defined(U_USE_UNICODE_FILTER_LOGIC_OBSOLETE_2_8)
|
2002-09-20 01:54:48 +00:00
|
|
|
|
1999-12-28 23:57:50 +00:00
|
|
|
#include "unicode/unifltlg.h"
|
|
|
|
#include "unicode/unifilt.h"
|
1999-11-20 00:40:50 +00:00
|
|
|
|
2001-10-08 23:26:58 +00:00
|
|
|
U_NAMESPACE_BEGIN
|
|
|
|
|
2002-08-28 17:17:04 +00:00
|
|
|
/**
|
|
|
|
* This class stubs out UnicodeMatcher API that we don't implement.
|
|
|
|
*/
|
|
|
|
class _UF: public UnicodeFilter {
|
|
|
|
|
|
|
|
// Stubs
|
|
|
|
virtual UnicodeString& toPattern(UnicodeString& result,
|
|
|
|
UBool escapeUnprintable) const {
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
virtual UBool matchesIndexValue(uint8_t v) const {
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
virtual void addMatchSetTo(UnicodeSet& toUnionTo) const {}
|
|
|
|
};
|
|
|
|
|
2000-02-05 00:24:24 +00:00
|
|
|
/**
|
|
|
|
* A NullFilter always returns a fixed value, either TRUE or FALSE.
|
|
|
|
* A filter value of 0 (that is, a UnicodeFilter* f, where f == 0)
|
|
|
|
* is equivalent to a NullFilter(TRUE).
|
|
|
|
*/
|
2002-12-18 01:46:21 +00:00
|
|
|
static const char gNullFilterClassID = 0;
|
2002-08-28 17:17:04 +00:00
|
|
|
class NullFilter : public _UF {
|
2000-05-18 22:08:39 +00:00
|
|
|
UBool result;
|
2000-02-05 00:24:24 +00:00
|
|
|
public:
|
2002-12-18 00:52:21 +00:00
|
|
|
virtual UClassID getDynamicClassID() const { return getStaticClassID(); }
|
|
|
|
static inline UClassID getStaticClassID() { return (UClassID)&gNullFilterClassID; }
|
2000-05-18 22:08:39 +00:00
|
|
|
NullFilter(UBool r) { result = r; }
|
2002-08-28 17:17:04 +00:00
|
|
|
NullFilter(const NullFilter& f) : _UF(f) { result = f.result; }
|
2000-02-05 00:24:24 +00:00
|
|
|
virtual ~NullFilter() {}
|
2001-07-25 19:11:02 +00:00
|
|
|
virtual UBool contains(UChar32 /*c*/) const { return result; }
|
2002-02-07 01:07:55 +00:00
|
|
|
virtual UnicodeFunctor* clone() const { return new NullFilter(*this); }
|
2000-02-05 00:24:24 +00:00
|
|
|
};
|
|
|
|
|
2002-12-18 01:46:21 +00:00
|
|
|
static const char gUnicodeNotFilterClassID = 0;
|
2002-08-28 17:17:04 +00:00
|
|
|
class UnicodeNotFilter : public _UF {
|
1999-11-20 00:40:50 +00:00
|
|
|
UnicodeFilter* filt;
|
|
|
|
public:
|
2002-12-18 00:52:21 +00:00
|
|
|
virtual UClassID getDynamicClassID() const { return getStaticClassID(); }
|
|
|
|
static inline UClassID getStaticClassID() { return (UClassID)&gUnicodeNotFilterClassID; }
|
1999-11-20 00:40:50 +00:00
|
|
|
UnicodeNotFilter(UnicodeFilter* adopted);
|
|
|
|
UnicodeNotFilter(const UnicodeNotFilter&);
|
|
|
|
virtual ~UnicodeNotFilter();
|
2001-07-25 19:11:02 +00:00
|
|
|
virtual UBool contains(UChar32 c) const;
|
2002-02-07 01:07:55 +00:00
|
|
|
virtual UnicodeFunctor* clone() const;
|
1999-11-20 00:40:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
UnicodeNotFilter::UnicodeNotFilter(UnicodeFilter* adopted) : filt(adopted) {}
|
2001-03-06 20:12:26 +00:00
|
|
|
UnicodeNotFilter::UnicodeNotFilter(const UnicodeNotFilter& f)
|
2002-08-28 17:17:04 +00:00
|
|
|
: _UF(f), filt((UnicodeFilter*) f.filt->clone()) {}
|
1999-11-20 00:40:50 +00:00
|
|
|
UnicodeNotFilter::~UnicodeNotFilter() { delete filt; }
|
2001-07-25 19:11:02 +00:00
|
|
|
UBool UnicodeNotFilter::contains(UChar32 c) const { return !filt->contains(c); }
|
2002-02-07 01:07:55 +00:00
|
|
|
UnicodeFunctor* UnicodeNotFilter::clone() const { return new UnicodeNotFilter(*this); }
|
1999-11-20 00:40:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a <tt>UnicodeFilter</tt> that implements the inverse of
|
|
|
|
* the given filter.
|
|
|
|
*/
|
2000-02-05 00:24:24 +00:00
|
|
|
UnicodeFilter* UnicodeFilterLogic::createNot(const UnicodeFilter* f) {
|
|
|
|
if (f == 0) {
|
|
|
|
return new NullFilter(FALSE);
|
|
|
|
} else {
|
2001-07-27 00:18:53 +00:00
|
|
|
return new UnicodeNotFilter((UnicodeFilter*)f->clone());
|
2000-02-05 00:24:24 +00:00
|
|
|
}
|
1999-11-20 00:40:50 +00:00
|
|
|
}
|
|
|
|
|
2002-12-18 01:46:21 +00:00
|
|
|
static const char gUnicodeAndFilterClassID = 0;
|
2002-08-28 17:17:04 +00:00
|
|
|
class UnicodeAndFilter : public _UF {
|
1999-11-20 00:40:50 +00:00
|
|
|
UnicodeFilter* filt1;
|
|
|
|
UnicodeFilter* filt2;
|
|
|
|
public:
|
2002-12-18 00:52:21 +00:00
|
|
|
virtual UClassID getDynamicClassID() const { return getStaticClassID(); }
|
|
|
|
static inline UClassID getStaticClassID() { return (UClassID)&gUnicodeAndFilterClassID; }
|
1999-11-20 00:40:50 +00:00
|
|
|
UnicodeAndFilter(UnicodeFilter* adopted1, UnicodeFilter* adopted2);
|
|
|
|
UnicodeAndFilter(const UnicodeAndFilter&);
|
|
|
|
virtual ~UnicodeAndFilter();
|
2001-07-25 19:11:02 +00:00
|
|
|
virtual UBool contains(UChar32 c) const;
|
2002-02-07 01:07:55 +00:00
|
|
|
virtual UnicodeFunctor* clone() const;
|
1999-11-20 00:40:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
UnicodeAndFilter::UnicodeAndFilter(UnicodeFilter* f1, UnicodeFilter* f2) : filt1(f1), filt2(f2) {}
|
2001-03-06 20:12:26 +00:00
|
|
|
UnicodeAndFilter::UnicodeAndFilter(const UnicodeAndFilter& f)
|
2002-08-28 17:17:04 +00:00
|
|
|
: _UF(f), filt1((UnicodeFilter*)f.filt1->clone()), filt2((UnicodeFilter*)f.filt2->clone()) {}
|
1999-11-20 00:40:50 +00:00
|
|
|
UnicodeAndFilter::~UnicodeAndFilter() { delete filt1; delete filt2; }
|
2001-07-25 19:11:02 +00:00
|
|
|
UBool UnicodeAndFilter::contains(UChar32 c) const { return filt1->contains(c) && filt2->contains(c); }
|
2002-02-07 01:07:55 +00:00
|
|
|
UnicodeFunctor* UnicodeAndFilter::clone() const { return new UnicodeAndFilter(*this); }
|
1999-11-20 00:40:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a <tt>UnicodeFilter</tt> that implements a short
|
|
|
|
* circuit AND of the result of the two given filters. That is,
|
2000-01-18 20:00:56 +00:00
|
|
|
* if <tt>f.contains()</tt> is <tt>false</tt>, then <tt>g.contains()</tt>
|
|
|
|
* is not called, and <tt>contains()</tt> returns <tt>false</tt>.
|
1999-11-20 00:40:50 +00:00
|
|
|
*/
|
2000-02-05 00:24:24 +00:00
|
|
|
UnicodeFilter* UnicodeFilterLogic::createAnd(const UnicodeFilter* f,
|
|
|
|
const UnicodeFilter* g) {
|
|
|
|
if (f == 0) {
|
|
|
|
if (g == 0) {
|
|
|
|
return NULL;
|
|
|
|
}
|
2001-07-27 00:18:53 +00:00
|
|
|
return (UnicodeFilter*)g->clone();
|
2000-02-05 00:24:24 +00:00
|
|
|
}
|
|
|
|
if (g == 0) {
|
2001-07-27 00:18:53 +00:00
|
|
|
return (UnicodeFilter*)f->clone();
|
2000-02-05 00:24:24 +00:00
|
|
|
}
|
2001-07-27 00:18:53 +00:00
|
|
|
return new UnicodeAndFilter((UnicodeFilter*)f->clone(), (UnicodeFilter*)g->clone());
|
1999-11-20 00:40:50 +00:00
|
|
|
}
|
|
|
|
|
2001-10-24 13:34:11 +00:00
|
|
|
/**
|
|
|
|
* Returns a <tt>UnicodeFilter</tt> that implements a short
|
|
|
|
* circuit AND of the result of the two given filters. That is,
|
|
|
|
* if <tt>f.contains()</tt> is <tt>false</tt>, then <tt>g.contains()</tt>
|
|
|
|
* is not called, and <tt>contains()</tt> returns <tt>false</tt>.
|
|
|
|
*
|
|
|
|
* ADOPTS both arguments.
|
|
|
|
*/
|
|
|
|
UnicodeFilter* UnicodeFilterLogic::createAdoptingAnd(UnicodeFilter* f,
|
|
|
|
UnicodeFilter* g) {
|
|
|
|
if (f == 0) {
|
|
|
|
if (g == 0) {
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
return g;
|
|
|
|
}
|
|
|
|
if (g == 0) {
|
|
|
|
return f;
|
|
|
|
}
|
|
|
|
return new UnicodeAndFilter(f, g);
|
|
|
|
}
|
|
|
|
|
2002-12-18 01:46:21 +00:00
|
|
|
static const char gUnicodeOrFilterClassID = 0;
|
2002-08-28 17:17:04 +00:00
|
|
|
class UnicodeOrFilter : public _UF {
|
1999-11-20 00:40:50 +00:00
|
|
|
UnicodeFilter* filt1;
|
|
|
|
UnicodeFilter* filt2;
|
|
|
|
public:
|
2002-12-18 00:52:21 +00:00
|
|
|
virtual UClassID getDynamicClassID() const { return getStaticClassID(); }
|
|
|
|
static inline UClassID getStaticClassID() { return (UClassID)&gUnicodeOrFilterClassID; }
|
1999-11-20 00:40:50 +00:00
|
|
|
UnicodeOrFilter(UnicodeFilter* adopted1, UnicodeFilter* adopted2);
|
|
|
|
UnicodeOrFilter(const UnicodeOrFilter&);
|
|
|
|
virtual ~UnicodeOrFilter();
|
2001-07-25 19:11:02 +00:00
|
|
|
virtual UBool contains(UChar32 c) const;
|
2002-02-07 01:07:55 +00:00
|
|
|
virtual UnicodeFunctor* clone() const;
|
1999-11-20 00:40:50 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
UnicodeOrFilter::UnicodeOrFilter(UnicodeFilter* f1, UnicodeFilter* f2) : filt1(f1), filt2(f2) {}
|
2001-03-06 20:12:26 +00:00
|
|
|
UnicodeOrFilter::UnicodeOrFilter(const UnicodeOrFilter& f)
|
2002-08-28 17:17:04 +00:00
|
|
|
: _UF(f), filt1((UnicodeFilter*)f.filt1->clone()), filt2((UnicodeFilter*)f.filt2->clone()) {}
|
1999-11-20 00:40:50 +00:00
|
|
|
UnicodeOrFilter::~UnicodeOrFilter() { delete filt1; delete filt2; }
|
2001-07-25 19:11:02 +00:00
|
|
|
UBool UnicodeOrFilter::contains(UChar32 c) const { return filt1->contains(c) || filt2->contains(c); }
|
2002-02-07 01:07:55 +00:00
|
|
|
UnicodeFunctor* UnicodeOrFilter::clone() const { return new UnicodeOrFilter(*this); }
|
1999-11-20 00:40:50 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns a <tt>UnicodeFilter</tt> that implements a short
|
|
|
|
* circuit OR of the result of the two given filters. That is, if
|
2000-01-18 20:00:56 +00:00
|
|
|
* <tt>f.contains()</tt> is <tt>true</tt>, then <tt>g.contains()</tt> is
|
|
|
|
* not called, and <tt>contains()</tt> returns <tt>true</tt>.
|
1999-11-20 00:40:50 +00:00
|
|
|
*/
|
2000-02-05 00:24:24 +00:00
|
|
|
UnicodeFilter* UnicodeFilterLogic::createOr(const UnicodeFilter* f,
|
|
|
|
const UnicodeFilter* g) {
|
|
|
|
if (f == 0) {
|
|
|
|
if (g == 0) {
|
|
|
|
return NULL;
|
|
|
|
}
|
2001-07-27 00:18:53 +00:00
|
|
|
return (UnicodeFilter*)g->clone();
|
2000-02-05 00:24:24 +00:00
|
|
|
}
|
|
|
|
if (g == 0) {
|
2001-07-27 00:18:53 +00:00
|
|
|
return (UnicodeFilter*)f->clone();
|
2000-02-05 00:24:24 +00:00
|
|
|
}
|
2001-07-27 00:18:53 +00:00
|
|
|
return new UnicodeOrFilter((UnicodeFilter*)f->clone(), (UnicodeFilter*)g->clone());
|
1999-11-20 00:40:50 +00:00
|
|
|
}
|
2001-10-08 23:26:58 +00:00
|
|
|
|
|
|
|
U_NAMESPACE_END
|
|
|
|
|
2002-09-20 01:54:48 +00:00
|
|
|
#endif /* #if !UCONFIG_NO_TRANSLITERATION */
|