ICU 71.1 71.1

brkiter.h
Go to the documentation of this file.
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 ********************************************************************************
5 * Copyright (C) 1997-2016, International Business Machines
6 * Corporation and others. All Rights Reserved.
7 ********************************************************************************
8 *
9 * File brkiter.h
10 *
11 * Modification History:
12 *
13 * Date Name Description
14 * 02/18/97 aliu Added typedef for TextCount. Made DONE const.
15 * 05/07/97 aliu Fixed DLL declaration.
16 * 07/09/97 jfitz Renamed BreakIterator and interface synced with JDK
17 * 08/11/98 helena Sync-up JDK1.2.
18 * 01/13/2000 helena Added UErrorCode parameter to createXXXInstance methods.
19 ********************************************************************************
20 */
21
22 #ifndef BRKITER_H
23 #define BRKITER_H
24
25 #include "unicode/utypes.h"
26
32 #include "unicode/utypes.h"
33
34 #if U_SHOW_CPLUSPLUS_API
35
36 #if UCONFIG_NO_BREAK_ITERATION
37
38 U_NAMESPACE_BEGIN
39
40 /*
41 * Allow the declaration of APIs with pointers to BreakIterator
42 * even when break iteration is removed from the build.
43 */
44 class BreakIterator;
45
46 U_NAMESPACE_END
47
48 #else
49
50 #include "unicode/uobject.h"
51 #include "unicode/unistr.h"
52 #include "unicode/chariter.h"
53 #include "unicode/locid.h"
54 #include "unicode/ubrk.h"
55 #include "unicode/strenum.h"
56 #include "unicode/utext.h"
57 #include "unicode/umisc.h"
58
59 U_NAMESPACE_BEGIN
60
106 class U_COMMON_API BreakIterator : public UObject {
107 public:
112 virtual ~BreakIterator();
113
127 virtual bool operator==(const BreakIterator&) const = 0;
128
135 bool operator!=(const BreakIterator& rhs) const { return !operator==(rhs); }
136
142 virtual BreakIterator* clone() const = 0;
143
149 virtual UClassID getDynamicClassID(void) const override = 0;
150
155 virtual CharacterIterator& getText(void) const = 0;
156
157
172 virtual UText *getUText(UText *fillIn, UErrorCode &status) const = 0;
173
185 virtual void setText(const UnicodeString &text) = 0;
186
205 virtual void setText(UText *text, UErrorCode &status) = 0;
206
215 virtual void adoptText(CharacterIterator* it) = 0;
216
217 enum {
223 DONE = (int32_t)-1
224 };
225
231 virtual int32_t first(void) = 0;
232
238 virtual int32_t last(void) = 0;
239
246 virtual int32_t previous(void) = 0;
247
254 virtual int32_t next(void) = 0;
255
261 virtual int32_t current(void) const = 0;
262
271 virtual int32_t following(int32_t offset) = 0;
272
281 virtual int32_t preceding(int32_t offset) = 0;
282
291 virtual UBool isBoundary(int32_t offset) = 0;
292
302 virtual int32_t next(int32_t n) = 0;
303
317 virtual int32_t getRuleStatus() const;
318
347 virtual int32_t getRuleStatusVec(int32_t *fillInVec, int32_t capacity, UErrorCode &status);
348
368 static BreakIterator* U_EXPORT2
369 createWordInstance(const Locale& where, UErrorCode& status);
370
392 static BreakIterator* U_EXPORT2
393 createLineInstance(const Locale& where, UErrorCode& status);
394
414 static BreakIterator* U_EXPORT2
415 createCharacterInstance(const Locale& where, UErrorCode& status);
416
435 static BreakIterator* U_EXPORT2
436 createSentenceInstance(const Locale& where, UErrorCode& status);
437
438 #ifndef U_HIDE_DEPRECATED_API
439
461 static BreakIterator* U_EXPORT2
462 createTitleInstance(const Locale& where, UErrorCode& status);
463 #endif /* U_HIDE_DEPRECATED_API */
464
474 static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);
475
485 static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale,
486 const Locale& displayLocale,
487 UnicodeString& name);
488
497 static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale,
498 UnicodeString& name);
499
500 #ifndef U_FORCE_HIDE_DEPRECATED_API
501
520 virtual BreakIterator * createBufferClone(void *stackBuffer,
521 int32_t &BufferSize,
522 UErrorCode &status) = 0;
523 #endif // U_FORCE_HIDE_DEPRECATED_API
524
525 #ifndef U_HIDE_DEPRECATED_API
526
533 inline UBool isBufferClone(void);
534
535 #endif /* U_HIDE_DEPRECATED_API */
536
537 #if !UCONFIG_NO_SERVICE
538
553 static URegistryKey U_EXPORT2 registerInstance(BreakIterator* toAdopt,
554 const Locale& locale,
555 UBreakIteratorType kind,
556 UErrorCode& status);
557
570 static UBool U_EXPORT2 unregister(URegistryKey key, UErrorCode& status);
571
578 static StringEnumeration* U_EXPORT2 getAvailableLocales(void);
579 #endif
580
586 Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
587
588 #ifndef U_HIDE_INTERNAL_API
589
595 const char *getLocaleID(ULocDataLocaleType type, UErrorCode& status) const;
596 #endif /* U_HIDE_INTERNAL_API */
597
623 virtual BreakIterator &refreshInputText(UText *input, UErrorCode &status) = 0;
624
625 private:
626 static BreakIterator* buildInstance(const Locale& loc, const char *type, UErrorCode& status);
627 static BreakIterator* createInstance(const Locale& loc, int32_t kind, UErrorCode& status);
628 static BreakIterator* makeInstance(const Locale& loc, int32_t kind, UErrorCode& status);
629
630 friend class ICUBreakIteratorFactory;
631 friend class ICUBreakIteratorService;
632
633 protected:
634 // Do not enclose protected default/copy constructors with #ifndef U_HIDE_INTERNAL_API
635 // or else the compiler will create a public ones.
637 BreakIterator();
639 BreakIterator (const BreakIterator &other);
640 #ifndef U_HIDE_INTERNAL_API
641
642 BreakIterator (const Locale& valid, const Locale &actual);
644 BreakIterator &operator = (const BreakIterator &other);
645 #endif /* U_HIDE_INTERNAL_API */
646
647 private:
648
650 char actualLocale[ULOC_FULLNAME_CAPACITY];
651 char validLocale[ULOC_FULLNAME_CAPACITY];
652 };
653
654 #ifndef U_HIDE_DEPRECATED_API
655
656 inline UBool BreakIterator::isBufferClone()
657 {
658 return false;
659 }
660
661 #endif /* U_HIDE_DEPRECATED_API */
662
663 U_NAMESPACE_END
664
665 #endif /* #if !UCONFIG_NO_BREAK_ITERATION */
666
667 #endif /* U_SHOW_CPLUSPLUS_API */
668
669 #endif // BRKITER_H
670 //eof
icu::BreakIterator
The BreakIterator class implements methods for finding the location of boundaries in text.
Definition: brkiter.h:106
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
UBool
int8_t UBool
The ICU boolean type, a signed-byte integer.
Definition: umachine.h:269
ubrk.h
C API: BreakIterator.
ULocDataLocaleType
ULocDataLocaleType
Constants for *_getLocale() Allow user to select whether she wants information on requested,...
Definition: uloc.h:338
icu::operator==
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
utext.h
C API: Abstract Unicode Text API.
icu::BreakIterator::operator!=
bool operator!=(const BreakIterator &rhs) const
Returns the complement of the result of operator==.
Definition: brkiter.h:135
U_COMMON_API
#define U_COMMON_API
Definition: utypes.h:300
umisc.h
C API:misc definitions.
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:295
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:96
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415
icu::StringEnumeration
Base class for 'pure' C++ implementations of uenum api.
Definition: strenum.h:61
icu::UObject::getDynamicClassID
virtual UClassID getDynamicClassID() const
ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.
UBreakIteratorType
UBreakIteratorType
The possible types of text boundaries.
Definition: ubrk.h:102
UText
UText struct.
Definition: utext.h:1328
icu::CharacterIterator
Abstract class that defines an API for iteration on text objects.
Definition: chariter.h:361
ULOC_FULLNAME_CAPACITY
#define ULOC_FULLNAME_CAPACITY
Useful constant for the maximum size of the whole locale ID (including the terminating NULL and all k...
Definition: uloc.h:264
strenum.h
C++ API: String Enumeration.
chariter.h
C++ API: Character Iterator.
locid.h
C++ API: Locale ID object.
uobject.h
C++ API: Common ICU base class UObject.
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:195
unistr.h
C++ API: Unicode String.
URegistryKey
const typedef void * URegistryKey
Opaque type returned by registerInstance, registerFactory and unregister for service registration.
Definition: umisc.h:57