Main Page   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Search  

search.h

Go to the documentation of this file.
00001 /*
00002 **********************************************************************
00003 *   Copyright (C) 2001 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 #include "unicode/uobject.h"
00015 #include "unicode/unistr.h"
00016 #include "unicode/chariter.h"
00017 #include "unicode/brkiter.h"
00018 #include "unicode/usearch.h"
00019 
00023 struct USearch;
00027 typedef struct USearch USearch;
00028 
00029 U_NAMESPACE_BEGIN
00030 
00070 class U_I18N_API SearchIterator : public UObject {
00071 
00072 public:
00073 
00074     // public constructors and destructors -------------------------------
00075 
00082     SearchIterator(const SearchIterator &other);
00083 
00088     virtual ~SearchIterator();
00089 
00090     // public get and set methods ----------------------------------------
00091 
00105     virtual void setOffset(int32_t position, UErrorCode &status) = 0;
00106 
00115     virtual int32_t getOffset(void) const = 0;
00116 
00126     void setAttribute(USearchAttribute       attribute,
00127                       USearchAttributeValue  value,
00128                       UErrorCode            &status);
00129 
00136     USearchAttributeValue getAttribute(USearchAttribute  attribute) const;
00137     
00154     int32_t getMatchedStart(void) const;
00155 
00170     int32_t getMatchedLength(void) const;
00171     
00186     void getMatchedText(UnicodeString &result) const;
00187     
00203     void setBreakIterator(BreakIterator *breakiter, UErrorCode &status);
00204     
00215     const BreakIterator * getBreakIterator(void) const;
00216 
00227     virtual void setText(const UnicodeString &text, UErrorCode &status);    
00228 
00244     virtual void setText(CharacterIterator &text, UErrorCode &status);
00245     
00251     const UnicodeString & getText(void) const;
00252 
00253     // operator overloading ----------------------------------------------
00254 
00263     virtual UBool operator==(const SearchIterator &that) const;
00264 
00271     UBool operator!=(const SearchIterator &that) const;
00272 
00273     // public methods ----------------------------------------------------
00274 
00282     virtual SearchIterator* safeClone(void) const = 0;
00283 
00297     int32_t first(UErrorCode &status);
00298 
00316     int32_t following(int32_t position, UErrorCode &status);
00317     
00331     int32_t last(UErrorCode &status);
00332 
00350     int32_t preceding(int32_t position, UErrorCode &status);
00351 
00366      int32_t next(UErrorCode &status);
00367 
00381     int32_t previous(UErrorCode &status);
00382 
00391     virtual void reset();
00392 
00393 protected:
00394     // protected data members ---------------------------------------------
00395 
00400     USearch *m_search_;
00401 
00410     BreakIterator *m_breakiterator_;
00411     
00416     UnicodeString  m_text_;
00417 
00418     // protected constructors and destructors -----------------------------
00419 
00425     SearchIterator();
00426 
00442     SearchIterator(const UnicodeString &text, 
00443                          BreakIterator *breakiter = NULL);
00444 
00464     SearchIterator(CharacterIterator &text, BreakIterator *breakiter = NULL);
00465 
00466     // protected methods --------------------------------------------------
00467 
00474     SearchIterator & operator=(const SearchIterator &that);
00475 
00495     virtual int32_t handleNext(int32_t position, UErrorCode &status) 
00496                                                                          = 0;
00497 
00517      virtual int32_t handlePrev(int32_t position, UErrorCode &status) 
00518                                                                          = 0;
00519 
00530     virtual void setMatchLength(int32_t length);
00531 
00542     virtual void setMatchStart(int32_t position);
00543 
00548     void setMatchNotFound();
00549 };
00550 
00551 inline UBool SearchIterator::operator!=(const SearchIterator &that) const
00552 {
00553    return !operator==(that); 
00554 }
00555 U_NAMESPACE_END
00556 
00557 #endif
00558 

Generated on Thu Aug 15 14:13:28 2002 for ICU 2.2 by doxygen1.2.11.1 written by Dimitri van Heesch, © 1997-2001