- Main Page
- Modules
- Data Structures
- Files
- Related Pages

- Search for |

- File List
- Globals

# brkiter.h

Go to the documentation of this file.

    00001 /*
    00002 ********************************************************************************
    00003 *   Copyright (C) 1997-2007, 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
    00515     const char *getLocaleID(ULocDataLocaleType type, UErrorCode& status) const;
    00516
    00517  private:
    00518     static BreakIterator* buildInstance(const Locale& loc, const char *type, int32_t kind, UErrorCode& status);
    00519     static BreakIterator* createInstance(const Locale& loc, int32_t kind, UErrorCode& status);
    00520     static BreakIterator* makeInstance(const Locale& loc, int32_t kind, UErrorCode& status);
    00521
    00522     friend class ICUBreakIteratorFactory;
    00523     friend class ICUBreakIteratorService;
    00524
    00525 protected:
    00527     BreakIterator();
    00529     UBool fBufferClone;
    00531     BreakIterator (const BreakIterator &other) : UObject(other), fBufferClone(FALSE) {}
    00532
    00533 private:
    00534
    00536     char actualLocale[ULOC_FULLNAME_CAPACITY];
    00537     char validLocale[ULOC_FULLNAME_CAPACITY];
    00538
    00543     BreakIterator& operator=(const BreakIterator&);
    00544 };
    00545
    00546 inline UBool BreakIterator::isBufferClone()
    00547 {
    00548     return fBufferClone;
    00549 }
    00550
    00551 U_NAMESPACE_END
    00552
    00553 #endif /* #if !UCONFIG_NO_BREAK_ITERATION */
    00554
    00555 #endif // _BRKITER
    00556 //eof
    00557