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