2 * Copyright 2003-2017, Haiku, Inc.
3 * Distributed under the terms of the MIT Licence.
9 #include <Archivable.h>
10 #include <SupportDefs.h>
13 #ifndef U_ICU_NAMESPACE
14 #define U_ICU_NAMESPACE icu
16 namespace U_ICU_NAMESPACE
{
23 enum collator_strengths
{
24 B_COLLATE_DEFAULT
= -1,
26 B_COLLATE_PRIMARY
= 1, // e.g.: no diacritical differences, e = é
27 B_COLLATE_SECONDARY
, // diacritics are different from their base
29 B_COLLATE_TERTIARY
, // case sensitive comparison
32 B_COLLATE_IDENTICAL
= 127 // Unicode value
36 class BCollator
: public BArchivable
{
39 BCollator(const char* locale
,
40 int8 strength
= B_COLLATE_PRIMARY
,
41 bool ignorePunctuation
= false);
42 BCollator(BMessage
* archive
);
44 BCollator(const BCollator
& other
);
48 BCollator
& operator=(const BCollator
& source
);
50 status_t
SetStrength(int8 strength
) const;
52 void SetIgnorePunctuation(bool ignore
);
53 bool IgnorePunctuation() const;
55 status_t
SetNumericSorting(bool enable
);
57 status_t
GetSortKey(const char* string
, BString
* key
)
60 int Compare(const char* s1
, const char* s2
)
62 bool Equal(const char* s1
, const char* s2
)
64 bool Greater(const char* s1
, const char* s2
)
66 bool GreaterOrEqual(const char* s1
, const char* s2
)
70 status_t
Archive(BMessage
* archive
, bool deep
) const;
71 static BArchivable
* Instantiate(BMessage
* archive
);
75 mutable U_ICU_NAMESPACE::Collator
* fICUCollator
;
76 bool fIgnorePunctuation
;
81 BCollator::Equal(const char *s1
, const char *s2
) const
83 return Compare(s1
, s2
) == 0;
88 BCollator::Greater(const char *s1
, const char *s2
) const
90 return Compare(s1
, s2
) > 0;
95 BCollator::GreaterOrEqual(const char *s1
, const char *s2
) const
97 return Compare(s1
, s2
) >= 0;
101 #endif /* _COLLATOR_H_ */