1 /* 2 +----------------------------------------------------------------------+ 3 | This source file is subject to version 3.01 of the PHP license, | 4 | that is bundled with this package in the file LICENSE, and is | 5 | available through the world-wide-web at the following url: | 6 | http://www.php.net/license/3_01.txt | 7 | If you did not receive a copy of the PHP license and are unable to | 8 | obtain it through the world-wide-web, please send a note to | 9 | license@php.net so we can mail you a copy immediately. | 10 +----------------------------------------------------------------------+ 11 | Authors: Gustavo Lopes <cataphract@php.net> | 12 +----------------------------------------------------------------------+ 13 */ 14 15 #ifndef CODEPOINTITERATOR_INTERNAL_H 16 #define CODEPOINTITERATOR_INTERNAL_H 17 18 #include <unicode/brkiter.h> 19 #include <unicode/unistr.h> 20 21 using icu::BreakIterator; 22 using icu::CharacterIterator; 23 using icu::UnicodeString; 24 25 namespace PHP { 26 27 class CodePointBreakIterator : public BreakIterator { 28 29 public: 30 static UClassID getStaticClassID(); 31 32 CodePointBreakIterator(); 33 34 CodePointBreakIterator(const CodePointBreakIterator &other); 35 36 CodePointBreakIterator& operator=(const CodePointBreakIterator& that); 37 38 virtual ~CodePointBreakIterator(); 39 40 #if U_ICU_VERSION_MAJOR_NUM >= 70 41 virtual bool operator==(const BreakIterator& that) const; 42 #else 43 virtual UBool operator==(const BreakIterator& that) const; 44 #endif 45 46 virtual CodePointBreakIterator* clone(void) const; 47 48 virtual UClassID getDynamicClassID(void) const; 49 50 virtual CharacterIterator& getText(void) const; 51 52 virtual UText *getUText(UText *fillIn, UErrorCode &status) const; 53 54 virtual void setText(const UnicodeString &text); 55 56 virtual void setText(UText *text, UErrorCode &status); 57 58 virtual void adoptText(CharacterIterator* it); 59 60 virtual int32_t first(void); 61 62 virtual int32_t last(void); 63 64 virtual int32_t previous(void); 65 66 virtual int32_t next(void); 67 68 virtual int32_t current(void) const; 69 70 virtual int32_t following(int32_t offset); 71 72 virtual int32_t preceding(int32_t offset); 73 74 virtual UBool isBoundary(int32_t offset); 75 76 virtual int32_t next(int32_t n); 77 78 virtual CodePointBreakIterator *createBufferClone(void *stackBuffer, 79 int32_t &BufferSize, 80 UErrorCode &status); 81 82 virtual CodePointBreakIterator &refreshInputText(UText *input, UErrorCode &status); 83 getLastCodePoint()84 inline UChar32 getLastCodePoint() 85 { 86 return this->lastCodePoint; 87 } 88 89 private: 90 UText *fText; 91 UChar32 lastCodePoint; 92 mutable CharacterIterator *fCharIter; 93 clearCurrentCharIter()94 inline void clearCurrentCharIter() 95 { 96 delete this->fCharIter; 97 this->fCharIter = NULL; 98 this->lastCodePoint = U_SENTINEL; 99 } 100 }; 101 } 102 103 #endif 104