ICU 72.1 72.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
28U_NAMESPACE_BEGIN
29
53public:
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(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 override;
170
171private:
178 int32_t index;
179
183 int32_t errorIndex;
184
185};
186
187inline ParsePosition&
188ParsePosition::operator=(const ParsePosition& copy)
189{
190 index = copy.index;
191 errorIndex = copy.errorIndex;
192 return *this;
193}
194
195inline bool
197{
198 if(index != copy.index || errorIndex != copy.errorIndex)
199 return false;
200 else
201 return true;
202}
203
204inline bool
206{
207 return !operator==(copy);
208}
209
210inline int32_t
211ParsePosition::getIndex() const
212{
213 return index;
214}
215
216inline void
217ParsePosition::setIndex(int32_t offset)
218{
219 this->index = offset;
220}
221
222inline int32_t
223ParsePosition::getErrorIndex() const
224{
225 return errorIndex;
226}
227
228inline void
229ParsePosition::setErrorIndex(int32_t ei)
230{
231 this->errorIndex = ei;
232}
233U_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
virtual UClassID getDynamicClassID() const override
ICU "poor man's RTTI", returns a UClassID for the actual class.
ParsePosition * clone() const
Clone this object.
ParsePosition(const ParsePosition &copy)
Copy constructor.
Definition: parsepos.h:80
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
virtual ~ParsePosition()
Destructor.
ParsePosition()
Default constructor, the index starts with 0 as default.
Definition: parsepos.h:58
ParsePosition(int32_t newIndex)
Create a new ParsePosition with the given initial index.
Definition: parsepos.h:69
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
bool operator!=(const StringPiece &x, const StringPiece &y)
Global operator != for StringPiece.
Definition: stringpiece.h:335
C++ API: Common ICU base class UObject.
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:96
Basic definitions for ICU, for both C and C++ APIs.
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside.
Definition: utypes.h:300