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

- Search for |

- File List
- Globals

# search.h

Go to the documentation of this file.

    00001 /*
    00002 **********************************************************************
    00003 *   Copyright (C) 2001-2005 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
    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
    00359     int32_t preceding(int32_t position, UErrorCode &status);
    00360
    00375      int32_t next(UErrorCode &status);
    00376
    00390     int32_t previous(UErrorCode &status);
    00391
    00400     virtual void reset();
    00401
    00402 protected:
    00403     // protected data members ---------------------------------------------
    00404
    00409     USearch *m_search_;
    00410
    00419     BreakIterator *m_breakiterator_;
    00420
    00425     UnicodeString  m_text_;
    00426
    00427     // protected constructors and destructors -----------------------------
    00428
    00434     SearchIterator();
    00435
    00451     SearchIterator(const UnicodeString &text,
    00452                          BreakIterator *breakiter = NULL);
    00453
    00473     SearchIterator(CharacterIterator &text, BreakIterator *breakiter = NULL);
    00474
    00475     // protected methods --------------------------------------------------
    00476
    00483     SearchIterator & operator=(const SearchIterator &that);
    00484
    00504     virtual int32_t handleNext(int32_t position, UErrorCode &status)
    00505                                                                          = 0;
    00506
    00526      virtual int32_t handlePrev(int32_t position, UErrorCode &status)
    00527                                                                          = 0;
    00528
    00539     virtual void setMatchLength(int32_t length);
    00540
    00551     virtual void setMatchStart(int32_t position);
    00552
    00557     void setMatchNotFound();
    00558 };
    00559
    00560 inline UBool SearchIterator::operator!=(const SearchIterator &that) const
    00561 {
    00562    return !operator==(that);
    00563 }
    00564 U_NAMESPACE_END
    00565
    00566 #endif /* #if !UCONFIG_NO_COLLATION */
    00567
    00568 #endif
    00569