/** * \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> * classes requires a <code>ParsePosition</code> object as an argument. * * <p> * By design, as you parse through a string with different formats, * you can use the same <code>ParsePosition</code>, since the index parameter * records the current position. * * The ParsePosition class is not suitable for subclassing. * * @version 1.3 10/30/97 * @author Mark Davis, Helena Shih * @see java.text.Format
*/
class U_COMMON_API ParsePosition : public UObject { public: /** * Default constructor, the index starts with 0 as default. * @stable ICU 2.0
*/
ParsePosition()
: UObject(),
index(0),
errorIndex(-1)
{}
/** * Create a new ParsePosition with the given initial index. * @param newIndex the new text offset. * @stable ICU 2.0
*/
ParsePosition(int32_t newIndex)
: UObject(),
index(newIndex),
errorIndex(-1)
{}
/** * Copy constructor * @param copy the object to be copied from. * @stable ICU 2.0
*/
ParsePosition(const ParsePosition& copy)
: UObject(copy),
index(copy.index),
errorIndex(copy.errorIndex)
{}
/** * Equality operator. * @return true if the two parse positions are equal, false otherwise. * @stable ICU 2.0
*/ inlinebooloperator==(const ParsePosition& that) const;
/** * Equality operator. * @return true if the two parse positions are not equal, false otherwise. * @stable ICU 2.0
*/ inlinebooloperator!=(const ParsePosition& that) const;
/** * Clone this object. * Clones can be used concurrently in multiple threads. * If an error occurs, then nullptr 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 * is the index of the character at which parsing will begin; on output, it * is the index of the character following the last character parsed. * @return the current index. * @stable ICU 2.0
*/ inline int32_t getIndex() const;
/** * Set the current parse position. * @param index the new index. * @stable ICU 2.0
*/ inlinevoid setIndex(int32_t index);
/** * Set the index at which a parse error occurred. Formatters * should set this before returning an error code from their * parseObject method. The default value is -1 if this is not * set. * @stable ICU 2.0
*/ inlinevoid 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
*/ inline int32_t getErrorIndex() const;
/** * ICU "poor man's RTTI", returns a UClassID for this class. * * @stable ICU 2.2
*/ static UClassID U_EXPORT2 getStaticClassID();
/** * ICU "poor man's RTTI", returns a UClassID for the actual class. * * @stable ICU 2.2
*/ virtual UClassID getDynamicClassID() const override;
private: /** * Input: the place you start parsing. * <br>Output: position where the parse stopped. * This is designed to be used serially, * with each call setting index up for the next one.
*/
int32_t index;
/** * The index at which a parse error occurred.
*/
int32_t errorIndex;
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.