]> granicus.if.org Git - icu/commitdiff
ICU-10347 add U_FINAL and U_OVERRIDE for C++11 "final" and "override".
authorSteven R. Loomis <srl@icu-project.org>
Sat, 16 Aug 2014 01:30:43 +0000 (01:30 +0000)
committerSteven R. Loomis <srl@icu-project.org>
Sat, 16 Aug 2014 01:30:43 +0000 (01:30 +0000)
Added them to several "not for subclassing" classes.
Some exceptions:
* Commented out U_FINAL where there's an internal override needed.
* For tests, added "#define U_FINAL" at the top to disable this.
#defined to null for Doxygen.

X-SVN-Rev: 36177

14 files changed:
icu4c/source/Doxyfile.in
icu4c/source/common/unicode/caniter.h
icu4c/source/common/unicode/rbbi.h
icu4c/source/common/unicode/umachine.h
icu4c/source/common/unicode/uniset.h
icu4c/source/common/unicode/usetiter.h
icu4c/source/i18n/unicode/coleitr.h
icu4c/source/i18n/unicode/dtfmtsym.h
icu4c/source/i18n/unicode/dtitvinf.h
icu4c/source/i18n/unicode/regex.h
icu4c/source/i18n/unicode/stsearch.h
icu4c/source/i18n/unicode/tblcoll.h
icu4c/source/test/intltest/regcoll.cpp
icu4c/source/test/intltest/transrt.cpp

index 4683b6b7e9014ace4ed7be5bdf840eff8d9b3434..90edbb18f2ec3e5e84b1ac6168cdefed24451f15 100644 (file)
@@ -1,7 +1,7 @@
 # Doxyfile 1.3.7
 #  ********************************************************************
 #  * COPYRIGHT:
-#  * Copyright (c) 2004-2012, International Business Machines Corporation
+#  * Copyright (c) 2004-2014, International Business Machines Corporation
 #  * and others. All Rights Reserved.
 #  ********************************************************************
 
@@ -192,7 +192,7 @@ EXPAND_ONLY_PREDEF     = YES
 SEARCH_INCLUDES        = YES
 INCLUDE_PATH           = 
 INCLUDE_FILE_PATTERNS  = 
-PREDEFINED             = U_EXPORT2= U_STABLE= U_DRAFT= U_INTERNAL= U_SYSTEM= U_DEPRECATED= U_OBSOLETE= U_CALLCONV= U_CDECL_BEGIN= U_CDECL_END=  U_NO_THROW=\ "U_NAMESPACE_BEGIN=namespace icu{" "U_NAMESPACE_END=}" U_HAVE_STD_STRING=1 U_SHOW_CPLUSPLUS_API=1 U_DEFINE_LOCAL_OPEN_POINTER()= U_IN_DOXYGEN=1 
+PREDEFINED             = U_EXPORT2= U_STABLE= U_DRAFT= U_INTERNAL= U_SYSTEM= U_DEPRECATED= U_OBSOLETE= U_CALLCONV= U_CDECL_BEGIN= U_CDECL_END=  U_NO_THROW=\ "U_NAMESPACE_BEGIN=namespace icu{" "U_NAMESPACE_END=}" U_HAVE_STD_STRING=1 U_SHOW_CPLUSPLUS_API=1 U_DEFINE_LOCAL_OPEN_POINTER()= U_IN_DOXYGEN=1 U_OVERRIDE= U_FINAL=
 EXPAND_AS_DEFINED      = 
 SKIP_FUNCTION_MACROS   = YES
 #---------------------------------------------------------------------------
index 23246c5a0f2d27401efb1aa89b7322b81fbe021a..3bd79f768e0b0577b0f23bd9d40bb3a4a3150222 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *******************************************************************************
- * Copyright (C) 1996-2011, International Business Machines Corporation and
+ * Copyright (C) 1996-2014, International Business Machines Corporation and
  * others. All Rights Reserved.
  *******************************************************************************
  */
@@ -69,7 +69,7 @@ Results for: {LATIN CAPITAL LETTER A WITH RING ABOVE}{LATIN SMALL LETTER D}{COMB
  * @author C++ port by V. Weinstein
  * @stable ICU 2.4
  */
-class U_COMMON_API CanonicalIterator : public UObject {
+class U_COMMON_API CanonicalIterator U_FINAL : public UObject {
 public:
     /**
      * Construct a CanonicalIterator object
index aa6cf47ba42f315adac3aecb45ecd7c5f5ce976f..844420dd3a87320c0519113bff37fbe5eff7f003 100644 (file)
@@ -1,6 +1,6 @@
 /*
 ***************************************************************************
-*   Copyright (C) 1999-2013 International Business Machines Corporation   *
+*   Copyright (C) 1999-2014 International Business Machines Corporation   *
 *   and others. All rights reserved.                                      *
 ***************************************************************************
 
@@ -62,7 +62,7 @@ struct RBBIStateTable;
  *    not part of the ICU API, and may not remain stable.</p>
  *
  */
-class U_COMMON_API RuleBasedBreakIterator : public BreakIterator {
+class U_COMMON_API RuleBasedBreakIterator /*U_FINAL*/ : public BreakIterator {
 
 protected:
     /**
index d1102f4936527c92b13bcaf84c8aedca6e7ff757..dd37108bb346bcf446044d2e5025d75e5fbab29d 100644 (file)
@@ -1,7 +1,7 @@
 /*
 ******************************************************************************
 *
-*   Copyright (C) 1999-2012, International Business Machines
+*   Copyright (C) 1999-2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *
 ******************************************************************************
@@ -13,7 +13,7 @@
 *   created on: 1999sep13
 *   created by: Markus W. Scherer
 *
-*   This file defines basic types and constants for utf.h to be
+*   This file defines basic types and constants for ICU to be
 *   platform-independent. umachine.h and utf.h are included into
 *   utypes.h to provide all the general definitions for ICU.
 *   All of these definitions used to be in utypes.h before
 /** This is used to declare a function as an internal ICU C API  */
 #define U_INTERNAL U_CAPI
 
+/**
+ * \def U_OVERRIDE
+ * Defined to the C++11 "override" keyword if available.
+ * Denotes a class or member which is an override of the base class.
+ * May result in an error if it applied to something not an override.
+ * (NOTE: '#define U_OVERRIDE' at the top of a compilation unit will
+ *  disable this keyword's use.)
+ * @internal
+ */
+
+/**
+ * \def U_FINAL
+ * Defined to the C++11 "final" keyword if available.
+ * Denotes a class or member which may not be overridden in subclasses.
+ * May result in an error if subclasses attempt to override.
+ * (NOTE: '#define U_FINAL' at the top of a compilation unit will
+ *  disable this keyword's use.)
+ * @internal
+ */
+
+#if defined(__cplusplus) && __cplusplus>=201103L
+/* C++11 */
+#ifndef U_OVERRIDE
+#define U_OVERRIDE override
+#endif
+#ifndef U_FINAL
+#define U_FINAL final
+#endif
+#else
+/* not C++11 - define to nothing */
+#ifndef U_OVERRIDE
+#define U_OVERRIDE
+#endif
+#ifndef U_FINAL
+#define U_FINAL
+#endif
+#endif
+
 /*==========================================================================*/
 /* limits for int32_t etc., like in POSIX inttypes.h                        */
 /*==========================================================================*/
index fa7cc7ca1c2cdc884884bc2c02cdacae475f7fe8..237ebf766c365cdb9f0ec052aebb43fbd462d436 100644 (file)
@@ -1,6 +1,6 @@
 /*
 ***************************************************************************
-* Copyright (C) 1999-2013, International Business Machines Corporation
+* Copyright (C) 1999-2014, International Business Machines Corporation
 * and others. All Rights Reserved.
 ***************************************************************************
 *   Date        Name        Description
@@ -273,7 +273,7 @@ class RuleCharacterIterator;
  * @author Alan Liu
  * @stable ICU 2.0
  */
-class U_COMMON_API UnicodeSet : public UnicodeFilter {
+class U_COMMON_API UnicodeSet U_FINAL : public UnicodeFilter {
 
     int32_t len; // length of list used; 0 <= len <= capacity
     int32_t capacity; // capacity of list
index 43374b2dae514bc3e58aca82d993bc10bef864b4..21c9babd0cf76d8a6d9b19bdd9cec3aee539813d 100644 (file)
@@ -1,6 +1,6 @@
 /*
 **********************************************************************
-* Copyright (c) 2002-2008, International Business Machines
+* Copyright (c) 2002-2014, International Business Machines
 * Corporation and others.  All Rights Reserved.
 **********************************************************************
 */
@@ -58,7 +58,7 @@ class UnicodeString;
  * @author M. Davis
  * @stable ICU 2.4
  */
-class U_COMMON_API UnicodeSetIterator : public UObject {
+class U_COMMON_API UnicodeSetIterator U_FINAL : public UObject {
 
  protected:
 
index d4beb3205676290e11449ab4428e054be061e864..8c5d0e94f58d4328f21dd331015a69c30dcf9406 100644 (file)
@@ -113,7 +113,7 @@ class UVector32;
 * @see     RuleBasedCollator
 * @version 1.8 Jan 16 2001
 */
-class U_I18N_API CollationElementIterator : public UObject {
+class U_I18N_API CollationElementIterator U_FINAL : public UObject {
 public: 
 
     // CollationElementIterator public data member ------------------------------
index 17fa705b6b213bfa0e7143ee12b0337d04f0108a..852b71daef2934c9d8e6ab39c0d4d2f41086e228 100644 (file)
@@ -76,7 +76,7 @@ class Hashtable;
  * locale at least contains any resources that are to be particularized for the
  * calendar type.
  */
-class U_I18N_API DateFormatSymbols : public UObject {
+class U_I18N_API DateFormatSymbols U_FINAL : public UObject  {
 public:
     /**
      * Construct a DateFormatSymbols object by loading format data from
index d39207bb5b2d685b662d46b2106afce1ce04fa76..9f6674e70d192a3acde4a605b9b019b671dfe7eb 100644 (file)
@@ -1,6 +1,6 @@
 /*
  *******************************************************************************
- * Copyright (C) 2008-2011,2013, International Business Machines Corporation and
+ * Copyright (C) 2008-2014, International Business Machines Corporation and
  * others. All Rights Reserved.
  *******************************************************************************
  *
@@ -148,7 +148,7 @@ U_NAMESPACE_BEGIN
  * @stable ICU 4.0
 **/
 
-class U_I18N_API DateIntervalInfo : public UObject {
+class U_I18N_API DateIntervalInfo U_FINAL : public UObject {
 public:
 #ifndef U_HIDE_INTERNAL_API
     /**
index b2ef4ce33d9b83b18ef2baaa69ac495852e0cf7a..7b85d7040f2a92711f1092381546b2d777046274 100644 (file)
@@ -1,6 +1,6 @@
 /*
 **********************************************************************
-*   Copyright (C) 2002-2013, International Business Machines
+*   Copyright (C) 2002-2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 **********************************************************************
 *   file name:  regex.h
@@ -80,7 +80,7 @@ class  UVector64;
   *
   * @stable ICU 2.4
   */
-class U_I18N_API RegexPattern: public UObject {
+class U_I18N_API RegexPattern U_FINAL : public UObject {
 public:
 
     /**
@@ -622,7 +622,7 @@ private:
  *
  * @stable ICU 2.4
  */
-class U_I18N_API RegexMatcher: public UObject {
+class U_I18N_API RegexMatcher U_FINAL : public UObject {
 public:
 
     /**
index c9c910b14bdd3ba218fc22bc551c23f8309e383a..d38cb23f2157e6945e66b10f2b844200e3e16c13 100644 (file)
@@ -129,7 +129,7 @@ U_NAMESPACE_BEGIN
  * @since ICU 2.0
  */
 
-class U_I18N_API StringSearch : public SearchIterator
+class U_I18N_API StringSearch U_FINAL : public SearchIterator
 {
 public:
 
index f392ac0e9947485ddaa3da70dbe1168e187546fb..4025b80b47c41faf2c65e55043ea71d5ca8a23ea 100644 (file)
@@ -107,7 +107,7 @@ class UVector64;
  * Note, RuleBasedCollator is not to be subclassed.
  * @see        Collator
  */
-class U_I18N_API RuleBasedCollator : public Collator {
+class U_I18N_API RuleBasedCollator U_FINAL : public Collator {
 public:
     /**
      * RuleBasedCollator constructor. This takes the table rules and builds a
index 0cc127e704a81ee38a0d16906e2f912e0f7a6777..f3b583bd839f74213f588628b005469cf959902e 100644 (file)
@@ -4,6 +4,10 @@
  * others. All Rights Reserved.
  ********************************************************************/
 
+// My4146160Collator overrides RBC. Disable U_FINAL for this test.
+#define U_FINAL
+#define U_OVERRIDE
+
 #include "unicode/utypes.h"
 
 #if !UCONFIG_NO_COLLATION
index 30ebbe9e052ff1d41db6b28e18e322971fd0b3c5..3f1d57b0310da6cc532c4e5dc9e02ae7e17cb6d7 100644 (file)
@@ -1,6 +1,6 @@
 /*
 **********************************************************************
-*   Copyright (C) 2000-2013, International Business Machines
+*   Copyright (C) 2000-2014, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 **********************************************************************
 *   Date        Name        Description
@@ -8,6 +8,10 @@
 **********************************************************************
 */
 
+// AbbreviatedUnicodeSetIterator overrides UnicodeSetIterator.
+#define U_FINAL
+#define U_OVERRIDE
+
 #include "unicode/utypes.h"
 
 #if !UCONFIG_NO_TRANSLITERATION