]> granicus.if.org Git - icu/commitdiff
ICU-12992 remove Char16Ptr output conversion overloads, remove wrapper-as-pointer...
authorMarkus Scherer <markus.icu@gmail.com>
Fri, 3 Mar 2017 23:55:13 +0000 (23:55 +0000)
committerMarkus Scherer <markus.icu@gmail.com>
Fri, 3 Mar 2017 23:55:13 +0000 (23:55 +0000)
X-SVN-Rev: 39730

icu4c/source/common/Makefile.in
icu4c/source/common/char16ptr.cpp [deleted file]
icu4c/source/common/common.vcxproj
icu4c/source/common/common.vcxproj.filters
icu4c/source/common/unicode/char16ptr.h
icu4c/source/common/unicode/unistr.h
icu4c/source/common/unistr.cpp

index 5a82fbf72622ab0c5439d6396ebe5b9c577c6014..10fa8de38ebe642594469d0564e7305fb261cfec 100644 (file)
@@ -95,7 +95,7 @@ bytestrie.o bytestrieiterator.o \
 ucharstrie.o ucharstriebuilder.o ucharstrieiterator.o \
 dictionarydata.o \
 edits.o \
-char16ptr.o appendable.o ustr_cnv.o unistr_cnv.o unistr.o unistr_case.o unistr_props.o \
+appendable.o ustr_cnv.o unistr_cnv.o unistr.o unistr_case.o unistr_props.o \
 utf_impl.o ustring.o ustrcase.o ucasemap.o ucasemap_titlecase_brkiter.o cstring.o ustrfmt.o ustrtrns.o ustr_wcs.o utext.o \
 unistr_case_locale.o ustrcase_locale.o unistr_titlecase_brkiter.o ustr_titlecase_brkiter.o \
 normalizer2impl.o normalizer2.o filterednormalizer2.o normlzr.o unorm.o unormcmp.o loadednormalizer2impl.o \
diff --git a/icu4c/source/common/char16ptr.cpp b/icu4c/source/common/char16ptr.cpp
deleted file mode 100644 (file)
index 5afec2a..0000000
+++ /dev/null
@@ -1,13 +0,0 @@
-// © 2017 and later: Unicode, Inc. and others.
-// License & terms of use: http://www.unicode.org/copyright.html
-
-// char16ptr.cpp
-// created: 2017feb28 Markus W. Scherer
-
-#include "unicode/utypes.h"
-#include "unicode/char16ptr.h"
-#include "uassert.h"
-
-U_NAMESPACE_BEGIN
-
-U_NAMESPACE_END
index 9e760180666c41f2d2f30ee251c096a20106289f..33ef60e2b995315590d78b9e0b66107e05f6a458 100644 (file)
     <ClCompile Include="bytestrie.cpp" />
     <ClCompile Include="bytestriebuilder.cpp" />
     <ClCompile Include="bytestrieiterator.cpp" />
-    <ClCompile Include="char16ptr.cpp" />
     <ClCompile Include="chariter.cpp" />
     <ClCompile Include="charstr.cpp" />
     <ClCompile Include="cstring.cpp" />
index b29fe2fc4f265b3bc496263e10dd1e8d466095c8..0542a8b1384d3438332894dc01e51980c1242487 100644 (file)
     <ClCompile Include="bytestream.cpp">
       <Filter>strings</Filter>
     </ClCompile>
-    <ClCompile Include="char16ptr.cpp">
-      <Filter>strings</Filter>
-    </ClCompile>
     <ClCompile Include="chariter.cpp">
       <Filter>strings</Filter>
     </ClCompile>
index 1d75f694f31eb3f30e823068269fe4c59372af96..780a1502738cf9f05e27696a30f387ce9ef89f27 100644 (file)
@@ -30,19 +30,20 @@ U_NAMESPACE_BEGIN
 #endif
 
 /**
- * char16_t * wrapper with implicit conversion from/to distinct but bit-compatible pointer types.
+ * char16_t * wrapper with implicit conversion from distinct but bit-compatible pointer types.
  * @draft ICU 59
  */
 class U_COMMON_API Char16Ptr final {
 public:
     /**
      * Copies the pointer.
-     * TODO: @param p ...
+     * @param p pointer
      * @draft ICU 59
      */
     inline Char16Ptr(char16_t *p);
     /**
      * Converts the pointer to char16_t *.
+     * @param p pointer to be converted
      * @draft ICU 59
      */
     inline Char16Ptr(uint16_t *p);
@@ -50,12 +51,14 @@ public:
     /**
      * Converts the pointer to char16_t *.
      * (Only defined if U_SIZEOF_WCHAR_T==2.)
+     * @param p pointer to be converted
      * @draft ICU 59
      */
     inline Char16Ptr(wchar_t *p);
 #endif
     /**
      * nullptr constructor.
+     * @param p nullptr
      * @draft ICU 59
      */
     inline Char16Ptr(std::nullptr_t p);
@@ -67,59 +70,16 @@ public:
 
     /**
      * Pointer access.
-     * TODO @return ...
+     * @return the wrapped pointer
      * @draft ICU 59
      */
     inline char16_t *get() const;
     /**
      * char16_t pointer access via type conversion (e.g., static_cast).
+     * @return the wrapped pointer
      * @draft ICU 59
      */
-    operator char16_t *() const { return get(); }
-    // TODO: do we need output conversion and other operator overloads
-    // if we do not change return values to pointer wrappers?
-    /**
-     * uint16_t pointer access via type conversion (e.g., static_cast).
-     * @draft ICU 59
-     */
-    inline operator uint16_t *() const;
-#if U_SIZEOF_WCHAR_T==2 || defined(U_IN_DOXYGEN)
-    /**
-     * wchar_t pointer access via type conversion (e.g., static_cast).
-     * @draft ICU 59
-     */
-    inline operator wchar_t *() const;
-#endif
-    operator void *() const { return get(); }
-
-    char16_t operator[](std::ptrdiff_t offset) const { return get()[offset]; }
-
-    UBool operator==(const Char16Ptr &other) const { return get() == other.get(); }
-    UBool operator!=(const Char16Ptr &other) const { return !operator==(other); }
-    UBool operator==(const char16_t *other) const { return get() == other; }
-    UBool operator!=(const char16_t *other) const { return !operator==(other); }
-    UBool operator==(const uint16_t *other) const { return static_cast<uint16_t *>(*this) == other; }
-    UBool operator!=(const uint16_t *other) const { return !operator==(other); }
-#if U_SIZEOF_WCHAR_T==2 || defined(U_IN_DOXYGEN)
-    UBool operator==(const wchar_t *other) const { return static_cast<wchar_t *>(*this) == other; }
-    UBool operator!=(const wchar_t *other) const { return !operator==(other); }
-#endif
-    UBool operator==(const std::nullptr_t null) const { return get() == null; }
-    UBool operator!=(const std::nullptr_t null) const { return !operator==(null); }
-    /**
-     * Comparison with 0.
-     * @return TRUE if the pointer is nullptr and zero==0
-     * @draft ICU 59
-     */
-    UBool operator==(int zero) const { return get() == nullptr && zero == 0; }
-    /**
-     * Comparison with 0.
-     * @return TRUE if the pointer is not nullptr and zero==0
-     * @draft ICU 59
-     */
-    UBool operator!=(int zero) const { return get() != nullptr && zero == 0; }
-
-    Char16Ptr operator+(std::ptrdiff_t offset) const { return Char16Ptr(get() + offset); }
+    inline operator char16_t *() const { return get(); }
 
 private:
     Char16Ptr() = delete;
@@ -154,17 +114,6 @@ Char16Ptr::~Char16Ptr() {
 
 char16_t *Char16Ptr::get() const { return p; }
 
-Char16Ptr::operator uint16_t *() const {
-    U_ALIASING_BARRIER(p);
-    return reinterpret_cast<uint16_t *>(p);
-}
-#if U_SIZEOF_WCHAR_T==2
-Char16Ptr::operator wchar_t *() const {
-    U_ALIASING_BARRIER(p);
-    return reinterpret_cast<wchar_t *>(p);
-}
-#endif
-
 #else
 
 Char16Ptr::Char16Ptr(char16_t *p) { u.cp = p; }
@@ -177,30 +126,23 @@ Char16Ptr::~Char16Ptr() {}
 
 char16_t *Char16Ptr::get() const { return u.cp; }
 
-Char16Ptr::operator uint16_t *() const {
-    return u.up;
-}
-#if U_SIZEOF_WCHAR_T==2
-Char16Ptr::operator wchar_t *() const {
-    return u.wp;
-}
-#endif
-
 #endif
 
 /**
- * const char16_t * wrapper with implicit conversion from/to distinct but bit-compatible pointer types.
+ * const char16_t * wrapper with implicit conversion from distinct but bit-compatible pointer types.
  * @draft ICU 59
  */
 class U_COMMON_API ConstChar16Ptr final {
 public:
     /**
      * Copies the pointer.
+     * @param p pointer
      * @draft ICU 59
      */
     inline ConstChar16Ptr(const char16_t *p);
     /**
      * Converts the pointer to char16_t *.
+     * @param p pointer to be converted
      * @draft ICU 59
      */
     inline ConstChar16Ptr(const uint16_t *p);
@@ -208,12 +150,14 @@ public:
     /**
      * Converts the pointer to char16_t *.
      * (Only defined if U_SIZEOF_WCHAR_T==2.)
+     * @param p pointer to be converted
      * @draft ICU 59
      */
     inline ConstChar16Ptr(const wchar_t *p);
 #endif
     /**
      * nullptr constructor.
+     * @param p nullptr
      * @draft ICU 59
      */
     inline ConstChar16Ptr(const std::nullptr_t p);
@@ -225,46 +169,16 @@ public:
 
     /**
      * Pointer access.
+     * @return the wrapped pointer
      * @draft ICU 59
      */
     inline const char16_t *get() const;
     /**
      * char16_t pointer access via type conversion (e.g., static_cast).
+     * @return the wrapped pointer
      * @draft ICU 59
      */
-    operator const char16_t *() const { return get(); }
-    /**
-     * uint16_t pointer access via type conversion (e.g., static_cast).
-     * @draft ICU 59
-     */
-    inline operator const uint16_t *() const;
-#if U_SIZEOF_WCHAR_T==2 || defined(U_IN_DOXYGEN)
-    /**
-     * wchar_t pointer access via type conversion (e.g., static_cast).
-     * @draft ICU 59
-     */
-    inline operator const wchar_t *() const;
-#endif
-    operator const void *() const { return get(); }
-
-    char16_t operator[](std::ptrdiff_t offset) const { return get()[offset]; }
-
-    UBool operator==(const ConstChar16Ptr &other) const { return get() == other.get(); }
-    UBool operator!=(const ConstChar16Ptr &other) const { return !operator==(other); }
-    UBool operator==(const char16_t *other) const { return get() == other; }
-    UBool operator!=(const char16_t *other) const { return !operator==(other); }
-    UBool operator==(const uint16_t *other) const { return static_cast<const uint16_t *>(*this) == other; }
-    UBool operator!=(const uint16_t *other) const { return !operator==(other); }
-#if U_SIZEOF_WCHAR_T==2 || defined(U_IN_DOXYGEN)
-    UBool operator==(const wchar_t *other) const { return static_cast<const wchar_t *>(*this) == other; }
-    UBool operator!=(const wchar_t *other) const { return !operator==(other); }
-#endif
-    UBool operator==(const std::nullptr_t null) const { return get() == null; }
-    UBool operator!=(const std::nullptr_t null) const { return !operator==(null); }
-    UBool operator==(int zero) const { return get() == nullptr && zero == 0; }
-    UBool operator!=(int zero) const { return get() != nullptr && zero == 0; }
-
-    ConstChar16Ptr operator+(std::ptrdiff_t offset) { return ConstChar16Ptr(get() + offset); }
+    inline operator const char16_t *() const { return get(); }
 
 private:
     ConstChar16Ptr() = delete;
@@ -299,17 +213,6 @@ ConstChar16Ptr::~ConstChar16Ptr() {
 
 const char16_t *ConstChar16Ptr::get() const { return p; }
 
-ConstChar16Ptr::operator const uint16_t *() const {
-    U_ALIASING_BARRIER(p);
-    return reinterpret_cast<const uint16_t *>(p);
-}
-#if U_SIZEOF_WCHAR_T==2
-ConstChar16Ptr::operator const wchar_t *() const {
-    U_ALIASING_BARRIER(p);
-    return reinterpret_cast<const wchar_t *>(p);
-}
-#endif
-
 #else
 
 ConstChar16Ptr::ConstChar16Ptr(const char16_t *p) { u.cp = p; }
@@ -322,15 +225,6 @@ ConstChar16Ptr::~ConstChar16Ptr() {}
 
 const char16_t *ConstChar16Ptr::get() const { return u.cp; }
 
-ConstChar16Ptr::operator const uint16_t *() const {
-    return u.up;
-}
-#if U_SIZEOF_WCHAR_T==2
-ConstChar16Ptr::operator const wchar_t *() const {
-    return u.wp;
-}
-#endif
-
 #endif
 
 U_NAMESPACE_END
index 3de890666aa1bbc4ed74a2cc8b2b0c5be4d58e9a..9eedd2f52df08e66f4296231e322707676928b93 100644 (file)
@@ -3017,7 +3017,7 @@ public:
    * @draft ICU 59
    */
   UNISTR_FROM_STRING_EXPLICIT UnicodeString(const uint16_t *text) :
-      UnicodeString(ConstChar16Ptr(text).get()) {}
+      UnicodeString(ConstChar16Ptr(text)) {}
 
 #if U_SIZEOF_WCHAR_T==2 || defined(U_IN_DOXYGEN)
   /**
@@ -3032,7 +3032,7 @@ public:
    * @draft ICU 59
    */
   UNISTR_FROM_STRING_EXPLICIT UnicodeString(const wchar_t *text) :
-      UnicodeString(ConstChar16Ptr(text).get()) {}
+      UnicodeString(ConstChar16Ptr(text)) {}
 #endif
 
   /**
@@ -3065,7 +3065,7 @@ public:
    * @draft ICU 59
    */
   UnicodeString(const uint16_t *text, int32_t length) :
-      UnicodeString(ConstChar16Ptr(text).get(), length) {}
+      UnicodeString(ConstChar16Ptr(text), length) {}
 
 #if U_SIZEOF_WCHAR_T==2 || defined(U_IN_DOXYGEN)
   /**
@@ -3077,7 +3077,7 @@ public:
    * @draft ICU 59
    */
   UnicodeString(const wchar_t *text, int32_t length) :
-      UnicodeString(ConstChar16Ptr(text).get(), length) {}
+      UnicodeString(ConstChar16Ptr(text), length) {}
 #endif
 
   /**
@@ -3144,7 +3144,7 @@ public:
    * @draft ICU 59
    */
   UnicodeString(uint16_t *buffer, int32_t buffLength, int32_t buffCapacity) :
-      UnicodeString(Char16Ptr(buffer).get(), buffLength, buffCapacity) {}
+      UnicodeString(Char16Ptr(buffer), buffLength, buffCapacity) {}
 
 #if U_SIZEOF_WCHAR_T==2 || defined(U_IN_DOXYGEN)
   /**
@@ -3157,7 +3157,7 @@ public:
    * @draft ICU 59
    */
   UnicodeString(wchar_t *buffer, int32_t buffLength, int32_t buffCapacity) :
-      UnicodeString(Char16Ptr(buffer).get(), buffLength, buffCapacity) {}
+      UnicodeString(Char16Ptr(buffer), buffLength, buffCapacity) {}
 #endif
 
   /**
index 29ea82df7f1ea05e87431fa19226f98b37f35bb3..416b909917d54482f400a2ecaac2bb94ebe8bea1 100644 (file)
@@ -875,11 +875,10 @@ UnicodeString::doExtract(int32_t start,
 }
 
 int32_t
-UnicodeString::extract(Char16Ptr destPtr, int32_t destCapacity,
+UnicodeString::extract(Char16Ptr dest, int32_t destCapacity,
                        UErrorCode &errorCode) const {
   int32_t len = length();
   if(U_SUCCESS(errorCode)) {
-    UChar *dest = destPtr;
     if(isBogus() || destCapacity<0 || (destCapacity>0 && dest==0)) {
       errorCode=U_ILLEGAL_ARGUMENT_ERROR;
     } else {