ICU 77.1  77.1
parsepos.h
Go to the documentation of this file.
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 * Copyright (C) 1997-2005, International Business Machines Corporation and others. All Rights Reserved.
5 *******************************************************************************
6 *
7 * File PARSEPOS.H
8 *
9 * Modification History:
10 *
11 * Date Name Description
12 * 07/09/97 helena Converted from java.
13 * 07/17/98 stephen Added errorIndex support.
14 * 05/11/99 stephen Cleaned up.
15 *******************************************************************************
16 */
17 
18 #ifndef PARSEPOS_H
19 #define PARSEPOS_H
20 
21 #include "unicode/utypes.h"
22 
23 #if U_SHOW_CPLUSPLUS_API
24 
25 #include "unicode/uobject.h"
26 
27 
28 U_NAMESPACE_BEGIN
29 
53 public:
59  : UObject(),
60  index(0),
61  errorIndex(-1)
62  {}
63 
69  ParsePosition(int32_t newIndex)
70  : UObject(),
71  index(newIndex),
72  errorIndex(-1)
73  {}
74 
81  : UObject(copy),
82  index(copy.index),
83  errorIndex(copy.errorIndex)
84  {}
85 
90  virtual ~ParsePosition();
91 
96  inline ParsePosition& operator=(const ParsePosition& copy);
97 
103  inline bool operator==(const ParsePosition& that) const;
104 
110  inline bool operator!=(const ParsePosition& that) const;
111 
124 
132  inline int32_t getIndex() const;
133 
139  inline void setIndex(int32_t index);
140 
148  inline void setErrorIndex(int32_t ei);
149 
155  inline int32_t getErrorIndex() const;
156 
162  static UClassID U_EXPORT2 getStaticClassID();
163 
169  virtual UClassID getDynamicClassID() const override;
170 
171 private:
178  int32_t index;
179 
183  int32_t errorIndex;
184 
185 };
186 
187 inline ParsePosition&
188 ParsePosition::operator=(const ParsePosition& copy)
189 {
190  index = copy.index;
191  errorIndex = copy.errorIndex;
192  return *this;
193 }
194 
195 inline bool
197 {
198  if(index != copy.index || errorIndex != copy.errorIndex)
199  return false;
200  else
201  return true;
202 }
203 
204 inline bool
206 {
207  return !operator==(copy);
208 }
209 
210 inline int32_t
211 ParsePosition::getIndex() const
212 {
213  return index;
214 }
215 
216 inline void
217 ParsePosition::setIndex(int32_t offset)
218 {
219  this->index = offset;
220 }
221 
222 inline int32_t
223 ParsePosition::getErrorIndex() const
224 {
225  return errorIndex;
226 }
227 
228 inline void
229 ParsePosition::setErrorIndex(int32_t ei)
230 {
231  this->errorIndex = ei;
232 }
233 U_NAMESPACE_END
234 
235 #endif /* U_SHOW_CPLUSPLUS_API */
236 
237 #endif
ParsePosition is a simple class used by Format and its subclasses to keep track of the current positi...
Definition: parsepos.h:52