Main Page | Class Hierarchy | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

search.h

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/unistr.h"
00014 #include "unicode/chariter.h"
00015 #include "unicode/brkiter.h"
00016 #include "unicode/usearch.h"
00017 
00018 struct USearch;
00019 typedef struct USearch USearch;
00020 
00021 U_NAMESPACE_BEGIN
00022 
00061 class U_I18N_API SearchIterator {
00062 
00063 public:
00064 
00065     // public constructors and destructors -------------------------------
00066 
00073     SearchIterator(const SearchIterator &other);
00074 
00079     virtual ~SearchIterator();
00080 
00081     // public get and set methods ----------------------------------------
00082 
00094     virtual void setOffset(int32_t position, UErrorCode &status) = 0;
00095 
00104     virtual int32_t getOffset(void) const = 0;
00105 
00115     void setAttribute(USearchAttribute       attribute,
00116                       USearchAttributeValue  value,
00117                       UErrorCode            &status);
00118 
00125     USearchAttributeValue getAttribute(USearchAttribute  attribute) const;
00126     
00139     int32_t getMatchedStart(void) const;
00140 
00151     int32_t getMatchedLength(void) const;
00152     
00163     void getMatchedText(UnicodeString &result) const;
00164     
00179     void setBreakIterator(BreakIterator *breakiter, UErrorCode &status);
00180     
00190     const BreakIterator * getBreakIterator(void) const;
00191 
00202     virtual void setText(const UnicodeString &text, UErrorCode &status);    
00203 
00219     virtual void setText(CharacterIterator &text, UErrorCode &status);
00220     
00226     const UnicodeString & getText(void) const;
00227 
00228     // operator overloading ----------------------------------------------
00229 
00238     virtual UBool operator==(const SearchIterator &that) const;
00239 
00246     UBool operator!=(const SearchIterator &that) const;
00247 
00248     // public methods ----------------------------------------------------
00249 
00257     virtual SearchIterator* safeClone(void) const = 0;
00258 
00271     int32_t first(UErrorCode &status);
00272 
00287     int32_t following(int32_t position, UErrorCode &status);
00288     
00301     int32_t last(UErrorCode &status);
00302 
00317     int32_t preceding(int32_t position, UErrorCode &status);
00318 
00332      int32_t next(UErrorCode &status);
00333 
00346     int32_t previous(UErrorCode &status);
00347 
00356     virtual void reset();
00357 
00358 protected:
00359     // protected data members ---------------------------------------------
00360 
00364     USearch *m_search_;
00365 
00373     BreakIterator *m_breakiterator_;
00374     
00378     UnicodeString  m_text_;
00379 
00380     // protected constructors and destructors -----------------------------
00381 
00386     SearchIterator();
00387 
00400     SearchIterator(const UnicodeString &text, 
00401                          BreakIterator *breakiter = NULL);
00402 
00419     SearchIterator(CharacterIterator &text, BreakIterator *breakiter = NULL);
00420 
00421     // protected methods --------------------------------------------------
00422 
00428     SearchIterator & operator=(const SearchIterator &that);
00429 
00447     virtual int32_t handleNext(int32_t position, UErrorCode &status) 
00448                                                                          = 0;
00449 
00467      virtual int32_t handlePrev(int32_t position, UErrorCode &status) 
00468                                                                          = 0;
00469 
00477     virtual void setMatchLength(int32_t length);
00478 
00486     virtual void setMatchStart(int32_t position);
00487 
00491     void setMatchNotFound();
00492 };
00493 
00494 inline UBool SearchIterator::operator!=(const SearchIterator &that) const
00495 {
00496    return !operator==(that); 
00497 }
00498 U_NAMESPACE_END
00499 
00500 #endif
00501 

Generated on Wed Nov 17 21:02:04 2004 for ICU 2.1 by  doxygen 1.3.9.1