ucnv_set.cpp 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. #include "unicode/utypes.h"
  23. #include "unicode/uset.h"
  24. #include "unicode/ucnv.h"
  25. #include "ucnv_bld.h"
  26. #include "uset_imp.h"
  27. #if !UCONFIG_NO_CONVERSION
  28. U_CAPI void U_EXPORT2
  29. ucnv_getUnicodeSet(const UConverter *cnv,
  30. USet *setFillIn,
  31. UConverterUnicodeSet whichSet,
  32. UErrorCode *pErrorCode) {
  33. /* argument checking */
  34. if(pErrorCode==nullptr || U_FAILURE(*pErrorCode)) {
  35. return;
  36. }
  37. if(cnv==nullptr || setFillIn==nullptr || whichSet<UCNV_ROUNDTRIP_SET || UCNV_SET_COUNT<=whichSet) {
  38. *pErrorCode=U_ILLEGAL_ARGUMENT_ERROR;
  39. return;
  40. }
  41. /* does this converter support this function? */
  42. if(cnv->sharedData->impl->getUnicodeSet==nullptr) {
  43. *pErrorCode=U_UNSUPPORTED_ERROR;
  44. return;
  45. }
  46. {
  47. USetAdder sa={
  48. nullptr,
  49. uset_add,
  50. uset_addRange,
  51. uset_addString,
  52. uset_remove,
  53. uset_removeRange
  54. };
  55. sa.set=setFillIn;
  56. /* empty the set */
  57. uset_clear(setFillIn);
  58. /* call the converter to add the code points it supports */
  59. cnv->sharedData->impl->getUnicodeSet(cnv, &sa, whichSet, pErrorCode);
  60. }
  61. }
  62. #endif