ICU 58.2 58.2

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

brkiter.h
Go to the documentation of this file.
1 // Copyright (C) 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 #if UCONFIG_NO_BREAK_ITERATION
33
34 U_NAMESPACE_BEGIN
35
36 /*
37 * Allow the declaration of APIs with pointers to BreakIterator
38 * even when break iteration is removed from the build.
39 */
40 class BreakIterator;
41
42 U_NAMESPACE_END
43
44 #else
45
46 #include "unicode/uobject.h"
47 #include "unicode/unistr.h"
48 #include "unicode/chariter.h"
49 #include "unicode/locid.h"
50 #include "unicode/ubrk.h"
51 #include "unicode/strenum.h"
52 #include "unicode/utext.h"
53 #include "unicode/umisc.h"
54
55 U_NAMESPACE_BEGIN
56
102 class U_COMMON_API BreakIterator : public UObject {
103 public:
108 virtual ~BreakIterator();
109
123 virtual UBool operator==(const BreakIterator&) const = 0;
124
131 UBool operator!=(const BreakIterator& rhs) const { return !operator==(rhs); }
132
138 virtual BreakIterator* clone(void) const = 0;
139
145 virtual UClassID getDynamicClassID(void) const = 0;
146
151 virtual CharacterIterator& getText(void) const = 0;
152
153
168 virtual UText *getUText(UText *fillIn, UErrorCode &status) const = 0;
169
181 virtual void setText(const UnicodeString &text) = 0;
182
201 virtual void setText(UText *text, UErrorCode &status) = 0;
202
211 virtual void adoptText(CharacterIterator* it) = 0;
212
213 enum {
219 DONE = (int32_t)-1
220 };
221
227 virtual int32_t first(void) = 0;
228
234 virtual int32_t last(void) = 0;
235
242 virtual int32_t previous(void) = 0;
243
250 virtual int32_t next(void) = 0;
251
257 virtual int32_t current(void) const = 0;
258
267 virtual int32_t following(int32_t offset) = 0;
268
277 virtual int32_t preceding(int32_t offset) = 0;
278
287 virtual UBool isBoundary(int32_t offset) = 0;
288
298 virtual int32_t next(int32_t n) = 0;
299
314 virtual int32_t getRuleStatus() const;
315
344 virtual int32_t getRuleStatusVec(int32_t *fillInVec, int32_t capacity, UErrorCode &status);
345
365 static BreakIterator* U_EXPORT2
366 createWordInstance(const Locale& where, UErrorCode& status);
367
389 static BreakIterator* U_EXPORT2
390 createLineInstance(const Locale& where, UErrorCode& status);
391
411 static BreakIterator* U_EXPORT2
412 createCharacterInstance(const Locale& where, UErrorCode& status);
413
432 static BreakIterator* U_EXPORT2
433 createSentenceInstance(const Locale& where, UErrorCode& status);
434
457 static BreakIterator* U_EXPORT2
458 createTitleInstance(const Locale& where, UErrorCode& status);
459
469 static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);
470
480 static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale,
481 const Locale& displayLocale,
482 UnicodeString& name);
483
492 static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale,
493 UnicodeString& name);
494
514 virtual BreakIterator * createBufferClone(void *stackBuffer,
515 int32_t &BufferSize,
516 UErrorCode &status) = 0;
517
518 #ifndef U_HIDE_DEPRECATED_API
519
526 inline UBool isBufferClone(void);
527
528 #endif /* U_HIDE_DEPRECATED_API */
529
530 #if !UCONFIG_NO_SERVICE
531
546 static URegistryKey U_EXPORT2 registerInstance(BreakIterator* toAdopt,
547 const Locale& locale,
548 UBreakIteratorType kind,
549 UErrorCode& status);
550
563 static UBool U_EXPORT2 unregister(URegistryKey key, UErrorCode& status);
564
571 static StringEnumeration* U_EXPORT2 getAvailableLocales(void);
572 #endif
573
579 Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
580
581 #ifndef U_HIDE_INTERNAL_API
582
588 const char *getLocaleID(ULocDataLocaleType type, UErrorCode& status) const;
589 #endif /* U_HIDE_INTERNAL_API */
590
616 virtual BreakIterator &refreshInputText(UText *input, UErrorCode &status) = 0;
617
618 private:
619 static BreakIterator* buildInstance(const Locale& loc, const char *type, int32_t kind, UErrorCode& status);
620 static BreakIterator* createInstance(const Locale& loc, int32_t kind, UErrorCode& status);
621 static BreakIterator* makeInstance(const Locale& loc, int32_t kind, UErrorCode& status);
622
623 friend class ICUBreakIteratorFactory;
624 friend class ICUBreakIteratorService;
625
626 protected:
627 // Do not enclose protected default/copy constructors with #ifndef U_HIDE_INTERNAL_API
628 // or else the compiler will create a public ones.
630 BreakIterator();
632 BreakIterator (const BreakIterator &other) : UObject(other) {}
633 #ifndef U_HIDE_INTERNAL_API
634
635 BreakIterator (const Locale& valid, const Locale& actual);
636 #endif /* U_HIDE_INTERNAL_API */
637
638 private:
639
641 char actualLocale[ULOC_FULLNAME_CAPACITY];
642 char validLocale[ULOC_FULLNAME_CAPACITY];
643
648 BreakIterator& operator=(const BreakIterator&);
649 };
650
651 #ifndef U_HIDE_DEPRECATED_API
652
653 inline UBool BreakIterator::isBufferClone()
654 {
655 return FALSE;
656 }
657
658 #endif /* U_HIDE_DEPRECATED_API */
659
660 U_NAMESPACE_END
661
662 #endif /* #if !UCONFIG_NO_BREAK_ITERATION */
663
664 #endif // _BRKITER
665 //eof
icu::UObject::getDynamicClassID
virtual UClassID getDynamicClassID() const
ICU4C "poor man&#39;s RTTI", returns a UClassID for the actual ICU class.
unistr.h
C++ API: Unicode String.
icu::operator==
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
UBreakIteratorType
UBreakIteratorType
The possible types of text boundaries.
Definition: ubrk.h:99
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler&#39;s RTTI.
Definition: uobject.h:93
umisc.h
C API:misc definitions.
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
icu::StringEnumeration
Base class for &#39;pure&#39; C++ implementations of uenum api.
Definition: strenum.h:57
utext.h
C API: Abstract Unicode Text API.
icu::BreakIterator::BreakIterator
BreakIterator(const BreakIterator &other)
Definition: brkiter.h:632
U_NAMESPACE_BEGIN
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:131
icu::CharacterIterator
Abstract class that defines an API for iteration on text objects.
Definition: chariter.h:358
icu::BreakIterator
The BreakIterator class implements methods for finding the location of boundaries in text...
Definition: brkiter.h:102
icu::BreakIterator::isBufferClone
UBool isBufferClone(void)
Determine whether the BreakIterator was created in user memory by createBufferClone(), and thus should not be deleted.
Definition: brkiter.h:653
icu::BreakIterator::operator!=
UBool operator!=(const BreakIterator &rhs) const
Returns the complement of the result of operator==.
Definition: brkiter.h:131
uobject.h
C++ API: Common ICU base class UObject.
URegistryKey
const void * URegistryKey
Opaque type returned by registerInstance, registerFactory and unregister for service registration...
Definition: umisc.h:57
U_NAMESPACE_END
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:132
UErrorCode
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:396
ULocDataLocaleType
ULocDataLocaleType
Constants for *_getLocale() Allow user to select whether she wants information on requested...
Definition: uloc.h:338
ubrk.h
C API: BreakIterator.
strenum.h
C++ API: String Enumeration.
locid.h
C++ API: Locale ID object.
UText
UText struct.
Definition: utext.h:1345
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
FALSE
#define FALSE
The FALSE value of a UBool.
Definition: umachine.h:267
U_COMMON_API
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside...
Definition: utypes.h:359
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:295
chariter.h
C++ API: Character Iterator.
icu::UObject
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:223
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:259
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:187