]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/i18n/utrans.cpp
ICU-64243.0.1.tar.gz
[apple/icu.git] / icuSources / i18n / utrans.cpp
index 16a09bdcb6a9e225b93cf9db6e5da3e8c8e29193..29013ead1257c239755aaa554a28a1158969100f 100644 (file)
@@ -1,6 +1,8 @@
+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
 /*
  *******************************************************************************
- *   Copyright (C) 1997-2009, International Business Machines
+ *   Copyright (C) 1997-2009,2014 International Business Machines
  *   Corporation and others.  All Rights Reserved.
  *******************************************************************************
  *   Date        Name        Description
@@ -20,6 +22,7 @@
 #include "unicode/uniset.h"
 #include "unicode/ustring.h"
 #include "unicode/uenum.h"
+#include "unicode/uset.h"
 #include "uenumimp.h"
 #include "cpputils.h"
 #include "rbt.h"
@@ -38,12 +41,12 @@ U_NAMESPACE_BEGIN
 class ReplaceableGlue : public Replaceable {
 
     UReplaceable *rep;
-    UReplaceableCallbacks *func;
+    const UReplaceableCallbacks *func;
 
 public:
 
     ReplaceableGlue(UReplaceable *replaceable,
-                    UReplaceableCallbacks *funcCallback);
+                    const UReplaceableCallbacks *funcCallback);
 
     virtual ~ReplaceableGlue();
 
@@ -85,7 +88,7 @@ protected:
 UOBJECT_DEFINE_RTTI_IMPLEMENTATION(ReplaceableGlue)
 
 ReplaceableGlue::ReplaceableGlue(UReplaceable *replaceable,
-                                 UReplaceableCallbacks *funcCallback)
+                                 const UReplaceableCallbacks *funcCallback)
   : Replaceable()
 {
     this->rep = replaceable;
@@ -395,7 +398,7 @@ utrans_openIDs(UErrorCode *pErrorCode) {
 U_CAPI void U_EXPORT2
 utrans_trans(const UTransliterator* trans,
              UReplaceable* rep,
-             UReplaceableCallbacks* repFunc,
+             const UReplaceableCallbacks* repFunc,
              int32_t start,
              int32_t* limit,
              UErrorCode* status) {
@@ -415,7 +418,7 @@ utrans_trans(const UTransliterator* trans,
 U_CAPI void U_EXPORT2
 utrans_transIncremental(const UTransliterator* trans,
                         UReplaceable* rep,
-                        UReplaceableCallbacks* repFunc,
+                        const UReplaceableCallbacks* repFunc,
                         UTransPosition* pos,
                         UErrorCode* status) {
 
@@ -492,4 +495,39 @@ utrans_transIncrementalUChars(const UTransliterator* trans,
     }
 }
 
+U_CAPI int32_t U_EXPORT2
+utrans_toRules(     const UTransliterator* trans,
+                    UBool escapeUnprintable,
+                    UChar* result, int32_t resultLength,
+                    UErrorCode* status) {
+    utrans_ENTRY(status) 0;
+    if ( (result==NULL)? resultLength!=0: resultLength<0 ) {
+        *status = U_ILLEGAL_ARGUMENT_ERROR;
+        return 0;
+    }
+
+    UnicodeString res;
+    res.setTo(result, 0, resultLength);
+    ((Transliterator*) trans)->toRules(res, escapeUnprintable);
+    return res.extract(result, resultLength, *status);
+}
+
+U_CAPI USet* U_EXPORT2
+utrans_getSourceSet(const UTransliterator* trans,
+                    UBool ignoreFilter,
+                    USet* fillIn,
+                    UErrorCode* status) {
+    utrans_ENTRY(status) fillIn;
+
+    if (fillIn == NULL) {
+        fillIn = uset_openEmpty();
+    }
+    if (ignoreFilter) {
+        ((Transliterator*) trans)->handleGetSourceSet(*((UnicodeSet*)fillIn));
+    } else {
+        ((Transliterator*) trans)->getSourceSet(*((UnicodeSet*)fillIn));
+    }
+    return fillIn;
+}
+
 #endif /* #if !UCONFIG_NO_TRANSLITERATION */