brkiter.h

Go to the documentation of this file.
00001 /*
00002 ********************************************************************************
00003 *   Copyright (C) 1997-2005, 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 
00052 U_NAMESPACE_BEGIN
00053 
00054 #if !UCONFIG_NO_SERVICE
00055 
00059 typedef const void* URegistryKey;
00060 #endif
00061 
00211 class U_COMMON_API BreakIterator : public UObject {
00212 public:
00217     virtual ~BreakIterator();
00218 
00232     virtual UBool operator==(const BreakIterator&) const = 0;
00233 
00240     UBool operator!=(const BreakIterator& rhs) const { return !operator==(rhs); }
00241 
00247     virtual BreakIterator* clone(void) const = 0;
00248 
00254     virtual UClassID getDynamicClassID(void) const = 0;
00255 
00262     virtual const CharacterIterator& getText(void) const = 0;
00263 
00264 
00279      virtual UText *getUText(UText *fillIn, UErrorCode &status) const = 0;
00280 
00287     virtual void  setText(const UnicodeString &text) = 0;
00288 
00302     virtual void  setText(UText *text, UErrorCode &status) = 0;
00303 
00310     virtual void  adoptText(CharacterIterator* it) = 0;
00311 
00312     enum {
00318         DONE = (int32_t)-1
00319     };
00320 
00325     virtual int32_t first(void) = 0;
00326 
00331     virtual int32_t last(void) = 0;
00332 
00339     virtual int32_t previous(void) = 0;
00340 
00347     virtual int32_t next(void) = 0;
00348 
00354     virtual int32_t current(void) const = 0;
00355 
00364     virtual int32_t following(int32_t offset) = 0;
00365 
00374     virtual int32_t preceding(int32_t offset) = 0;
00375 
00384     virtual UBool isBoundary(int32_t offset) = 0;
00385 
00395     virtual int32_t next(int32_t n) = 0;
00396 
00416     static BreakIterator* U_EXPORT2
00417     createWordInstance(const Locale& where, UErrorCode& status);
00418 
00440     static BreakIterator* U_EXPORT2
00441     createLineInstance(const Locale& where, UErrorCode& status);
00442 
00462     static BreakIterator* U_EXPORT2
00463     createCharacterInstance(const Locale& where, UErrorCode& status);
00464 
00483     static BreakIterator* U_EXPORT2
00484     createSentenceInstance(const Locale& where, UErrorCode& status);
00485 
00508     static BreakIterator* U_EXPORT2
00509     createTitleInstance(const Locale& where, UErrorCode& status);
00510 
00520     static const Locale* U_EXPORT2 getAvailableLocales(int32_t& count);
00521 
00531     static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale,
00532                                          const Locale& displayLocale,
00533                                          UnicodeString& name);
00534 
00543     static UnicodeString& U_EXPORT2 getDisplayName(const Locale& objectLocale,
00544                                          UnicodeString& name);
00545 
00563     virtual BreakIterator *  createBufferClone(void *stackBuffer,
00564                                                int32_t &BufferSize,
00565                                                UErrorCode &status) = 0;
00566 
00573     inline UBool isBufferClone(void);
00574 
00575 #if !UCONFIG_NO_SERVICE
00576 
00588     static URegistryKey U_EXPORT2 registerInstance(BreakIterator* toAdopt,
00589                                         const Locale& locale,
00590                                         UBreakIteratorType kind,
00591                                         UErrorCode& status);
00592 
00602     static UBool U_EXPORT2 unregister(URegistryKey key, UErrorCode& status);
00603 
00610     static StringEnumeration* U_EXPORT2 getAvailableLocales(void);
00611 #endif
00612 
00618     Locale getLocale(ULocDataLocaleType type, UErrorCode& status) const;
00619 
00626     const char *getLocaleID(ULocDataLocaleType type, UErrorCode& status) const;
00627 
00628  private:
00629     static BreakIterator* buildInstance(const Locale& loc, const char *type, UBool dict, UErrorCode& status);
00630     static BreakIterator* createInstance(const Locale& loc, UBreakIteratorType kind, UErrorCode& status);
00631     static BreakIterator* makeInstance(const Locale& loc, int32_t kind, UErrorCode& status);
00632 
00633     friend class ICUBreakIteratorFactory;
00634     friend class ICUBreakIteratorService;
00635 
00636 protected:
00638     BreakIterator();
00640     UBool fBufferClone;
00642     BreakIterator (const BreakIterator &other) : UObject(other), fBufferClone(FALSE) {}
00643 
00644 private:
00645 
00647     char actualLocale[ULOC_FULLNAME_CAPACITY];
00648     char validLocale[ULOC_FULLNAME_CAPACITY];
00649 
00654     BreakIterator& operator=(const BreakIterator&);
00655 };
00656 
00657 inline UBool BreakIterator::isBufferClone()
00658 {
00659     return fBufferClone;
00660 }
00661 
00662 U_NAMESPACE_END
00663 
00664 #endif /* #if !UCONFIG_NO_BREAK_ITERATION */
00665 
00666 #endif // _BRKITER
00667 //eof
00668 

Generated on Wed Jul 20 08:07:18 2005 for ICU 3.4 by  doxygen 1.4.2-20050421