|
||||
Warning, file /include/unicode/parsepos.h was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).
0001 // © 2016 and later: Unicode, Inc. and others. 0002 // License & terms of use: http://www.unicode.org/copyright.html 0003 /* 0004 * Copyright (C) 1997-2005, International Business Machines Corporation and others. All Rights Reserved. 0005 ******************************************************************************* 0006 * 0007 * File PARSEPOS.H 0008 * 0009 * Modification History: 0010 * 0011 * Date Name Description 0012 * 07/09/97 helena Converted from java. 0013 * 07/17/98 stephen Added errorIndex support. 0014 * 05/11/99 stephen Cleaned up. 0015 ******************************************************************************* 0016 */ 0017 0018 #ifndef PARSEPOS_H 0019 #define PARSEPOS_H 0020 0021 #include "unicode/utypes.h" 0022 0023 #if U_SHOW_CPLUSPLUS_API 0024 0025 #include "unicode/uobject.h" 0026 0027 0028 U_NAMESPACE_BEGIN 0029 0030 /** 0031 * \file 0032 * \brief C++ API: Canonical Iterator 0033 */ 0034 /** 0035 * <code>ParsePosition</code> is a simple class used by <code>Format</code> 0036 * and its subclasses to keep track of the current position during parsing. 0037 * The <code>parseObject</code> method in the various <code>Format</code> 0038 * classes requires a <code>ParsePosition</code> object as an argument. 0039 * 0040 * <p> 0041 * By design, as you parse through a string with different formats, 0042 * you can use the same <code>ParsePosition</code>, since the index parameter 0043 * records the current position. 0044 * 0045 * The ParsePosition class is not suitable for subclassing. 0046 * 0047 * @version 1.3 10/30/97 0048 * @author Mark Davis, Helena Shih 0049 * @see java.text.Format 0050 */ 0051 0052 class U_COMMON_API ParsePosition : public UObject { 0053 public: 0054 /** 0055 * Default constructor, the index starts with 0 as default. 0056 * @stable ICU 2.0 0057 */ 0058 ParsePosition() 0059 : UObject(), 0060 index(0), 0061 errorIndex(-1) 0062 {} 0063 0064 /** 0065 * Create a new ParsePosition with the given initial index. 0066 * @param newIndex the new text offset. 0067 * @stable ICU 2.0 0068 */ 0069 ParsePosition(int32_t newIndex) 0070 : UObject(), 0071 index(newIndex), 0072 errorIndex(-1) 0073 {} 0074 0075 /** 0076 * Copy constructor 0077 * @param copy the object to be copied from. 0078 * @stable ICU 2.0 0079 */ 0080 ParsePosition(const ParsePosition& copy) 0081 : UObject(copy), 0082 index(copy.index), 0083 errorIndex(copy.errorIndex) 0084 {} 0085 0086 /** 0087 * Destructor 0088 * @stable ICU 2.0 0089 */ 0090 virtual ~ParsePosition(); 0091 0092 /** 0093 * Assignment operator 0094 * @stable ICU 2.0 0095 */ 0096 inline ParsePosition& operator=(const ParsePosition& copy); 0097 0098 /** 0099 * Equality operator. 0100 * @return true if the two parse positions are equal, false otherwise. 0101 * @stable ICU 2.0 0102 */ 0103 inline bool operator==(const ParsePosition& that) const; 0104 0105 /** 0106 * Equality operator. 0107 * @return true if the two parse positions are not equal, false otherwise. 0108 * @stable ICU 2.0 0109 */ 0110 inline bool operator!=(const ParsePosition& that) const; 0111 0112 /** 0113 * Clone this object. 0114 * Clones can be used concurrently in multiple threads. 0115 * If an error occurs, then nullptr is returned. 0116 * The caller must delete the clone. 0117 * 0118 * @return a clone of this object 0119 * 0120 * @see getDynamicClassID 0121 * @stable ICU 2.8 0122 */ 0123 ParsePosition *clone() const; 0124 0125 /** 0126 * Retrieve the current parse position. On input to a parse method, this 0127 * is the index of the character at which parsing will begin; on output, it 0128 * is the index of the character following the last character parsed. 0129 * @return the current index. 0130 * @stable ICU 2.0 0131 */ 0132 inline int32_t getIndex(void) const; 0133 0134 /** 0135 * Set the current parse position. 0136 * @param index the new index. 0137 * @stable ICU 2.0 0138 */ 0139 inline void setIndex(int32_t index); 0140 0141 /** 0142 * Set the index at which a parse error occurred. Formatters 0143 * should set this before returning an error code from their 0144 * parseObject method. The default value is -1 if this is not 0145 * set. 0146 * @stable ICU 2.0 0147 */ 0148 inline void setErrorIndex(int32_t ei); 0149 0150 /** 0151 * Retrieve the index at which an error occurred, or -1 if the 0152 * error index has not been set. 0153 * @stable ICU 2.0 0154 */ 0155 inline int32_t getErrorIndex(void) const; 0156 0157 /** 0158 * ICU "poor man's RTTI", returns a UClassID for this class. 0159 * 0160 * @stable ICU 2.2 0161 */ 0162 static UClassID U_EXPORT2 getStaticClassID(); 0163 0164 /** 0165 * ICU "poor man's RTTI", returns a UClassID for the actual class. 0166 * 0167 * @stable ICU 2.2 0168 */ 0169 virtual UClassID getDynamicClassID() const override; 0170 0171 private: 0172 /** 0173 * Input: the place you start parsing. 0174 * <br>Output: position where the parse stopped. 0175 * This is designed to be used serially, 0176 * with each call setting index up for the next one. 0177 */ 0178 int32_t index; 0179 0180 /** 0181 * The index at which a parse error occurred. 0182 */ 0183 int32_t errorIndex; 0184 0185 }; 0186 0187 inline ParsePosition& 0188 ParsePosition::operator=(const ParsePosition& copy) 0189 { 0190 index = copy.index; 0191 errorIndex = copy.errorIndex; 0192 return *this; 0193 } 0194 0195 inline bool 0196 ParsePosition::operator==(const ParsePosition& copy) const 0197 { 0198 if(index != copy.index || errorIndex != copy.errorIndex) 0199 return false; 0200 else 0201 return true; 0202 } 0203 0204 inline bool 0205 ParsePosition::operator!=(const ParsePosition& copy) const 0206 { 0207 return !operator==(copy); 0208 } 0209 0210 inline int32_t 0211 ParsePosition::getIndex() const 0212 { 0213 return index; 0214 } 0215 0216 inline void 0217 ParsePosition::setIndex(int32_t offset) 0218 { 0219 this->index = offset; 0220 } 0221 0222 inline int32_t 0223 ParsePosition::getErrorIndex() const 0224 { 0225 return errorIndex; 0226 } 0227 0228 inline void 0229 ParsePosition::setErrorIndex(int32_t ei) 0230 { 0231 this->errorIndex = ei; 0232 } 0233 U_NAMESPACE_END 0234 0235 #endif /* U_SHOW_CPLUSPLUS_API */ 0236 0237 #endif
[ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |