ICU 65.1  65.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 UBool operator==(const ParsePosition& that) const;
104 
110  inline UBool operator!=(const ParsePosition& that) const;
111 
123  ParsePosition *clone() const;
124 
132  inline int32_t getIndex(void) const;
133 
139  inline void setIndex(int32_t index);
140 
148  inline void setErrorIndex(int32_t ei);
149 
155  inline int32_t getErrorIndex(void) const;
156 
162  static UClassID U_EXPORT2 getStaticClassID();
163 
169  virtual UClassID getDynamicClassID() const;
170 
171 private:
178  int32_t index;
179 
183  int32_t errorIndex;
184 
185 };
186 
187 inline ParsePosition&
189 {
190  index = copy.index;
191  errorIndex = copy.errorIndex;
192  return *this;
193 }
194 
195 inline UBool
197 {
198  if(index != copy.index || errorIndex != copy.errorIndex)
199  return FALSE;
200  else
201  return TRUE;
202 }
203 
204 inline UBool
206 {
207  return !operator==(copy);
208 }
209 
210 inline int32_t
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
224 {
225  return errorIndex;
226 }
227 
228 inline void
230 {
231  this->errorIndex = ei;
232 }
233 U_NAMESPACE_END
234 
235 #endif /* U_SHOW_CPLUSPLUS_API */
236 
237 #endif
void setIndex(int32_t index)
Set the current parse position.
Definition: parsepos.h:217
int32_t getErrorIndex(void) const
Retrieve the index at which an error occurred, or -1 if the error index has not been set...
Definition: parsepos.h:223
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:96
void setErrorIndex(int32_t ei)
Set the index at which a parse error occurred.
Definition: parsepos.h:229
UBool operator!=(const StringPiece &x, const StringPiece &y)
Global operator != for StringPiece.
Definition: stringpiece.h:251
virtual UClassID getDynamicClassID() const
ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.
#define TRUE
The TRUE value of a UBool.
Definition: umachine.h:265
C++ API: Common ICU base class UObject.
ParsePosition & operator=(const ParsePosition &copy)
Assignment operator.
Definition: parsepos.h:188
int32_t getIndex(void) const
Retrieve the current parse position.
Definition: parsepos.h:211
ParsePosition()
Default constructor, the index starts with 0 as default.
Definition: parsepos.h:58
ParsePosition(const ParsePosition &copy)
Copy constructor.
Definition: parsepos.h:80
ParsePosition is a simple class used by Format and its subclasses to keep track of the current positi...
Definition: parsepos.h:52
UBool operator==(const ParsePosition &that) const
Equality operator.
Definition: parsepos.h:196
Basic definitions for ICU, for both C and C++ APIs.
ParsePosition(int32_t newIndex)
Create a new ParsePosition with the given initial index.
Definition: parsepos.h:69
#define FALSE
The FALSE value of a UBool.
Definition: umachine.h:269
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside...
Definition: utypes.h:300
UBool operator!=(const ParsePosition &that) const
Equality operator.
Definition: parsepos.h:205
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
int8_t UBool
The ICU boolean type.
Definition: umachine.h:261