ICU 51.2  51.2
brkiter.h
Go to the documentation of this file.
1 /*
2 ********************************************************************************
3 * Copyright (C) 1997-2013, 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 
194  virtual void setText(UText *text, UErrorCode &status) = 0;
195 
204  virtual void adoptText(CharacterIterator* it) = 0;
205 
206  enum {
212  DONE = (int32_t)-1
213  };
214 
220  virtual int32_t first(void) = 0;
221 
227  virtual int32_t last(void) = 0;
228 
235  virtual int32_t previous(void) = 0;
236 
243  virtual int32_t next(void) = 0;
244 
250  virtual int32_t current(void) const = 0;
251 
260  virtual int32_t following(int32_t offset) = 0;
261 
270  virtual int32_t preceding(int32_t offset) = 0;
271 
280  virtual UBool isBoundary(int32_t offset) = 0;
281 
291  virtual int32_t next(int32_t n) = 0;
292 
312  static BreakIterator* U_EXPORT2
313  createWordInstance(const Locale& where, UErrorCode& status);
314 
336  static BreakIterator* U_EXPORT2
337  createLineInstance(const Locale& where, UErrorCode& status);
338 
358  static BreakIterator* U_EXPORT2
359  createCharacterInstance(const Locale& where, UErrorCode& status);
360 
379  static BreakIterator* U_EXPORT2
380  createSentenceInstance(const Locale& where, UErrorCode& status);
381 
404  static BreakIterator* U_EXPORT2
405  createTitleInstance(const Locale& where, UErrorCode& status);
406 
416  static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);
417 
427  static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale,
428  const Locale& displayLocale,
429  UnicodeString& name);
430 
439  static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale,
440  UnicodeString& name);
441 
459  virtual BreakIterator * createBufferClone(void *stackBuffer,
460  int32_t &BufferSize,
461  UErrorCode &status) = 0;
462 
469  inline UBool isBufferClone(void);
470 
471 #if !UCONFIG_NO_SERVICE
472 
484  static URegistryKey U_EXPORT2 registerInstance(BreakIterator* toAdopt,
485  const Locale& locale,
486  UBreakIteratorType kind,
487  UErrorCode& status);
488 
498  static UBool U_EXPORT2 unregister(URegistryKey key, UErrorCode& status);
499 
506  static StringEnumeration* U_EXPORT2 getAvailableLocales(void);
507 #endif
508 
514  Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
515 
516 #ifndef U_HIDE_INTERNAL_API
517 
523  const char *getLocaleID(ULocDataLocaleType type, UErrorCode& status) const;
524 #endif /* U_HIDE_INTERNAL_API */
525 
551  virtual BreakIterator &refreshInputText(UText *input, UErrorCode &status) = 0;
552 
553  private:
554  static BreakIterator* buildInstance(const Locale& loc, const char *type, int32_t kind, UErrorCode& status);
555  static BreakIterator* createInstance(const Locale& loc, int32_t kind, UErrorCode& status);
556  static BreakIterator* makeInstance(const Locale& loc, int32_t kind, UErrorCode& status);
557 
558  friend class ICUBreakIteratorFactory;
559  friend class ICUBreakIteratorService;
560 
561 protected:
562  // Do not enclose protected default/copy constructors with #ifndef U_HIDE_INTERNAL_API
563  // or else the compiler will create a public ones.
565  BreakIterator();
569  BreakIterator (const BreakIterator &other) : UObject(other), fBufferClone(FALSE) {}
570 
571 private:
572 
574  char actualLocale[ULOC_FULLNAME_CAPACITY];
575  char validLocale[ULOC_FULLNAME_CAPACITY];
576 
581  BreakIterator& operator=(const BreakIterator&);
582 };
583 
584 inline UBool BreakIterator::isBufferClone()
585 {
586  return fBufferClone;
587 }
588 
590 
591 #endif /* #if !UCONFIG_NO_BREAK_ITERATION */
592 
593 #endif // _BRKITER
594 //eof
595