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

search.h

00001 /*
00002 **********************************************************************
00003 *   Copyright (C) 2001-2003 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 
00015 #if !UCONFIG_NO_COLLATION
00016 
00017 #include "unicode/uobject.h"
00018 #include "unicode/unistr.h"
00019 #include "unicode/chariter.h"
00020 #include "unicode/brkiter.h"
00021 #include "unicode/usearch.h"
00022 
00026 struct USearch;
00030 typedef struct USearch USearch;
00031 
00032 U_NAMESPACE_BEGIN
00033 
00073 class U_I18N_API SearchIterator : public UObject {
00074 
00075 public:
00076 
00077     // public constructors and destructors -------------------------------
00078 
00085     SearchIterator(const SearchIterator &other);
00086 
00091     virtual ~SearchIterator();
00092 
00093     // public get and set methods ----------------------------------------
00094 
00108     virtual void setOffset(int32_t position, UErrorCode &status) = 0;
00109 
00118     virtual int32_t getOffset(void) const = 0;
00119 
00129     void setAttribute(USearchAttribute       attribute,
00130                       USearchAttributeValue  value,
00131                       UErrorCode            &status);
00132 
00139     USearchAttributeValue getAttribute(USearchAttribute  attribute) const;
00140     
00157     int32_t getMatchedStart(void) const;
00158 
00173     int32_t getMatchedLength(void) const;
00174     
00189     void getMatchedText(UnicodeString &result) const;
00190     
00206     void setBreakIterator(BreakIterator *breakiter, UErrorCode &status);
00207     
00218     const BreakIterator * getBreakIterator(void) const;
00219 
00230     virtual void setText(const UnicodeString &text, UErrorCode &status);    
00231 
00247     virtual void setText(CharacterIterator &text, UErrorCode &status);
00248     
00254     const UnicodeString & getText(void) const;
00255 
00256     // operator overloading ----------------------------------------------
00257 
00266     virtual UBool operator==(const SearchIterator &that) const;
00267 
00274     UBool operator!=(const SearchIterator &that) const;
00275 
00276     // public methods ----------------------------------------------------
00277 
00285     virtual SearchIterator* safeClone(void) const = 0;
00286 
00300     int32_t first(UErrorCode &status);
00301 
00319     int32_t following(int32_t position, UErrorCode &status);
00320     
00334     int32_t last(UErrorCode &status);
00335 
00353     int32_t preceding(int32_t position, UErrorCode &status);
00354 
00369      int32_t next(UErrorCode &status);
00370 
00384     int32_t previous(UErrorCode &status);
00385 
00394     virtual void reset();
00395 
00396 protected:
00397     // protected data members ---------------------------------------------
00398 
00403     USearch *m_search_;
00404 
00413     BreakIterator *m_breakiterator_;
00414     
00419     UnicodeString  m_text_;
00420 
00421     // protected constructors and destructors -----------------------------
00422 
00428     SearchIterator();
00429 
00445     SearchIterator(const UnicodeString &text, 
00446                          BreakIterator *breakiter = NULL);
00447 
00467     SearchIterator(CharacterIterator &text, BreakIterator *breakiter = NULL);
00468 
00469     // protected methods --------------------------------------------------
00470 
00477     SearchIterator & operator=(const SearchIterator &that);
00478 
00498     virtual int32_t handleNext(int32_t position, UErrorCode &status) 
00499                                                                          = 0;
00500 
00520      virtual int32_t handlePrev(int32_t position, UErrorCode &status) 
00521                                                                          = 0;
00522 
00533     virtual void setMatchLength(int32_t length);
00534 
00545     virtual void setMatchStart(int32_t position);
00546 
00551     void setMatchNotFound();
00552 };
00553 
00554 inline UBool SearchIterator::operator!=(const SearchIterator &that) const
00555 {
00556    return !operator==(that); 
00557 }
00558 U_NAMESPACE_END
00559 
00560 #endif /* #if !UCONFIG_NO_COLLATION */
00561 
00562 #endif
00563 

Generated on Wed May 18 17:29:14 2005 for ICU 2.8 by  doxygen 1.4.2