brkiter.h

Go to the documentation of this file.
00001 /*
00002 ********************************************************************************
00003 *   Copyright (C) 1997-2012, 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 
00215     virtual int32_t first(void) = 0;
00216 
00222     virtual int32_t last(void) = 0;
00223 
00230     virtual int32_t previous(void) = 0;
00231 
00238     virtual int32_t next(void) = 0;
00239 
00245     virtual int32_t current(void) const = 0;
00246 
00255     virtual int32_t following(int32_t offset) = 0;
00256 
00265     virtual int32_t preceding(int32_t offset) = 0;
00266 
00275     virtual UBool isBoundary(int32_t offset) = 0;
00276 
00286     virtual int32_t next(int32_t n) = 0;
00287 
00307     static BreakIterator* U_EXPORT2
00308     createWordInstance(const Locale& where, UErrorCode& status);
00309 
00331     static BreakIterator* U_EXPORT2
00332     createLineInstance(const Locale& where, UErrorCode& status);
00333 
00353     static BreakIterator* U_EXPORT2
00354     createCharacterInstance(const Locale& where, UErrorCode& status);
00355 
00374     static BreakIterator* U_EXPORT2
00375     createSentenceInstance(const Locale& where, UErrorCode& status);
00376 
00399     static BreakIterator* U_EXPORT2
00400     createTitleInstance(const Locale& where, UErrorCode& status);
00401 
00411     static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);
00412 
00422     static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale,
00423                                          const Locale& displayLocale,
00424                                          UnicodeString& name);
00425 
00434     static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale,
00435                                          UnicodeString& name);
00436 
00454     virtual BreakIterator *  createBufferClone(void *stackBuffer,
00455                                                int32_t &BufferSize,
00456                                                UErrorCode &status) = 0;
00457 
00464     inline UBool isBufferClone(void);
00465 
00466 #if !UCONFIG_NO_SERVICE
00467 
00479     static URegistryKey U_EXPORT2 registerInstance(BreakIterator* toAdopt,
00480                                         const Locale& locale,
00481                                         UBreakIteratorType kind,
00482                                         UErrorCode& status);
00483 
00493     static UBool U_EXPORT2 unregister(URegistryKey key, UErrorCode& status);
00494 
00501     static StringEnumeration* U_EXPORT2 getAvailableLocales(void);
00502 #endif
00503 
00509     Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
00510 
00511 #ifndef U_HIDE_INTERNAL_API
00512 
00518     const char *getLocaleID(ULocDataLocaleType type, UErrorCode& status) const;
00519 #endif  /* U_HIDE_INTERNAL_API */
00520 
00546     virtual BreakIterator &refreshInputText(UText *input, UErrorCode &status) = 0;
00547 
00548  private:
00549     static BreakIterator* buildInstance(const Locale& loc, const char *type, int32_t kind, UErrorCode& status);
00550     static BreakIterator* createInstance(const Locale& loc, int32_t kind, UErrorCode& status);
00551     static BreakIterator* makeInstance(const Locale& loc, int32_t kind, UErrorCode& status);
00552 
00553     friend class ICUBreakIteratorFactory;
00554     friend class ICUBreakIteratorService;
00555 
00556 protected:
00557     // Do not enclose protected default/copy constructors with #ifndef U_HIDE_INTERNAL_API
00558     // or else the compiler will create a public ones.
00560     BreakIterator();
00562     UBool fBufferClone;
00564     BreakIterator (const BreakIterator &other) : UObject(other), fBufferClone(FALSE) {}
00565 
00566 private:
00567 
00569     char actualLocale[ULOC_FULLNAME_CAPACITY];
00570     char validLocale[ULOC_FULLNAME_CAPACITY];
00571 
00576     BreakIterator& operator=(const BreakIterator&);
00577 };
00578 
00579 inline UBool BreakIterator::isBufferClone()
00580 {
00581     return fBufferClone;
00582 }
00583 
00584 U_NAMESPACE_END
00585 
00586 #endif /* #if !UCONFIG_NO_BREAK_ITERATION */
00587 
00588 #endif // _BRKITER
00589 //eof
00590 

Generated on 27 Oct 2013 for ICU 50.1.2 by  doxygen 1.4.7