]> git.saurik.com Git - apple/icu.git/blame - icuSources/common/ucnv_set.cpp
ICU-66108.tar.gz
[apple/icu.git] / icuSources / common / ucnv_set.cpp
CommitLineData
f3c0d7a5
A
1// © 2016 and later: Unicode, Inc. and others.
2// License & terms of use: http://www.unicode.org/copyright.html
374ca955
A
3/*
4*******************************************************************************
5*
46f4442e 6* Copyright (C) 2003-2007, International Business Machines
374ca955
A
7* Corporation and others. All Rights Reserved.
8*
9*******************************************************************************
10* file name: ucnv_set.c
f3c0d7a5 11* encoding: UTF-8
374ca955
A
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
31U_CAPI void U_EXPORT2
32ucnv_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,
73c04bcf 56 uset_addString,
46f4442e
A
57 uset_remove,
58 uset_removeRange
374ca955
A
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