michael@0: /* michael@0: ******************************************************************************* michael@0: * Copyright (C) 2009-2010, International Business Machines Corporation and * michael@0: * others. All Rights Reserved. * michael@0: ******************************************************************************* michael@0: */ michael@0: michael@0: #ifndef FPHDLIMP_H michael@0: #define FPHDLIMP_H michael@0: michael@0: #if !UCONFIG_NO_FORMATTING michael@0: michael@0: #include "unicode/utypes.h" michael@0: #include "unicode/fieldpos.h" michael@0: #include "unicode/fpositer.h" michael@0: michael@0: U_NAMESPACE_BEGIN michael@0: michael@0: // utility FieldPositionHandler michael@0: // base class, null implementation michael@0: michael@0: class FieldPositionHandler: public UMemory { michael@0: public: michael@0: virtual ~FieldPositionHandler(); michael@0: virtual void addAttribute(int32_t id, int32_t start, int32_t limit); michael@0: virtual void shiftLast(int32_t delta); michael@0: virtual UBool isRecording(void); michael@0: }; michael@0: michael@0: michael@0: // utility subclass FieldPositionOnlyHandler michael@0: michael@0: class FieldPositionOnlyHandler : public FieldPositionHandler { michael@0: FieldPosition& pos; michael@0: michael@0: public: michael@0: FieldPositionOnlyHandler(FieldPosition& pos); michael@0: virtual ~FieldPositionOnlyHandler(); michael@0: michael@0: virtual void addAttribute(int32_t id, int32_t start, int32_t limit); michael@0: virtual void shiftLast(int32_t delta); michael@0: virtual UBool isRecording(void); michael@0: }; michael@0: michael@0: michael@0: // utility subclass FieldPositionIteratorHandler michael@0: michael@0: class FieldPositionIteratorHandler : public FieldPositionHandler { michael@0: FieldPositionIterator* iter; // can be NULL michael@0: UVector32* vec; michael@0: UErrorCode status; michael@0: michael@0: // Note, we keep a reference to status, so if status is on the stack, we have michael@0: // to be destroyed before status goes out of scope. Easiest thing is to michael@0: // allocate us on the stack in the same (or narrower) scope as status has. michael@0: // This attempts to encourage that by blocking heap allocation. michael@0: void *operator new(size_t s); michael@0: void *operator new[](size_t s); michael@0: michael@0: public: michael@0: FieldPositionIteratorHandler(FieldPositionIterator* posIter, UErrorCode& status); michael@0: ~FieldPositionIteratorHandler(); michael@0: michael@0: virtual void addAttribute(int32_t id, int32_t start, int32_t limit); michael@0: virtual void shiftLast(int32_t delta); michael@0: virtual UBool isRecording(void); michael@0: }; michael@0: michael@0: U_NAMESPACE_END michael@0: michael@0: #endif /* !UCONFIG_NO_FORMATTING */ michael@0: michael@0: #endif /* FPHDLIMP_H */