ICU 4.8.1.1  4.8.1.1
search.h
Go to the documentation of this file.
00001 /*
00002 **********************************************************************
00003 *   Copyright (C) 2001-2011 IBM and others. All rights reserved.
00004 **********************************************************************
00005 *   Date        Name        Description
00006 *  03/22/2000   helena      Creation.
00007 **********************************************************************
00008 */
00009 
00010 #ifndef SEARCH_H
00011 #define SEARCH_H
00012 
00013 #include "unicode/utypes.h"
00014 
00020 #if !UCONFIG_NO_COLLATION && !UCONFIG_NO_BREAK_ITERATION
00021 
00022 #include "unicode/uobject.h"
00023 #include "unicode/unistr.h"
00024 #include "unicode/chariter.h"
00025 #include "unicode/brkiter.h"
00026 #include "unicode/usearch.h"
00027 
00031 struct USearch;
00035 typedef struct USearch USearch;
00036 
00037 U_NAMESPACE_BEGIN
00038 
00079 class U_I18N_API SearchIterator : public UObject {
00080 
00081 public:
00082 
00083     // public constructors and destructors -------------------------------
00084 
00091     SearchIterator(const SearchIterator &other);
00092 
00097     virtual ~SearchIterator();
00098 
00099     // public get and set methods ----------------------------------------
00100 
00114     virtual void setOffset(int32_t position, UErrorCode &status) = 0;
00115 
00124     virtual int32_t getOffset(void) const = 0;
00125 
00135     void setAttribute(USearchAttribute       attribute,
00136                       USearchAttributeValue  value,
00137                       UErrorCode            &status);
00138 
00145     USearchAttributeValue getAttribute(USearchAttribute  attribute) const;
00146     
00163     int32_t getMatchedStart(void) const;
00164 
00179     int32_t getMatchedLength(void) const;
00180     
00195     void getMatchedText(UnicodeString &result) const;
00196     
00212     void setBreakIterator(BreakIterator *breakiter, UErrorCode &status);
00213     
00224     const BreakIterator * getBreakIterator(void) const;
00225 
00236     virtual void setText(const UnicodeString &text, UErrorCode &status);    
00237 
00253     virtual void setText(CharacterIterator &text, UErrorCode &status);
00254     
00260     const UnicodeString & getText(void) const;
00261 
00262     // operator overloading ----------------------------------------------
00263 
00272     virtual UBool operator==(const SearchIterator &that) const;
00273 
00280     UBool operator!=(const SearchIterator &that) const;
00281 
00282     // public methods ----------------------------------------------------
00283 
00291     virtual SearchIterator* safeClone(void) const = 0;
00292 
00306     int32_t first(UErrorCode &status);
00307 
00325     int32_t following(int32_t position, UErrorCode &status);
00326     
00340     int32_t last(UErrorCode &status);
00341 
00365     int32_t preceding(int32_t position, UErrorCode &status);
00366 
00381      int32_t next(UErrorCode &status);
00382 
00396     int32_t previous(UErrorCode &status);
00397 
00406     virtual void reset();
00407 
00408 protected:
00409     // protected data members ---------------------------------------------
00410 
00415     USearch *m_search_;
00416 
00425     BreakIterator *m_breakiterator_;
00426     
00431     UnicodeString  m_text_;
00432 
00433     // protected constructors and destructors -----------------------------
00434 
00440     SearchIterator();
00441 
00457     SearchIterator(const UnicodeString &text, 
00458                          BreakIterator *breakiter = NULL);
00459 
00479     SearchIterator(CharacterIterator &text, BreakIterator *breakiter = NULL);
00480 
00481     // protected methods --------------------------------------------------
00482 
00489     SearchIterator & operator=(const SearchIterator &that);
00490 
00510     virtual int32_t handleNext(int32_t position, UErrorCode &status) 
00511                                                                          = 0;
00512 
00532      virtual int32_t handlePrev(int32_t position, UErrorCode &status) 
00533                                                                          = 0;
00534 
00545     virtual void setMatchLength(int32_t length);
00546 
00557     virtual void setMatchStart(int32_t position);
00558 
00563     void setMatchNotFound();
00564 };
00565 
00566 inline UBool SearchIterator::operator!=(const SearchIterator &that) const
00567 {
00568    return !operator==(that); 
00569 }
00570 U_NAMESPACE_END
00571 
00572 #endif /* #if !UCONFIG_NO_COLLATION */
00573 
00574 #endif
00575 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Friends Defines