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 		virtual UBool operator==(const BreakIterator& that) const;
43 
44 		virtual CodePointBreakIterator* clone(void) const;
45 
46 		virtual UClassID getDynamicClassID(void) const;
47 
48 		virtual CharacterIterator& getText(void) const;
49 
50 		virtual UText *getUText(UText *fillIn, UErrorCode &status) const;
51 
52 		virtual void setText(const UnicodeString &text);
53 
54 		virtual void setText(UText *text, UErrorCode &status);
55 
56 		virtual void adoptText(CharacterIterator* it);
57 
58 		virtual int32_t first(void);
59 
60 		virtual int32_t last(void);
61 
62 		virtual int32_t previous(void);
63 
64 		virtual int32_t next(void);
65 
66 		virtual int32_t current(void) const;
67 
68 		virtual int32_t following(int32_t offset);
69 
70 		virtual int32_t preceding(int32_t offset);
71 
72 		virtual UBool isBoundary(int32_t offset);
73 
74 		virtual int32_t next(int32_t n);
75 
76 		virtual CodePointBreakIterator *createBufferClone(void *stackBuffer,
77 														  int32_t &BufferSize,
78 														  UErrorCode &status);
79 
80 		virtual CodePointBreakIterator &refreshInputText(UText *input, UErrorCode &status);
81 
getLastCodePoint()82 		inline UChar32 getLastCodePoint()
83 		{
84 			return this->lastCodePoint;
85 		}
86 
87 	private:
88 		UText *fText;
89 		UChar32 lastCodePoint;
90 		mutable CharacterIterator *fCharIter;
91 
clearCurrentCharIter()92 		inline void clearCurrentCharIter()
93 		{
94 			delete this->fCharIter;
95 			this->fCharIter = NULL;
96 			this->lastCodePoint = U_SENTINEL;
97 		}
98 	};
99 }
100 
101 #endif
102