]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/common/unicode/messagepattern.h
ICU-66108.tar.gz
[apple/icu.git] / icuSources / common / unicode / messagepattern.h
index 84af565fb59e58311b8dde5006f97eeeb7844790..04f00a8757d7832179098246317ac907738d122a 100644 (file)
@@ -1,10 +1,12 @@
+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
 /*
 *******************************************************************************
-*   Copyright (C) 2011-2012, International Business Machines
+*   Copyright (C) 2011-2013, International Business Machines
 *   Corporation and others.  All Rights Reserved.
 *******************************************************************************
 *   file name:  messagepattern.h
-*   encoding:   US-ASCII
+*   encoding:   UTF-8
 *   tab size:   8 (not used)
 *   indentation:4
 *
@@ -22,6 +24,8 @@
 
 #include "unicode/utypes.h"
 
+#if U_SHOW_CPLUSPLUS_API
+
 #if !UCONFIG_NO_FORMATTING
 
 #include "unicode/parseerr.h"
@@ -233,7 +237,7 @@ enum UMessagePatternArgType {
      */
     UMSGPAT_ARG_TYPE_CHOICE,
     /**
-     * The argument is a PluralFormat with an optional ARG_INT or ARG_DOUBLE offset
+     * The argument is a cardinal-number PluralFormat with an optional ARG_INT or ARG_DOUBLE offset
      * (e.g., offset:1)
      * and one or more (ARG_SELECTOR [explicit-value] message) tuples.
      * If the selector has an explicit value (e.g., =2), then
@@ -246,13 +250,28 @@ enum UMessagePatternArgType {
      * The argument is a SelectFormat with one or more (ARG_SELECTOR, message) pairs.
      * @stable ICU 4.8
      */
-    UMSGPAT_ARG_TYPE_SELECT
+    UMSGPAT_ARG_TYPE_SELECT,
+    /**
+     * The argument is an ordinal-number PluralFormat
+     * with the same style parts sequence and semantics as UMSGPAT_ARG_TYPE_PLURAL.
+     * @stable ICU 50
+     */
+    UMSGPAT_ARG_TYPE_SELECTORDINAL
 };
 /**
  * @stable ICU 4.8
  */
 typedef enum UMessagePatternArgType UMessagePatternArgType;
 
+/**
+ * \def UMSGPAT_ARG_TYPE_HAS_PLURAL_STYLE
+ * Returns TRUE if the argument type has a plural style part sequence and semantics,
+ * for example UMSGPAT_ARG_TYPE_PLURAL and UMSGPAT_ARG_TYPE_SELECTORDINAL.
+ * @stable ICU 50
+ */
+#define UMSGPAT_ARG_TYPE_HAS_PLURAL_STYLE(argType) \
+    ((argType)==UMSGPAT_ARG_TYPE_PLURAL || (argType)==UMSGPAT_ARG_TYPE_SELECTORDINAL)
+
 enum {
     /**
      * Return value from MessagePattern.validateArgumentName() for when
@@ -754,8 +773,8 @@ public:
          * @stable ICU 4.8
          */
         UMessagePatternArgType getArgType() const {
-            UMessagePatternPartType type=getType();
-            if(type==UMSGPAT_PART_TYPE_ARG_START || type==UMSGPAT_PART_TYPE_ARG_LIMIT) {
+            UMessagePatternPartType msgType=getType();
+            if(msgType ==UMSGPAT_PART_TYPE_ARG_START || msgType ==UMSGPAT_PART_TYPE_ARG_LIMIT) {
                 return (UMessagePatternArgType)value;
             } else {
                 return UMSGPAT_ARG_TYPE_NONE;
@@ -878,6 +897,8 @@ private:
 
     UBool isSelect(int32_t index);
 
+    UBool isOrdinal(int32_t index);
+
     /**
      * @return TRUE if we are inside a MessageFormat (sub-)pattern,
      *         as opposed to inside a top-level choice/plural/select pattern.
@@ -901,9 +922,6 @@ private:
 
     void setParseError(UParseError *parseError, int32_t index);
 
-    // No ICU "poor man's RTTI" for this class nor its subclasses.
-    virtual UClassID getDynamicClassID() const;
-
     UBool init(UErrorCode &errorCode);
     UBool copyStorage(const MessagePattern &other, UErrorCode &errorCode);
 
@@ -926,4 +944,6 @@ U_NAMESPACE_END
 
 #endif  // !UCONFIG_NO_FORMATTING
 
+#endif /* U_SHOW_CPLUSPLUS_API */
+
 #endif  // __MESSAGEPATTERN_H__