|
ICU 73.2
73.2
|
00001 // © 2016 and later: Unicode, Inc. and others. 00002 // License & terms of use: http://www.unicode.org/copyright.html 00003 /* 00004 ********************************************************************** 00005 * Copyright (C) 2001-2011 IBM and others. All rights reserved. 00006 ********************************************************************** 00007 * Date Name Description 00008 * 03/22/2000 helena Creation. 00009 ********************************************************************** 00010 */ 00011 00012 #ifndef SEARCH_H 00013 #define SEARCH_H 00014 00015 #include "unicode/utypes.h" 00016 00017 #if U_SHOW_CPLUSPLUS_API 00018 00024 #if !UCONFIG_NO_COLLATION && !UCONFIG_NO_BREAK_ITERATION 00025 00026 #include "unicode/uobject.h" 00027 #include "unicode/unistr.h" 00028 #include "unicode/chariter.h" 00029 #include "unicode/brkiter.h" 00030 #include "unicode/usearch.h" 00031 00035 struct USearch; 00039 typedef struct USearch USearch; 00040 00041 U_NAMESPACE_BEGIN 00042 00082 class U_I18N_API SearchIterator : public UObject { 00083 00084 public: 00085 00086 // public constructors and destructors ------------------------------- 00087 00094 SearchIterator(const SearchIterator &other); 00095 00100 virtual ~SearchIterator(); 00101 00102 // public get and set methods ---------------------------------------- 00103 00117 virtual void setOffset(int32_t position, UErrorCode &status) = 0; 00118 00127 virtual int32_t getOffset(void) const = 0; 00128 00138 void setAttribute(USearchAttribute attribute, 00139 USearchAttributeValue value, 00140 UErrorCode &status); 00141 00148 USearchAttributeValue getAttribute(USearchAttribute attribute) const; 00149 00166 int32_t getMatchedStart(void) const; 00167 00182 int32_t getMatchedLength(void) const; 00183 00198 void getMatchedText(UnicodeString &result) const; 00199 00215 void setBreakIterator(BreakIterator *breakiter, UErrorCode &status); 00216 00227 const BreakIterator * getBreakIterator(void) const; 00228 00239 virtual void setText(const UnicodeString &text, UErrorCode &status); 00240 00256 virtual void setText(CharacterIterator &text, UErrorCode &status); 00257 00263 const UnicodeString & getText(void) const; 00264 00265 // operator overloading ---------------------------------------------- 00266 00275 virtual bool operator==(const SearchIterator &that) const; 00276 00283 bool operator!=(const SearchIterator &that) const; 00284 00285 // public methods ---------------------------------------------------- 00286 00294 virtual SearchIterator* safeClone(void) const = 0; 00295 00309 int32_t first(UErrorCode &status); 00310 00328 int32_t following(int32_t position, UErrorCode &status); 00329 00343 int32_t last(UErrorCode &status); 00344 00368 int32_t preceding(int32_t position, UErrorCode &status); 00369 00384 int32_t next(UErrorCode &status); 00385 00399 int32_t previous(UErrorCode &status); 00400 00409 virtual void reset(); 00410 00411 protected: 00412 // protected data members --------------------------------------------- 00413 00418 USearch *m_search_; 00419 00428 BreakIterator *m_breakiterator_; 00429 00434 UnicodeString m_text_; 00435 00436 // protected constructors and destructors ----------------------------- 00437 00443 SearchIterator(); 00444 00460 SearchIterator(const UnicodeString &text, 00461 BreakIterator *breakiter = nullptr); 00462 00482 SearchIterator(CharacterIterator &text, BreakIterator *breakiter = nullptr); 00483 00484 // protected methods -------------------------------------------------- 00485 00492 SearchIterator & operator=(const SearchIterator &that); 00493 00513 virtual int32_t handleNext(int32_t position, UErrorCode &status) 00514 = 0; 00515 00535 virtual int32_t handlePrev(int32_t position, UErrorCode &status) 00536 = 0; 00537 00548 virtual void setMatchLength(int32_t length); 00549 00560 virtual void setMatchStart(int32_t position); 00561 00566 void setMatchNotFound(); 00567 }; 00568 00569 inline bool SearchIterator::operator!=(const SearchIterator &that) const 00570 { 00571 return !operator==(that); 00572 } 00573 U_NAMESPACE_END 00574 00575 #endif /* #if !UCONFIG_NO_COLLATION */ 00576 00577 #endif /* U_SHOW_CPLUSPLUS_API */ 00578 00579 #endif 00580
1.7.6.1