ICU 64.2  64.2
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 #include "unicode/uobject.h"
23 
24 
26 
50 public:
56  : UObject(),
57  index(0),
58  errorIndex(-1)
59  {}
60 
66  ParsePosition(int32_t newIndex)
67  : UObject(),
68  index(newIndex),
69  errorIndex(-1)
70  {}
71 
78  : UObject(copy),
79  index(copy.index),
80  errorIndex(copy.errorIndex)
81  {}
82 
87  virtual ~ParsePosition();
88 
93  inline ParsePosition& operator=(const ParsePosition& copy);
94 
100  inline UBool operator==(const ParsePosition& that) const;
101 
107  inline UBool operator!=(const ParsePosition& that) const;
108 
120  ParsePosition *clone() const;
121 
129  inline int32_t getIndex(void) const;
130 
136  inline void setIndex(int32_t index);
137 
145  inline void setErrorIndex(int32_t ei);
146 
152  inline int32_t getErrorIndex(void) const;
153 
159  static UClassID U_EXPORT2 getStaticClassID();
160 
166  virtual UClassID getDynamicClassID() const;
167 
168 private:
175  int32_t index;
176 
180  int32_t errorIndex;
181 
182 };
183 
184 inline ParsePosition&
186 {
187  index = copy.index;
188  errorIndex = copy.errorIndex;
189  return *this;
190 }
191 
192 inline UBool
194 {
195  if(index != copy.index || errorIndex != copy.errorIndex)
196  return FALSE;
197  else
198  return TRUE;
199 }
200 
201 inline UBool
203 {
204  return !operator==(copy);
205 }
206 
207 inline int32_t
209 {
210  return index;
211 }
212 
213 inline void
214 ParsePosition::setIndex(int32_t offset)
215 {
216  this->index = offset;
217 }
218 
219 inline int32_t
221 {
222  return errorIndex;
223 }
224 
225 inline void
227 {
228  this->errorIndex = ei;
229 }
231 
232 #endif
void setIndex(int32_t index)
Set the current parse position.
Definition: parsepos.h:214
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:220
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:93
void setErrorIndex(int32_t ei)
Set the index at which a parse error occurred.
Definition: parsepos.h:226
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:137
UBool operator!=(const StringPiece &x, const StringPiece &y)
Global operator != for StringPiece.
Definition: stringpiece.h:218
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:229
C++ API: Common ICU base class UObject.
ParsePosition & operator=(const ParsePosition &copy)
Assignment operator.
Definition: parsepos.h:185
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:138
int32_t getIndex(void) const
Retrieve the current parse position.
Definition: parsepos.h:208
ParsePosition()
Default constructor, the index starts with 0 as default.
Definition: parsepos.h:55
ParsePosition(const ParsePosition &copy)
Copy constructor.
Definition: parsepos.h:77
ParsePosition is a simple class used by Format and its subclasses to keep track of the current positi...
Definition: parsepos.h:49
UBool operator==(const ParsePosition &that) const
Equality operator.
Definition: parsepos.h:193
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:66
#define FALSE
The FALSE value of a UBool.
Definition: umachine.h:233
#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:202
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
int8_t UBool
The ICU boolean type.
Definition: umachine.h:225