OLD | NEW |
1 /* | 1 /* |
2 ******************************************************************************** | 2 ******************************************************************************** |
3 * Copyright (C) 1997-2014, International Business Machines | 3 * Copyright (C) 1997-2015, International Business Machines |
4 * Corporation and others. All Rights Reserved. | 4 * Corporation and others. All Rights Reserved. |
5 ******************************************************************************** | 5 ******************************************************************************** |
6 */ | 6 */ |
7 | 7 |
8 #ifndef FILTEREDBRK_H | 8 #ifndef FILTEREDBRK_H |
9 #define FILTEREDBRK_H | 9 #define FILTEREDBRK_H |
10 | 10 |
11 #include "unicode/utypes.h" | 11 #include "unicode/utypes.h" |
12 #include "unicode/brkiter.h" | 12 #include "unicode/brkiter.h" |
13 | 13 |
14 #if !UCONFIG_NO_BREAK_ITERATION && !UCONFIG_NO_FILTERED_BREAK_ITERATION | 14 #if !UCONFIG_NO_BREAK_ITERATION && !UCONFIG_NO_FILTERED_BREAK_ITERATION |
15 #ifndef U_HIDE_INTERNAL_API | 15 |
| 16 #ifndef U_HIDE_DRAFT_API |
16 | 17 |
17 U_NAMESPACE_BEGIN | 18 U_NAMESPACE_BEGIN |
18 | 19 |
19 /** | 20 /** |
20 * \file | 21 * \file |
21 * \brief C++ API: FilteredBreakIteratorBuilder | 22 * \brief C++ API: FilteredBreakIteratorBuilder |
22 */ | 23 */ |
23 | 24 |
24 /** | 25 /** |
25 * The BreakIteratorFilter is used to modify the behavior of a BreakIterator | 26 * The BreakIteratorFilter is used to modify the behavior of a BreakIterator |
26 * by constructing a new BreakIterator which suppresses certain segment boundar
ies. | 27 * by constructing a new BreakIterator which suppresses certain segment boundar
ies. |
27 * See http://www.unicode.org/reports/tr35/tr35-general.html#Segmentation_Exce
ptions . | 28 * See http://www.unicode.org/reports/tr35/tr35-general.html#Segmentation_Exce
ptions . |
28 * For example, a typical English Sentence Break Iterator would break on the sp
ace | 29 * For example, a typical English Sentence Break Iterator would break on the sp
ace |
29 * in the string "Mr. Smith" (resulting in two segments), | 30 * in the string "Mr. Smith" (resulting in two segments), |
30 * but with "Mr." as an exception, a filtered break iterator | 31 * but with "Mr." as an exception, a filtered break iterator |
31 * would consider the string "Mr. Smith" to be a single segment. | 32 * would consider the string "Mr. Smith" to be a single segment. |
32 * | 33 * |
33 * <p><b>Note:</b> An instance of {@link BreakIterator} returned by this builder | 34 * @draft ICU 56 |
34 * class currently does not support following operations in this technology prev
iew | |
35 * version: | |
36 * <ul> | |
37 * <li>{@link BreakIterator#next(int32_t) next(int32_t n)}</li> | |
38 * <li>{@link BreakIterator#previous(void) previous(void)}</li> | |
39 * <li>{@link BreakIterator#following(int32_t) following(int32_t offset)}</li> | |
40 * <li>{@link BreakIterator#preceding(int32_t) preceding(int32_t offset)}</li> | |
41 * </ul> | |
42 * When one of above methods is called, BreakIterator.DONE will be returned imme
diately | |
43 * without updating the internal state. | |
44 * | |
45 * @internal technology preview | |
46 */ | 35 */ |
47 class U_I18N_API FilteredBreakIteratorBuilder : public UObject { | 36 class U_COMMON_API FilteredBreakIteratorBuilder : public UObject { |
48 public: | 37 public: |
49 /** | 38 /** |
50 * destructor. | 39 * destructor. |
51 * @internal technology preview | 40 * @draft ICU 56 |
52 */ | 41 */ |
53 virtual ~FilteredBreakIteratorBuilder(); | 42 virtual ~FilteredBreakIteratorBuilder(); |
54 | 43 |
55 /** | 44 /** |
56 * Construct a FilteredBreakIteratorBuilder based on rules in a locale. | 45 * Construct a FilteredBreakIteratorBuilder based on rules in a locale. |
57 * The rules are taken from CLDR exception data for the locale, | 46 * The rules are taken from CLDR exception data for the locale, |
58 * see http://www.unicode.org/reports/tr35/tr35-general.html#Segmentation_Exc
eptions | 47 * see http://www.unicode.org/reports/tr35/tr35-general.html#Segmentation_Exc
eptions |
59 * This is the equivalent of calling createInstance(UErrorCode&) | 48 * This is the equivalent of calling createInstance(UErrorCode&) |
60 * and then repeatedly calling addNoBreakAfter(...) with the contents | 49 * and then repeatedly calling addNoBreakAfter(...) with the contents |
61 * of the CLDR exception data. | 50 * of the CLDR exception data. |
62 * @param where the locale. | 51 * @param where the locale. |
63 * @param status The error code. | 52 * @param status The error code. |
64 * @return the new builder | 53 * @return the new builder |
65 * @internal technology preview | 54 * @draft ICU 56 |
66 */ | 55 */ |
67 static FilteredBreakIteratorBuilder *createInstance(const Locale& where, UErro
rCode& status); | 56 static FilteredBreakIteratorBuilder *createInstance(const Locale& where, UErro
rCode& status); |
68 | 57 |
69 /** | 58 /** |
70 * Construct an empty FilteredBreakIteratorBuilder. | 59 * Construct an empty FilteredBreakIteratorBuilder. |
71 * In this state, it will not suppress any segment boundaries. | 60 * In this state, it will not suppress any segment boundaries. |
72 * @param status The error code. | 61 * @param status The error code. |
73 * @return the new builder | 62 * @return the new builder |
74 * @internal technology preview | 63 * @draft ICU 56 |
75 */ | 64 */ |
76 static FilteredBreakIteratorBuilder *createInstance(UErrorCode &status); | 65 static FilteredBreakIteratorBuilder *createInstance(UErrorCode &status); |
77 | 66 |
78 /** | 67 /** |
79 * Suppress a certain string from being the end of a segment. | 68 * Suppress a certain string from being the end of a segment. |
80 * For example, suppressing "Mr.", then segments ending in "Mr." will not be r
eturned | 69 * For example, suppressing "Mr.", then segments ending in "Mr." will not be r
eturned |
81 * by the iterator. | 70 * by the iterator. |
82 * @param string the string to suppress, such as "Mr." | 71 * @param string the string to suppress, such as "Mr." |
83 * @param status error code | 72 * @param status error code |
84 * @return returns TRUE if the string was not present and now added, | 73 * @return returns TRUE if the string was not present and now added, |
85 * FALSE if the call was a no-op because the string was already being suppress
ed. | 74 * FALSE if the call was a no-op because the string was already being suppress
ed. |
86 * @internal technology preview | 75 * @draft ICU 56 |
87 */ | 76 */ |
88 virtual UBool suppressBreakAfter(const UnicodeString& string, UErrorCode& stat
us) = 0; | 77 virtual UBool suppressBreakAfter(const UnicodeString& string, UErrorCode& stat
us) = 0; |
89 | 78 |
90 /** | 79 /** |
91 * Stop suppressing a certain string from being the end of the segment. | 80 * Stop suppressing a certain string from being the end of the segment. |
92 * This function does not create any new segment boundaries, but only serves t
o un-do | 81 * This function does not create any new segment boundaries, but only serves t
o un-do |
93 * the effect of earlier calls to suppressBreakAfter, or to un-do the effect o
f | 82 * the effect of earlier calls to suppressBreakAfter, or to un-do the effect o
f |
94 * locale data which may be suppressing certain strings. | 83 * locale data which may be suppressing certain strings. |
95 * @param exception the exception to remove | 84 * @param exception the exception to remove |
96 * @param status error code | 85 * @param status error code |
97 * @return returns TRUE if the string was present and now removed, | 86 * @return returns TRUE if the string was present and now removed, |
98 * FALSE if the call was a no-op because the string was not being suppressed. | 87 * FALSE if the call was a no-op because the string was not being suppressed. |
99 * @internal technology preview | 88 * @draft ICU 56 |
100 */ | 89 */ |
101 virtual UBool unsuppressBreakAfter(const UnicodeString& string, UErrorCode& st
atus) = 0; | 90 virtual UBool unsuppressBreakAfter(const UnicodeString& string, UErrorCode& st
atus) = 0; |
102 | 91 |
103 /** | 92 /** |
104 * Wrap (adopt) an existing break iterator in a new filtered instance. | 93 * Wrap (adopt) an existing break iterator in a new filtered instance. |
105 * The resulting BreakIterator is owned by the caller. | 94 * The resulting BreakIterator is owned by the caller. |
106 * The BreakIteratorFilter may be destroyed before the BreakIterator is destro
yed. | 95 * The BreakIteratorFilter may be destroyed before the BreakIterator is destro
yed. |
107 * Note that the adoptBreakIterator is adopted by the new BreakIterator | 96 * Note that the adoptBreakIterator is adopted by the new BreakIterator |
108 * and should no longer be used by the caller. | 97 * and should no longer be used by the caller. |
109 * The FilteredBreakIteratorBuilder may be reused. | 98 * The FilteredBreakIteratorBuilder may be reused. |
110 * @param adoptBreakIterator the break iterator to adopt | 99 * @param adoptBreakIterator the break iterator to adopt |
111 * @param status error code | 100 * @param status error code |
112 * @return the new BreakIterator, owned by the caller. | 101 * @return the new BreakIterator, owned by the caller. |
113 * @internal technology preview | 102 * @draft ICU 56 |
114 */ | 103 */ |
115 virtual BreakIterator *build(BreakIterator* adoptBreakIterator, UErrorCode& st
atus) = 0; | 104 virtual BreakIterator *build(BreakIterator* adoptBreakIterator, UErrorCode& st
atus) = 0; |
116 | 105 |
117 protected: | 106 protected: |
118 /** | 107 /** |
119 * For subclass use | 108 * For subclass use |
120 * @internal technology preview | 109 * @draft ICU 56 |
121 */ | 110 */ |
122 FilteredBreakIteratorBuilder(); | 111 FilteredBreakIteratorBuilder(); |
123 }; | 112 }; |
124 | 113 |
125 | 114 |
126 U_NAMESPACE_END | 115 U_NAMESPACE_END |
127 | 116 |
128 #endif /* U_HIDE_INTERNAL_API */ | 117 #endif /* U_HIDE_DRAFT_API */ |
| 118 |
129 #endif // #if !UCONFIG_NO_BREAK_ITERATION && !UCONFIG_NO_FILTERED_BREAK_ITERATIO
N | 119 #endif // #if !UCONFIG_NO_BREAK_ITERATION && !UCONFIG_NO_FILTERED_BREAK_ITERATIO
N |
130 | 120 |
131 #endif // #ifndef FILTEREDBRK_H | 121 #endif // #ifndef FILTEREDBRK_H |
OLD | NEW |