1 // © 2016 and later: Unicode, Inc. and others. 2 // License & terms of use: http://www.unicode.org/copyright.html 3 /* 4 ******************************************************************************* 5 * Copyright (C) 2009-2015, International Business Machines Corporation and * 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 24 class U_I18N_API FieldPositionHandler: public UMemory { 25 public: 26 virtual ~FieldPositionHandler(); 27 virtual void addAttribute(int32_t id, int32_t start, int32_t limit); 28 virtual void shiftLast(int32_t delta); 29 virtual UBool isRecording(void) const; 30 }; 31 32 33 // utility subclass FieldPositionOnlyHandler 34 35 class FieldPositionOnlyHandler : public FieldPositionHandler { 36 FieldPosition& pos; 37 38 public: 39 FieldPositionOnlyHandler(FieldPosition& pos); 40 virtual ~FieldPositionOnlyHandler(); 41 42 virtual void addAttribute(int32_t id, int32_t start, int32_t limit); 43 virtual void shiftLast(int32_t delta); 44 virtual UBool isRecording(void) const; 45 }; 46 47 48 // utility subclass FieldPositionIteratorHandler 49 50 class FieldPositionIteratorHandler : public FieldPositionHandler { 51 FieldPositionIterator* iter; // can be NULL 52 UVector32* vec; 53 UErrorCode status; 54 55 // Note, we keep a reference to status, so if status is on the stack, we have 56 // to be destroyed before status goes out of scope. Easiest thing is to 57 // allocate us on the stack in the same (or narrower) scope as status has. 58 // This attempts to encourage that by blocking heap allocation. 59 void *operator new(size_t s); 60 void *operator new[](size_t s); 61 62 public: 63 FieldPositionIteratorHandler(FieldPositionIterator* posIter, UErrorCode& status); 64 ~FieldPositionIteratorHandler(); 65 66 virtual void addAttribute(int32_t id, int32_t start, int32_t limit); 67 virtual void shiftLast(int32_t delta); 68 virtual UBool isRecording(void) const; 69 }; 70 71 U_NAMESPACE_END 72 73 #endif /* !UCONFIG_NO_FORMATTING */ 74 75 #endif /* FPHDLIMP_H */ 76