ICU-4404 Add some missing uset functions.

X-SVN-Rev: 17193
This commit is contained in:
George Rhoten 2005-02-08 18:40:36 +00:00
parent 514d090022
commit ff6d9533d5
2 changed files with 42 additions and 6 deletions

View file

@ -368,6 +368,17 @@ uset_addRange(USet* set, UChar32 start, UChar32 end);
U_STABLE void U_EXPORT2
uset_addString(USet* set, const UChar* str, int32_t strLen);
/**
* Adds each of the characters in this string to the set. Thus "ch" => {"c", "h"}
* If this set already any particular character, it has no effect on that character.
* @param set the object to which to add the character
* @param str the source string
* @param strLen the length of the string or -1 if null terminated.
* @draft ICU 3.4
*/
U_DRAFT void U_EXPORT2
uset_addAllCodePoints(USet* set, const UChar *str, int32_t strLen);
/**
* Removes the given character from the given USet. After this call,
* uset_contains(set, c) will return FALSE.
@ -611,6 +622,19 @@ uset_getItem(const USet* set, int32_t itemIndex,
U_DRAFT UBool U_EXPORT2
uset_containsAll(const USet* set1, const USet* set2);
/**
* Returns true if this set contains all the characters
* of the given string. This is does not check containment of grapheme
* clusters, like uset_containsString.
* @param set set of characters to be checked for containment
* @param str string containing codepoints to be checked for containment
* @param strLen the length of the string or -1 if null terminated.
* @return true if the test condition is met
* @draft ICU 3.4
*/
U_DRAFT UBool U_EXPORT2
uset_containsAllCodePoints(USet* set, const UChar *str, int32_t strLen);
/**
* Returns true if set1 contains none of the characters and strings
* of set2. It answers the question, 'Is set1 a disjoint set of set2?'

View file

@ -62,17 +62,22 @@ uset_addRange(USet* set, UChar32 start, UChar32 end) {
U_CAPI void U_EXPORT2
uset_addString(USet* set, const UChar* str, int32_t strLen) {
// WRONG! Do not alias, it will stay aliased, even after
// copying. TODO: do we need a copy ctor that unaliases
// WRONG! Do not alias, it will stay aliased, even after
// copying. TODO: do we need a copy ctor that unaliases
//UnicodeString s(strLen==-1, str, strLen);
// We promised -1 for zero terminated
if(strLen == -1) {
strLen = u_strlen(str);
}
// UnicodeString handles -1 for strLen
UnicodeString s(str, strLen);
((UnicodeSet*) set)->add(s);
}
U_CAPI void U_EXPORT2
uset_addAllCodePoints(USet* set, const UChar *str, int32_t strLen) {
// UnicodeString handles -1 for strLen
UnicodeString s(str, strLen);
((UnicodeSet*) set)->addAll(s);
}
U_CAPI void U_EXPORT2
uset_remove(USet* set, UChar32 c) {
((UnicodeSet*) set)->remove(c);
@ -150,6 +155,13 @@ uset_containsAll(const USet* set1, const USet* set2) {
return ((const UnicodeSet*) set1)->containsAll(* (const UnicodeSet*) set2);
}
U_CAPI UBool U_EXPORT2
uset_containsAllCodePoints(USet* set, const UChar *str, int32_t strLen) {
// Create a string alias, since nothing is being added to the set.
UnicodeString s(strLen==-1, str, strLen);
return ((const UnicodeSet*) set)->containsAll(s);
}
U_CAPI UBool U_EXPORT2
uset_containsNone(const USet* set1, const USet* set2) {
return ((const UnicodeSet*) set1)->containsNone(* (const UnicodeSet*) set2);