intl/icu/source/common/ucnv_set.c

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/intl/icu/source/common/ucnv_set.c	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,68 @@
     1.4 +/*
     1.5 +*******************************************************************************
     1.6 +*
     1.7 +*   Copyright (C) 2003-2007, International Business Machines
     1.8 +*   Corporation and others.  All Rights Reserved.
     1.9 +*
    1.10 +*******************************************************************************
    1.11 +*   file name:  ucnv_set.c
    1.12 +*   encoding:   US-ASCII
    1.13 +*   tab size:   8 (not used)
    1.14 +*   indentation:4
    1.15 +*
    1.16 +*   created on: 2004sep07
    1.17 +*   created by: Markus W. Scherer
    1.18 +*
    1.19 +*   Conversion API functions using USet (ucnv_getUnicodeSet())
    1.20 +*   moved here from ucnv.c for removing the dependency of other ucnv_
    1.21 +*   implementation functions on the USet implementation.
    1.22 +*/
    1.23 +
    1.24 +#include "unicode/utypes.h"
    1.25 +#include "unicode/uset.h"
    1.26 +#include "unicode/ucnv.h"
    1.27 +#include "ucnv_bld.h"
    1.28 +#include "uset_imp.h"
    1.29 +
    1.30 +#if !UCONFIG_NO_CONVERSION
    1.31 +
    1.32 +U_CAPI void U_EXPORT2
    1.33 +ucnv_getUnicodeSet(const UConverter *cnv,
    1.34 +                   USet *setFillIn,
    1.35 +                   UConverterUnicodeSet whichSet,
    1.36 +                   UErrorCode *pErrorCode) {
    1.37 +    /* argument checking */
    1.38 +    if(pErrorCode==NULL || U_FAILURE(*pErrorCode)) {
    1.39 +        return;
    1.40 +    }
    1.41 +    if(cnv==NULL || setFillIn==NULL || whichSet<UCNV_ROUNDTRIP_SET || UCNV_SET_COUNT<=whichSet) {
    1.42 +        *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
    1.43 +        return;
    1.44 +    }
    1.45 +
    1.46 +    /* does this converter support this function? */
    1.47 +    if(cnv->sharedData->impl->getUnicodeSet==NULL) {
    1.48 +        *pErrorCode=U_UNSUPPORTED_ERROR;
    1.49 +        return;
    1.50 +    }
    1.51 +
    1.52 +    {
    1.53 +        USetAdder sa={
    1.54 +            NULL,
    1.55 +            uset_add,
    1.56 +            uset_addRange,
    1.57 +            uset_addString,
    1.58 +            uset_remove,
    1.59 +            uset_removeRange
    1.60 +        };
    1.61 +        sa.set=setFillIn;
    1.62 +
    1.63 +        /* empty the set */
    1.64 +        uset_clear(setFillIn);
    1.65 +
    1.66 +        /* call the converter to add the code points it supports */
    1.67 +        cnv->sharedData->impl->getUnicodeSet(cnv, &sa, whichSet, pErrorCode);
    1.68 +    }
    1.69 +}
    1.70 +
    1.71 +#endif

mercurial