1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
4 *******************************************************************************
5 * Copyright (C) 2009-2015, International Business Machines Corporation and *
6 * others. All Rights Reserved. *
7 *******************************************************************************
13 #if !UCONFIG_NO_FORMATTING
15 #include "unicode/utypes.h"
16 #include "unicode/fieldpos.h"
17 #include "unicode/fpositer.h"
21 // utility FieldPositionHandler
22 // base class, null implementation
24 class U_I18N_API FieldPositionHandler
: public UMemory
{
29 virtual ~FieldPositionHandler();
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;
34 void setShift(int32_t delta
);
38 // utility subclass FieldPositionOnlyHandler
40 class FieldPositionOnlyHandler
: public FieldPositionHandler
{
44 FieldPositionOnlyHandler(FieldPosition
& pos
);
45 virtual ~FieldPositionOnlyHandler();
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
;
53 // utility subclass FieldPositionIteratorHandler
55 class FieldPositionIteratorHandler
: public FieldPositionHandler
{
56 FieldPositionIterator
* iter
; // can be NULL
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
);
68 FieldPositionIteratorHandler(FieldPositionIterator
* posIter
, UErrorCode
& status
);
69 ~FieldPositionIteratorHandler();
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
;
78 #endif /* !UCONFIG_NO_FORMATTING */
80 #endif /* FPHDLIMP_H */