]>
Commit | Line | Data |
---|---|---|
1 | // © 2016 and later: Unicode, Inc. and others. | |
2 | // License & terms of use: http://www.unicode.org/copyright.html | |
3 | /* | |
4 | ******************************************************************************* | |
5 | * | |
6 | * Copyright (C) 2003-2007, International Business Machines | |
7 | * Corporation and others. All Rights Reserved. | |
8 | * | |
9 | ******************************************************************************* | |
10 | * file name: ucnv_set.c | |
11 | * encoding: UTF-8 | |
12 | * tab size: 8 (not used) | |
13 | * indentation:4 | |
14 | * | |
15 | * created on: 2004sep07 | |
16 | * created by: Markus W. Scherer | |
17 | * | |
18 | * Conversion API functions using USet (ucnv_getUnicodeSet()) | |
19 | * moved here from ucnv.c for removing the dependency of other ucnv_ | |
20 | * implementation functions on the USet implementation. | |
21 | */ | |
22 | ||
23 | #include "unicode/utypes.h" | |
24 | #include "unicode/uset.h" | |
25 | #include "unicode/ucnv.h" | |
26 | #include "ucnv_bld.h" | |
27 | #include "uset_imp.h" | |
28 | ||
29 | #if !UCONFIG_NO_CONVERSION | |
30 | ||
31 | U_CAPI void U_EXPORT2 | |
32 | ucnv_getUnicodeSet(const UConverter *cnv, | |
33 | USet *setFillIn, | |
34 | UConverterUnicodeSet whichSet, | |
35 | UErrorCode *pErrorCode) { | |
36 | /* argument checking */ | |
37 | if(pErrorCode==NULL || U_FAILURE(*pErrorCode)) { | |
38 | return; | |
39 | } | |
40 | if(cnv==NULL || setFillIn==NULL || whichSet<UCNV_ROUNDTRIP_SET || UCNV_SET_COUNT<=whichSet) { | |
41 | *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR; | |
42 | return; | |
43 | } | |
44 | ||
45 | /* does this converter support this function? */ | |
46 | if(cnv->sharedData->impl->getUnicodeSet==NULL) { | |
47 | *pErrorCode=U_UNSUPPORTED_ERROR; | |
48 | return; | |
49 | } | |
50 | ||
51 | { | |
52 | USetAdder sa={ | |
53 | NULL, | |
54 | uset_add, | |
55 | uset_addRange, | |
56 | uset_addString, | |
57 | uset_remove, | |
58 | uset_removeRange | |
59 | }; | |
60 | sa.set=setFillIn; | |
61 | ||
62 | /* empty the set */ | |
63 | uset_clear(setFillIn); | |
64 | ||
65 | /* call the converter to add the code points it supports */ | |
66 | cnv->sharedData->impl->getUnicodeSet(cnv, &sa, whichSet, pErrorCode); | |
67 | } | |
68 | } | |
69 | ||
70 | #endif |