00001 /* 00002 * Copyright (C) {1997-1999}, International Business Machines Corporation and others. All Rights Reserved. 00003 ******************************************************************************* 00004 * 00005 * File PARSEPOS.H 00006 * 00007 * Modification History: 00008 * 00009 * Date Name Description 00010 * 07/09/97 helena Converted from java. 00011 * 07/17/98 stephen Added errorIndex support. 00012 * 05/11/99 stephen Cleaned up. 00013 ******************************************************************************* 00014 */ 00015 00016 #ifndef PARSEPOS_H 00017 #define PARSEPOS_H 00018 00019 #include "unicode/utypes.h" 00020 #include "unicode/uobject.h" 00021 00022 U_NAMESPACE_BEGIN 00023 00042 class U_COMMON_API ParsePosition : public UObject { 00043 public: 00048 ParsePosition() 00049 : UObject() 00050 { this->index = 0; this->errorIndex = -1; } 00051 00057 ParsePosition(int32_t newIndex) 00058 : UObject() 00059 { this->index = newIndex; this->errorIndex = -1; } 00060 00066 ParsePosition(const ParsePosition& copy) 00067 : UObject(copy) 00068 { this->index = copy.index; this->errorIndex = copy.errorIndex; } 00069 00074 ~ParsePosition() {} 00075 00080 ParsePosition& operator=(const ParsePosition& copy); 00081 00087 UBool operator==(const ParsePosition& that) const; 00088 00094 UBool operator!=(const ParsePosition& that) const; 00095 00103 int32_t getIndex(void) const; 00104 00110 void setIndex(int32_t index); 00111 00119 void setErrorIndex(int32_t ei); 00120 00126 int32_t getErrorIndex(void) const; 00127 00133 virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } 00134 00140 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } 00141 00142 private: 00149 int32_t index; 00150 00154 int32_t errorIndex; 00155 00160 static const char fgClassID; 00161 }; 00162 00163 inline ParsePosition& 00164 ParsePosition::operator=(const ParsePosition& copy) 00165 { 00166 index = copy.index; 00167 errorIndex = copy.errorIndex; 00168 return *this; 00169 } 00170 00171 inline UBool 00172 ParsePosition::operator==(const ParsePosition& copy) const 00173 { 00174 if(index != copy.index || errorIndex != copy.errorIndex) 00175 return FALSE; 00176 else 00177 return TRUE; 00178 } 00179 00180 inline UBool 00181 ParsePosition::operator!=(const ParsePosition& copy) const 00182 { 00183 return !operator==(copy); 00184 } 00185 00186 inline int32_t 00187 ParsePosition::getIndex() const 00188 { 00189 return index; 00190 } 00191 00192 inline void 00193 ParsePosition::setIndex(int32_t offset) 00194 { 00195 this->index = offset; 00196 } 00197 00198 inline int32_t 00199 ParsePosition::getErrorIndex() const 00200 { 00201 return errorIndex; 00202 } 00203 00204 inline void 00205 ParsePosition::setErrorIndex(int32_t ei) 00206 { 00207 this->errorIndex = ei; 00208 } 00209 U_NAMESPACE_END 00210 00211 #endif