ICU 49.1.1  49.1.1
brkiter.h
Go to the documentation of this file.
00001 /*
00002 ********************************************************************************
00003 *   Copyright (C) 1997-2011, International Business Machines
00004 *   Corporation and others.  All Rights Reserved.
00005 ********************************************************************************
00006 *
00007 * File brkiter.h
00008 *
00009 * Modification History:
00010 *
00011 *   Date        Name        Description
00012 *   02/18/97    aliu        Added typedef for TextCount.  Made DONE const.
00013 *   05/07/97    aliu        Fixed DLL declaration.
00014 *   07/09/97    jfitz       Renamed BreakIterator and interface synced with JDK
00015 *   08/11/98    helena      Sync-up JDK1.2.
00016 *   01/13/2000  helena      Added UErrorCode parameter to createXXXInstance methods.
00017 ********************************************************************************
00018 */
00019 
00020 #ifndef BRKITER_H
00021 #define BRKITER_H
00022 
00023 #include "unicode/utypes.h"
00024 
00030 #if UCONFIG_NO_BREAK_ITERATION
00031 
00032 U_NAMESPACE_BEGIN
00033 
00034 /*
00035  * Allow the declaration of APIs with pointers to BreakIterator
00036  * even when break iteration is removed from the build.
00037  */
00038 class BreakIterator;
00039 
00040 U_NAMESPACE_END
00041 
00042 #else
00043 
00044 #include "unicode/uobject.h"
00045 #include "unicode/unistr.h"
00046 #include "unicode/chariter.h"
00047 #include "unicode/locid.h"
00048 #include "unicode/ubrk.h"
00049 #include "unicode/strenum.h"
00050 #include "unicode/utext.h"
00051 #include "unicode/umisc.h"
00052 
00053 U_NAMESPACE_BEGIN
00054 
00100 class U_COMMON_API BreakIterator : public UObject {
00101 public:
00106     virtual ~BreakIterator();
00107 
00121     virtual UBool operator==(const BreakIterator&) const = 0;
00122 
00129     UBool operator!=(const BreakIterator& rhs) const { return !operator==(rhs); }
00130 
00136     virtual BreakIterator* clone(void) const = 0;
00137 
00143     virtual UClassID getDynamicClassID(void) const = 0;
00144 
00149     virtual CharacterIterator& getText(void) const = 0;
00150 
00151 
00166      virtual UText *getUText(UText *fillIn, UErrorCode &status) const = 0;
00167 
00174     virtual void  setText(const UnicodeString &text) = 0;
00175 
00189     virtual void  setText(UText *text, UErrorCode &status) = 0;
00190 
00199     virtual void  adoptText(CharacterIterator* it) = 0;
00200 
00201     enum {
00207         DONE = (int32_t)-1
00208     };
00209 
00214     virtual int32_t first(void) = 0;
00215 
00220     virtual int32_t last(void) = 0;
00221 
00228     virtual int32_t previous(void) = 0;
00229 
00236     virtual int32_t next(void) = 0;
00237 
00243     virtual int32_t current(void) const = 0;
00244 
00253     virtual int32_t following(int32_t offset) = 0;
00254 
00263     virtual int32_t preceding(int32_t offset) = 0;
00264 
00273     virtual UBool isBoundary(int32_t offset) = 0;
00274 
00284     virtual int32_t next(int32_t n) = 0;
00285 
00305     static BreakIterator* U_EXPORT2
00306     createWordInstance(const Locale& where, UErrorCode& status);
00307 
00329     static BreakIterator* U_EXPORT2
00330     createLineInstance(const Locale& where, UErrorCode& status);
00331 
00351     static BreakIterator* U_EXPORT2
00352     createCharacterInstance(const Locale& where, UErrorCode& status);
00353 
00372     static BreakIterator* U_EXPORT2
00373     createSentenceInstance(const Locale& where, UErrorCode& status);
00374 
00397     static BreakIterator* U_EXPORT2
00398     createTitleInstance(const Locale& where, UErrorCode& status);
00399 
00409     static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);
00410 
00420     static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale,
00421                                          const Locale& displayLocale,
00422                                          UnicodeString& name);
00423 
00432     static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale,
00433                                          UnicodeString& name);
00434 
00452     virtual BreakIterator *  createBufferClone(void *stackBuffer,
00453                                                int32_t &BufferSize,
00454                                                UErrorCode &status) = 0;
00455 
00462     inline UBool isBufferClone(void);
00463 
00464 #if !UCONFIG_NO_SERVICE
00465 
00477     static URegistryKey U_EXPORT2 registerInstance(BreakIterator* toAdopt,
00478                                         const Locale& locale,
00479                                         UBreakIteratorType kind,
00480                                         UErrorCode& status);
00481 
00491     static UBool U_EXPORT2 unregister(URegistryKey key, UErrorCode& status);
00492 
00499     static StringEnumeration* U_EXPORT2 getAvailableLocales(void);
00500 #endif
00501 
00507     Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
00508 
00509 #ifndef U_HIDE_INTERNAL_API
00510 
00516     const char *getLocaleID(ULocDataLocaleType type, UErrorCode& status) const;
00517 #endif  /* U_HIDE_INTERNAL_API */
00518 
00544     virtual BreakIterator &refreshInputText(UText *input, UErrorCode &status) = 0;
00545 
00546  private:
00547     static BreakIterator* buildInstance(const Locale& loc, const char *type, int32_t kind, UErrorCode& status);
00548     static BreakIterator* createInstance(const Locale& loc, int32_t kind, UErrorCode& status);
00549     static BreakIterator* makeInstance(const Locale& loc, int32_t kind, UErrorCode& status);
00550 
00551     friend class ICUBreakIteratorFactory;
00552     friend class ICUBreakIteratorService;
00553 
00554 protected:
00555     // Do not enclose protected default/copy constructors with #ifndef U_HIDE_INTERNAL_API
00556     // or else the compiler will create a public ones.
00558     BreakIterator();
00560     UBool fBufferClone;
00562     BreakIterator (const BreakIterator &other) : UObject(other), fBufferClone(FALSE) {}
00563 
00564 private:
00565 
00567     char actualLocale[ULOC_FULLNAME_CAPACITY];
00568     char validLocale[ULOC_FULLNAME_CAPACITY];
00569 
00574     BreakIterator& operator=(const BreakIterator&);
00575 };
00576 
00577 inline UBool BreakIterator::isBufferClone()
00578 {
00579     return fBufferClone;
00580 }
00581 
00582 U_NAMESPACE_END
00583 
00584 #endif /* #if !UCONFIG_NO_BREAK_ITERATION */
00585 
00586 #endif // _BRKITER
00587 //eof
00588