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