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 00040 class U_COMMON_API ParsePosition : public UObject { 00041 public: 00046 ParsePosition() 00047 : UObject() 00048 { this->index = 0; this->errorIndex = -1; } 00049 00055 ParsePosition(int32_t newIndex) 00056 : UObject() 00057 { this->index = newIndex; this->errorIndex = -1; } 00058 00064 ParsePosition(const ParsePosition& copy) 00065 : UObject(copy) 00066 { this->index = copy.index; this->errorIndex = copy.errorIndex; } 00067 00072 ~ParsePosition() {} 00073 00078 ParsePosition& operator=(const ParsePosition& copy); 00079 00085 UBool operator==(const ParsePosition& that) const; 00086 00092 UBool operator!=(const ParsePosition& that) const; 00093 00101 int32_t getIndex(void) const; 00102 00108 void setIndex(int32_t index); 00109 00117 void setErrorIndex(int32_t ei); 00118 00124 int32_t getErrorIndex(void) const; 00125 00131 virtual inline UClassID getDynamicClassID() const { return getStaticClassID(); } 00132 00138 static inline UClassID getStaticClassID() { return (UClassID)&fgClassID; } 00139 00140 private: 00147 int32_t index; 00148 00152 int32_t errorIndex; 00153 00158 static const char fgClassID; 00159 }; 00160 00161 inline ParsePosition& 00162 ParsePosition::operator=(const ParsePosition& copy) 00163 { 00164 index = copy.index; 00165 errorIndex = copy.errorIndex; 00166 return *this; 00167 } 00168 00169 inline UBool 00170 ParsePosition::operator==(const ParsePosition& copy) const 00171 { 00172 if(index != copy.index || errorIndex != copy.errorIndex) 00173 return FALSE; 00174 else 00175 return TRUE; 00176 } 00177 00178 inline UBool 00179 ParsePosition::operator!=(const ParsePosition& copy) const 00180 { 00181 return !operator==(copy); 00182 } 00183 00184 inline int32_t 00185 ParsePosition::getIndex() const 00186 { 00187 return index; 00188 } 00189 00190 inline void 00191 ParsePosition::setIndex(int32_t offset) 00192 { 00193 this->index = offset; 00194 } 00195 00196 inline int32_t 00197 ParsePosition::getErrorIndex() const 00198 { 00199 return errorIndex; 00200 } 00201 00202 inline void 00203 ParsePosition::setErrorIndex(int32_t ei) 00204 { 00205 this->errorIndex = ei; 00206 } 00207 U_NAMESPACE_END 00208 00209 #endif