ICU 50.1.2  50.1.2
brkiter.h
Go to the documentation of this file.
1 /*
2 ********************************************************************************
3 * Copyright (C) 1997-2012, International Business Machines
4 * Corporation and others. All Rights Reserved.
5 ********************************************************************************
6 *
7 * File brkiter.h
8 *
9 * Modification History:
10 *
11 * Date Name Description
12 * 02/18/97 aliu Added typedef for TextCount. Made DONE const.
13 * 05/07/97 aliu Fixed DLL declaration.
14 * 07/09/97 jfitz Renamed BreakIterator and interface synced with JDK
15 * 08/11/98 helena Sync-up JDK1.2.
16 * 01/13/2000 helena Added UErrorCode parameter to createXXXInstance methods.
17 ********************************************************************************
18 */
19 
20 #ifndef BRKITER_H
21 #define BRKITER_H
22 
23 #include "unicode/utypes.h"
24 
30 #if UCONFIG_NO_BREAK_ITERATION
31 
33 
34 /*
35  * Allow the declaration of APIs with pointers to BreakIterator
36  * even when break iteration is removed from the build.
37  */
38 class BreakIterator;
39 
41 
42 #else
43 
44 #include "unicode/uobject.h"
45 #include "unicode/unistr.h"
46 #include "unicode/chariter.h"
47 #include "unicode/locid.h"
48 #include "unicode/ubrk.h"
49 #include "unicode/strenum.h"
50 #include "unicode/utext.h"
51 #include "unicode/umisc.h"
52 
54 
101 public:
106  virtual ~BreakIterator();
107 
121  virtual UBool operator==(const BreakIterator&) const = 0;
122 
129  UBool operator!=(const BreakIterator& rhs) const { return !operator==(rhs); }
130 
136  virtual BreakIterator* clone(void) const = 0;
137 
143  virtual UClassID getDynamicClassID(void) const = 0;
144 
149  virtual CharacterIterator& getText(void) const = 0;
150 
151 
166  virtual UText *getUText(UText *fillIn, UErrorCode &status) const = 0;
167 
174  virtual void setText(const UnicodeString &text) = 0;
175 
189  virtual void setText(UText *text, UErrorCode &status) = 0;
190 
199  virtual void adoptText(CharacterIterator* it) = 0;
200 
201  enum {
207  DONE = (int32_t)-1
208  };
209 
215  virtual int32_t first(void) = 0;
216 
222  virtual int32_t last(void) = 0;
223 
230  virtual int32_t previous(void) = 0;
231 
238  virtual int32_t next(void) = 0;
239 
245  virtual int32_t current(void) const = 0;
246 
255  virtual int32_t following(int32_t offset) = 0;
256 
265  virtual int32_t preceding(int32_t offset) = 0;
266 
275  virtual UBool isBoundary(int32_t offset) = 0;
276 
286  virtual int32_t next(int32_t n) = 0;
287 
307  static BreakIterator* U_EXPORT2
308  createWordInstance(const Locale& where, UErrorCode& status);
309 
331  static BreakIterator* U_EXPORT2
332  createLineInstance(const Locale& where, UErrorCode& status);
333 
353  static BreakIterator* U_EXPORT2
354  createCharacterInstance(const Locale& where, UErrorCode& status);
355 
374  static BreakIterator* U_EXPORT2
375  createSentenceInstance(const Locale& where, UErrorCode& status);
376 
399  static BreakIterator* U_EXPORT2
400  createTitleInstance(const Locale& where, UErrorCode& status);
401 
411  static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);
412 
422  static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale,
423  const Locale& displayLocale,
424  UnicodeString& name);
425 
434  static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale,
435  UnicodeString& name);
436 
454  virtual BreakIterator * createBufferClone(void *stackBuffer,
455  int32_t &BufferSize,
456  UErrorCode &status) = 0;
457 
464  inline UBool isBufferClone(void);
465 
466 #if !UCONFIG_NO_SERVICE
467 
479  static URegistryKey U_EXPORT2 registerInstance(BreakIterator* toAdopt,
480  const Locale& locale,
481  UBreakIteratorType kind,
482  UErrorCode& status);
483 
493  static UBool U_EXPORT2 unregister(URegistryKey key, UErrorCode& status);
494 
501  static StringEnumeration* U_EXPORT2 getAvailableLocales(void);
502 #endif
503 
509  Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
510 
511 #ifndef U_HIDE_INTERNAL_API
512 
518  const char *getLocaleID(ULocDataLocaleType type, UErrorCode& status) const;
519 #endif /* U_HIDE_INTERNAL_API */
520 
546  virtual BreakIterator &refreshInputText(UText *input, UErrorCode &status) = 0;
547 
548  private:
549  static BreakIterator* buildInstance(const Locale& loc, const char *type, int32_t kind, UErrorCode& status);
550  static BreakIterator* createInstance(const Locale& loc, int32_t kind, UErrorCode& status);
551  static BreakIterator* makeInstance(const Locale& loc, int32_t kind, UErrorCode& status);
552 
553  friend class ICUBreakIteratorFactory;
554  friend class ICUBreakIteratorService;
555 
556 protected:
557  // Do not enclose protected default/copy constructors with #ifndef U_HIDE_INTERNAL_API
558  // or else the compiler will create a public ones.
560  BreakIterator();
564  BreakIterator (const BreakIterator &other) : UObject(other), fBufferClone(FALSE) {}
565 
566 private:
567 
569  char actualLocale[ULOC_FULLNAME_CAPACITY];
570  char validLocale[ULOC_FULLNAME_CAPACITY];
571 
576  BreakIterator& operator=(const BreakIterator&);
577 };
578 
580 {
581  return fBufferClone;
582 }
583 
585 
586 #endif /* #if !UCONFIG_NO_BREAK_ITERATION */
587 
588 #endif // _BRKITER
589 //eof
590 
virtual UClassID getDynamicClassID() const =0
ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.
C++ API: Unicode String.
U_EXPORT UBool operator==(const StringPiece &x, const StringPiece &y)
Global operator == for StringPiece.
UBreakIteratorType
The possible types of text boundaries.
Definition: ubrk.h:87
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:96
C API:misc definitions.
#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:262
Base class for 'pure' C++ implementations of uenum api.
Definition: strenum.h:55
C API: Abstract Unicode Text API.
BreakIterator(const BreakIterator &other)
Definition: brkiter.h:564
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:129
Abstract class that defines an API for iteration on text objects.
Definition: chariter.h:356
The BreakIterator class implements methods for finding the location of boundaries in text...
Definition: brkiter.h:100
UBool isBufferClone(void)
Determine whether the BreakIterator was created in user memory by createBufferClone(), and thus should not be deleted.
Definition: brkiter.h:579
UBool operator!=(const BreakIterator &rhs) const
Returns the complement of the result of operator==.
Definition: brkiter.h:129
C++ API: Common ICU base class UObject.
const void * URegistryKey
Opaque type returned by registerInstance, registerFactory and unregister for service registration...
Definition: umisc.h:55
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:130
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:476
ULocDataLocaleType
Constants for *_getLocale() Allow user to select whether she wants information on requested...
Definition: uloc.h:336
C API: BreakIterator.
C++ API: String Enumeration.
C++ API: Locale ID object.
UText struct.
Definition: utext.h:1343
Basic definitions for ICU, for both C and C++ APIs.
UBool fBufferClone
Definition: brkiter.h:562
#define FALSE
The FALSE value of a UBool.
Definition: umachine.h:208
#define U_COMMON_API
Set to export library symbols from inside the common library, and to import them from outside...
Definition: utypes.h:357
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:246
C++ API: Character Iterator.
UObject is the common ICU "boilerplate" class.
Definition: uobject.h:229
int8_t UBool
The ICU boolean type.
Definition: umachine.h:200
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:182