]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/i18n/funcrepl.cpp
ICU-64260.0.1.tar.gz
[apple/icu.git] / icuSources / i18n / funcrepl.cpp
index 8b33196e3d8648c2e4f9e6ec49ee9df13d45f4d9..01c8754657bfb8d5a1077711ed202d3a68d4e71c 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) 2002, International Business Machines Corporation
+*   Copyright (c) 2002-2012, International Business Machines Corporation
 *   and others.  All Rights Reserved.
 **********************************************************************
 *   Date        Name        Description
@@ -22,7 +24,7 @@ static const UChar CLOSE[]   = {32,41,0}; // " )"
 
 U_NAMESPACE_BEGIN
 
-const char FunctionReplacer::fgClassID=0;
+UOBJECT_DEFINE_RTTI_IMPLEMENTATION(FunctionReplacer)
 
 /**
  * Construct a replacer that takes the output of the given
@@ -38,7 +40,10 @@ FunctionReplacer::FunctionReplacer(Transliterator* adoptedTranslit,
 /**
  * Copy constructor.
  */
-FunctionReplacer::FunctionReplacer(const FunctionReplacer& other) {
+FunctionReplacer::FunctionReplacer(const FunctionReplacer& other) :
+    UnicodeFunctor(other),
+    UnicodeReplacer(other)
+{
     translit = other.translit->clone();
     replacer = other.replacer->clone();
 }
@@ -63,7 +68,10 @@ UnicodeFunctor* FunctionReplacer::clone() const {
  * and return the pointer.
  */
 UnicodeReplacer* FunctionReplacer::toReplacer() const {
-    return (UnicodeReplacer*) this;
+  FunctionReplacer  *nonconst_this = const_cast<FunctionReplacer *>(this);
+  UnicodeReplacer *nonconst_base = static_cast<UnicodeReplacer *>(nonconst_this);
+  
+  return nonconst_base;
 }
 
 /**
@@ -72,7 +80,8 @@ UnicodeReplacer* FunctionReplacer::toReplacer() const {
 int32_t FunctionReplacer::replace(Replaceable& text,
                                   int32_t start,
                                   int32_t limit,
-                                  int32_t& cursor) {
+                                  int32_t& cursor)
+{
 
     // First delegate to subordinate replacer
     int32_t len = replacer->toReplacer()->replace(text, start, limit, cursor);
@@ -93,9 +102,9 @@ UnicodeString& FunctionReplacer::toReplacerPattern(UnicodeString& rule,
     rule.truncate(0);
     rule.append(AMPERSAND);
     rule.append(translit->getID());
-    rule.append(OPEN);
+    rule.append(OPEN, 2);
     rule.append(replacer->toReplacer()->toReplacerPattern(str, escapeUnprintable));
-    rule.append(CLOSE);
+    rule.append(CLOSE, 2);
     return rule;
 }