+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
/*
*******************************************************************************
- * Copyright (C) 1997-2004, International Business Machines
+ * Copyright (C) 1997-2009,2014 International Business Machines
* Corporation and others. All Rights Reserved.
*******************************************************************************
* Date Name Description
#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"
class ReplaceableGlue : public Replaceable {
UReplaceable *rep;
- UReplaceableCallbacks *func;
+ const UReplaceableCallbacks *func;
public:
ReplaceableGlue(UReplaceable *replaceable,
- UReplaceableCallbacks *funcCallback);
+ const UReplaceableCallbacks *funcCallback);
virtual ~ReplaceableGlue();
*
* @draft ICU 2.2
*/
- virtual inline UClassID getDynamicClassID() const;
+ virtual UClassID getDynamicClassID() const;
/**
* ICU "poor man's RTTI", returns a UClassID for this class.
*
* @draft ICU 2.2
*/
- static inline UClassID U_EXPORT2 getStaticClassID();
+ static UClassID U_EXPORT2 getStaticClassID();
protected:
UOBJECT_DEFINE_RTTI_IMPLEMENTATION(ReplaceableGlue)
ReplaceableGlue::ReplaceableGlue(UReplaceable *replaceable,
- UReplaceableCallbacks *funcCallback)
+ const UReplaceableCallbacks *funcCallback)
: Replaceable()
{
this->rep = replaceable;
rules,
rulesLength); // r-o alias
- RuleBasedTransliterator *trans = NULL;
- trans = new RuleBasedTransliterator(ID, ruleStr, dir,
- NULL, *parseError, *status);
- if (trans == NULL) {
- *status = U_MEMORY_ALLOCATION_ERROR;
- } else if (U_FAILURE(*status)) {
- delete trans;
- trans = NULL;
+ Transliterator *trans = NULL;
+ trans = Transliterator::createFromRules(ID, ruleStr, dir, *parseError, *status);
+ if(U_FAILURE(*status)) {
+ return NULL;
}
+
return (UTransliterator*) trans;
}
}
int32_t rulesLength, /* -1 if null-terminated */
UParseError* parseError, /* may be Null */
UErrorCode* status) {
- UnicodeString ID(id, ""); // use invariant converter
+ UnicodeString ID(id, -1, US_INV); // use invariant converter
return utrans_openU(ID.getBuffer(), ID.length(), dir,
rules, rulesLength,
parseError, status);
utrans_getID(const UTransliterator* trans,
char* buf,
int32_t bufCapacity) {
- return ((Transliterator*) trans)->getID().extract(0, 0x7fffffff, buf, bufCapacity, "");
+ return ((Transliterator*) trans)->getID().extract(0, 0x7fffffff, buf, bufCapacity, US_INV);
}
U_CAPI void U_EXPORT2
U_CAPI void U_EXPORT2
utrans_unregister(const char* id) {
- UnicodeString ID(id, ""); // use invariant converter
+ UnicodeString ID(id, -1, US_INV); // use invariant converter
Transliterator::unregister(ID);
}
utrans_getAvailableID(int32_t index,
char* buf, // may be NULL
int32_t bufCapacity) {
- return Transliterator::getAvailableID(index).extract(0, 0x7fffffff, buf, bufCapacity, "");
+ return Transliterator::getAvailableID(index).extract(0, 0x7fffffff, buf, bufCapacity, US_INV);
}
/* Transliterator UEnumeration ---------------------------------------------- */
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) {
U_CAPI void U_EXPORT2
utrans_transIncremental(const UTransliterator* trans,
UReplaceable* rep,
- UReplaceableCallbacks* repFunc,
+ const UReplaceableCallbacks* repFunc,
UTransPosition* pos,
UErrorCode* status) {
}
}
+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 */