ICU 54.1 54.1

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

- File List
- Globals

All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
search.h
Go to the documentation of this file.
1 /*
2 **********************************************************************
3 * Copyright (C) 2001-2011 IBM and others. All rights reserved.
4 **********************************************************************
5 * Date Name Description
6 * 03/22/2000 helena Creation.
7 **********************************************************************
8 */
9
10 #ifndef SEARCH_H
11 #define SEARCH_H
12
13 #include "unicode/utypes.h"
14
20 #if !UCONFIG_NO_COLLATION && !UCONFIG_NO_BREAK_ITERATION
21
22 #include "unicode/uobject.h"
23 #include "unicode/unistr.h"
24 #include "unicode/chariter.h"
25 #include "unicode/brkiter.h"
26 #include "unicode/usearch.h"
27
31 struct USearch;
35 typedef struct USearch USearch;
36
37 U_NAMESPACE_BEGIN
38
79 class U_I18N_API SearchIterator : public UObject {
80
81 public:
82
83 // public constructors and destructors -------------------------------
84
91 SearchIterator(const SearchIterator &other);
92
97 virtual ~SearchIterator();
98
99 // public get and set methods ----------------------------------------
100
114 virtual void setOffset(int32_t position, UErrorCode &status) = 0;
115
124 virtual int32_t getOffset(void) const = 0;
125
135 void setAttribute(USearchAttribute attribute,
136 USearchAttributeValue value,
137 UErrorCode &status);
138
145 USearchAttributeValue getAttribute(USearchAttribute attribute) const;
146
163 int32_t getMatchedStart(void) const;
164
179 int32_t getMatchedLength(void) const;
180
195 void getMatchedText(UnicodeString &result) const;
196
212 void setBreakIterator(BreakIterator *breakiter, UErrorCode &status);
213
224 const BreakIterator * getBreakIterator(void) const;
225
236 virtual void setText(const UnicodeString &text, UErrorCode &status);
237
253 virtual void setText(CharacterIterator &text, UErrorCode &status);
254
260 const UnicodeString & getText(void) const;
261
262 // operator overloading ----------------------------------------------
263
272 virtual UBool operator==(const SearchIterator &that) const;
273
280 UBool operator!=(const SearchIterator &that) const;
281
282 // public methods ----------------------------------------------------
283
291 virtual SearchIterator* safeClone(void) const = 0;
292
306 int32_t first(UErrorCode &status);
307
325 int32_t following(int32_t position, UErrorCode &status);
326
340 int32_t last(UErrorCode &status);
341
365 int32_t preceding(int32_t position, UErrorCode &status);
366
381 int32_t next(UErrorCode &status);
382
396 int32_t previous(UErrorCode &status);
397
406 virtual void reset();
407
408 protected:
409 // protected data members ---------------------------------------------
410
415 USearch *m_search_;
416
425 BreakIterator *m_breakiterator_;
426
431 UnicodeString m_text_;
432
433 // protected constructors and destructors -----------------------------
434
440 SearchIterator();
441
457 SearchIterator(const UnicodeString &text,
458 BreakIterator *breakiter = NULL);
459
479 SearchIterator(CharacterIterator &text, BreakIterator *breakiter = NULL);
480
481 // protected methods --------------------------------------------------
482
489 SearchIterator & operator=(const SearchIterator &that);
490
510 virtual int32_t handleNext(int32_t position, UErrorCode &status)
511 = 0;
512
532 virtual int32_t handlePrev(int32_t position, UErrorCode &status)
533 = 0;
534
545 virtual void setMatchLength(int32_t length);
546
557 virtual void setMatchStart(int32_t position);
558
563 void setMatchNotFound();
564 };
565
566 inline UBool SearchIterator::operator!=(const SearchIterator &that) const
567 {
568 return !operator==(that);
569 }
570 U_NAMESPACE_END
571
572 #endif /* #if !UCONFIG_NO_COLLATION */
573
574 #endif
575