]>
Commit | Line | Data |
---|---|---|
f3c0d7a5 A |
1 | // © 2016 and later: Unicode, Inc. and others. |
2 | // License & terms of use: http://www.unicode.org/copyright.html | |
729e4ab9 A |
3 | /* |
4 | ******************************************************************************* | |
2ca993e8 | 5 | * Copyright (C) 2009-2015, International Business Machines Corporation and * |
729e4ab9 A |
6 | * others. All Rights Reserved. * |
7 | ******************************************************************************* | |
8 | */ | |
9 | ||
10 | #ifndef FPHDLIMP_H | |
11 | #define FPHDLIMP_H | |
12 | ||
13 | #if !UCONFIG_NO_FORMATTING | |
14 | ||
15 | #include "unicode/utypes.h" | |
16 | #include "unicode/fieldpos.h" | |
17 | #include "unicode/fpositer.h" | |
18 | ||
19 | U_NAMESPACE_BEGIN | |
20 | ||
21 | // utility FieldPositionHandler | |
22 | // base class, null implementation | |
23 | ||
2ca993e8 | 24 | class U_I18N_API FieldPositionHandler: public UMemory { |
0f5d89e8 A |
25 | protected: |
26 | int32_t fShift = 0; | |
27 | ||
729e4ab9 A |
28 | public: |
29 | virtual ~FieldPositionHandler(); | |
0f5d89e8 A |
30 | virtual void addAttribute(int32_t id, int32_t start, int32_t limit) = 0; |
31 | virtual void shiftLast(int32_t delta) = 0; | |
32 | virtual UBool isRecording(void) const = 0; | |
33 | ||
34 | void setShift(int32_t delta); | |
729e4ab9 A |
35 | }; |
36 | ||
37 | ||
38 | // utility subclass FieldPositionOnlyHandler | |
39 | ||
40 | class FieldPositionOnlyHandler : public FieldPositionHandler { | |
41 | FieldPosition& pos; | |
42 | ||
43 | public: | |
44 | FieldPositionOnlyHandler(FieldPosition& pos); | |
45 | virtual ~FieldPositionOnlyHandler(); | |
46 | ||
0f5d89e8 A |
47 | void addAttribute(int32_t id, int32_t start, int32_t limit) U_OVERRIDE; |
48 | void shiftLast(int32_t delta) U_OVERRIDE; | |
49 | UBool isRecording(void) const U_OVERRIDE; | |
729e4ab9 A |
50 | }; |
51 | ||
52 | ||
53 | // utility subclass FieldPositionIteratorHandler | |
54 | ||
55 | class FieldPositionIteratorHandler : public FieldPositionHandler { | |
56 | FieldPositionIterator* iter; // can be NULL | |
57 | UVector32* vec; | |
58 | UErrorCode status; | |
59 | ||
60 | // Note, we keep a reference to status, so if status is on the stack, we have | |
61 | // to be destroyed before status goes out of scope. Easiest thing is to | |
62 | // allocate us on the stack in the same (or narrower) scope as status has. | |
63 | // This attempts to encourage that by blocking heap allocation. | |
64 | void *operator new(size_t s); | |
65 | void *operator new[](size_t s); | |
66 | ||
67 | public: | |
68 | FieldPositionIteratorHandler(FieldPositionIterator* posIter, UErrorCode& status); | |
69 | ~FieldPositionIteratorHandler(); | |
70 | ||
0f5d89e8 A |
71 | void addAttribute(int32_t id, int32_t start, int32_t limit) U_OVERRIDE; |
72 | void shiftLast(int32_t delta) U_OVERRIDE; | |
73 | UBool isRecording(void) const U_OVERRIDE; | |
729e4ab9 A |
74 | }; |
75 | ||
76 | U_NAMESPACE_END | |
77 | ||
78 | #endif /* !UCONFIG_NO_FORMATTING */ | |
79 | ||
80 | #endif /* FPHDLIMP_H */ |