ICU 76.1: common/unicode/parsepos.h Source File

ICU 76.1 76.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
52 class U_COMMON_API ParsePosition : public UObject {
53 public:
58 ParsePosition()
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
80 ParsePosition(const ParsePosition& copy)
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
123 ParsePosition *clone() const;
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
196 ParsePosition::operator==(const ParsePosition& copy) const
197 {
198 if(index != copy.index || errorIndex != copy.errorIndex)
199 return false;
200 else
201 return true;
202 }
203
204 inline bool
205 ParsePosition::operator!=(const ParsePosition& copy) const
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
icu::ParsePosition
ParsePosition is a simple class used by Format and its subclasses to keep track of the current positi...
Definition: parsepos.h:52
icu::ParsePosition::clone
ParsePosition * clone() const
Clone this object.
icu::ParsePosition::getDynamicClassID
virtual UClassID getDynamicClassID() const override
ICU "poor man's RTTI", returns a UClassID for the actual class.
icu::ParsePosition::ParsePosition
ParsePosition(const ParsePosition &copy)
Copy constructor.
Definition: parsepos.h:80
icu::ParsePosition::getStaticClassID
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
icu::ParsePosition::~ParsePosition
virtual ~ParsePosition()
Destructor.
icu::ParsePosition::ParsePosition
ParsePosition()
Default constructor, the index starts with 0 as default.
Definition: parsepos.h:58
icu::ParsePosition::ParsePosition
ParsePosition(int32_t newIndex)
Create a new ParsePosition with the given initial index.
Definition: parsepos.h:69
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
icu::operator==
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
icu::operator!=
bool operator!=(const StringPiece &x, const StringPiece &y)
Global operator != for StringPiece.
Definition: stringpiece.h:346
uobject.h
C++ API: Common ICU base class UObject.
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:96
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
U_COMMON_API
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside.
Definition: utypes.h:315