]> git.saurik.com Git - apple/icu.git/blobdiff - icuSources/common/unicode/parsepos.h
ICU-64232.0.1.tar.gz
[apple/icu.git] / icuSources / common / unicode / parsepos.h
index e741abab9bc3429398b1583c6b9af6c5cac4e908..e3d7d778ac1382b70c07a483438e76d1f9f4c03e 100644 (file)
@@ -1,5 +1,7 @@
+// © 2016 and later: Unicode, Inc. and others.
+// License & terms of use: http://www.unicode.org/copyright.html
 /*
-* Copyright (C) {1997-2003}, International Business Machines Corporation and others. All Rights Reserved.
+* Copyright (C) 1997-2005, International Business Machines Corporation and others. All Rights Reserved.
 *******************************************************************************
 *
 * File PARSEPOS.H
 #include "unicode/utypes.h"
 #include "unicode/uobject.h"
 
+#if U_SHOW_CPLUSPLUS_API
 U_NAMESPACE_BEGIN
 
 /**
+ * \file
+ * \brief C++ API: Canonical Iterator
+ */
+/** 
  * <code>ParsePosition</code> is a simple class used by <code>Format</code>
  * and its subclasses to keep track of the current position during parsing.
  * The <code>parseObject</code> method in the various <code>Format</code>
@@ -46,8 +54,10 @@ public:
      * @stable ICU 2.0
      */
     ParsePosition()
-        : UObject()
-      { this->index = 0; this->errorIndex = -1; }
+        : UObject(),
+        index(0),
+        errorIndex(-1)
+      {}
 
     /**
      * Create a new ParsePosition with the given initial index.
@@ -55,8 +65,10 @@ public:
      * @stable ICU 2.0
      */
     ParsePosition(int32_t newIndex)
-        : UObject()
-      {    this->index = newIndex; this->errorIndex = -1; }
+        : UObject(),
+        index(newIndex),
+        errorIndex(-1)
+      {}
 
     /**
      * Copy constructor
@@ -64,34 +76,49 @@ public:
      * @stable ICU 2.0
      */
     ParsePosition(const ParsePosition& copy)
-        : UObject(copy)
-      {    this->index = copy.index; this->errorIndex = copy.errorIndex; }
+        : UObject(copy),
+        index(copy.index),
+        errorIndex(copy.errorIndex)
+      {}
 
     /**
      * Destructor
      * @stable ICU 2.0
      */
-    ~ParsePosition() {}
+    virtual ~ParsePosition();
 
     /**
      * Assignment operator
      * @stable ICU 2.0
      */
-    ParsePosition&      operator=(const ParsePosition& copy);
+    inline ParsePosition&      operator=(const ParsePosition& copy);
 
     /**
      * Equality operator.
      * @return TRUE if the two parse positions are equal, FALSE otherwise.
      * @stable ICU 2.0
      */
-    UBool              operator==(const ParsePosition& that) const;
+    inline UBool              operator==(const ParsePosition& that) const;
 
     /**
      * Equality operator.
      * @return TRUE if the two parse positions are not equal, FALSE otherwise.
      * @stable ICU 2.0
      */
-    UBool              operator!=(const ParsePosition& that) const;
+    inline UBool              operator!=(const ParsePosition& that) const;
+
+    /**
+     * Clone this object.
+     * Clones can be used concurrently in multiple threads.
+     * If an error occurs, then NULL is returned.
+     * The caller must delete the clone.
+     *
+     * @return a clone of this object
+     *
+     * @see getDynamicClassID
+     * @stable ICU 2.8
+     */
+    ParsePosition *clone() const;
 
     /**
      * Retrieve the current parse position.  On input to a parse method, this
@@ -100,14 +127,14 @@ public:
      * @return the current index.
      * @stable ICU 2.0
      */
-    int32_t getIndex(void) const;
+    inline int32_t getIndex(void) const;
 
     /**
      * Set the current parse position.
      * @param index the new index.
      * @stable ICU 2.0
      */
-    void setIndex(int32_t index);
+    inline void setIndex(int32_t index);
 
     /**
      * Set the index at which a parse error occurred.  Formatters
@@ -116,28 +143,28 @@ public:
      * set.
      * @stable ICU 2.0
      */
-    void setErrorIndex(int32_t ei);
+    inline void setErrorIndex(int32_t ei);
 
     /**
      * Retrieve the index at which an error occurred, or -1 if the
      * error index has not been set.
      * @stable ICU 2.0
      */
-    int32_t getErrorIndex(void) const;
+    inline int32_t getErrorIndex(void) const;
 
     /**
-     * ICU "poor man's RTTI", returns a UClassID for the actual class.
+     * ICU "poor man's RTTI", returns a UClassID for this class.
      *
-     * @draft ICU 2.2
+     * @stable ICU 2.2
      */
-    virtual inline UClassID getDynamicClassID() const;
+    static UClassID U_EXPORT2 getStaticClassID();
 
     /**
-     * ICU "poor man's RTTI", returns a UClassID for this class.
+     * ICU "poor man's RTTI", returns a UClassID for the actual class.
      *
-     * @draft ICU 2.2
+     * @stable ICU 2.2
      */
-    static inline UClassID getStaticClassID();
+    virtual UClassID getDynamicClassID() const;
 
 private:
     /**
@@ -153,21 +180,8 @@ private:
      */
     int32_t errorIndex;
 
-    /**
-     * The address of this static class variable serves as this class's ID
-     * for ICU "poor man's RTTI".
-     */
-    static const char fgClassID;
 };
 
-inline UClassID
-ParsePosition::getStaticClassID()
-{ return (UClassID)&fgClassID; }
-
-inline UClassID
-ParsePosition::getDynamicClassID() const
-{ return ParsePosition::getStaticClassID(); }
-
 inline ParsePosition&
 ParsePosition::operator=(const ParsePosition& copy)
 {
@@ -215,5 +229,6 @@ ParsePosition::setErrorIndex(int32_t ei)
   this->errorIndex = ei;
 }
 U_NAMESPACE_END
+#endif // U_SHOW_CPLUSPLUS_API
 
 #endif