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 | https://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 ~CodePointBreakIterator() override; 39 40 #if U_ICU_VERSION_MAJOR_NUM >= 70 41 bool operator==(const BreakIterator& that) const override; 42 #else 43 UBool operator==(const BreakIterator& that) const override; 44 #endif 45 46 CodePointBreakIterator* clone(void) const override; 47 48 UClassID getDynamicClassID(void) const override; 49 50 CharacterIterator& getText(void) const override; 51 52 UText *getUText(UText *fillIn, UErrorCode &status) const override; 53 54 void setText(const UnicodeString &text) override; 55 56 void setText(UText *text, UErrorCode &status) override; 57 58 void adoptText(CharacterIterator* it) override; 59 60 int32_t first(void) override; 61 62 int32_t last(void) override; 63 64 int32_t previous(void) override; 65 66 int32_t next(void) override; 67 68 int32_t current(void) const override; 69 70 int32_t following(int32_t offset) override; 71 72 int32_t preceding(int32_t offset) override; 73 74 UBool isBoundary(int32_t offset) override; 75 76 int32_t next(int32_t n) override; 77 78 CodePointBreakIterator *createBufferClone(void *stackBuffer, 79 int32_t &BufferSize, 80 UErrorCode &status) override; 81 82 CodePointBreakIterator &refreshInputText(UText *input, UErrorCode &status) override; 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