ICU 62.1  62.1
stsearch.h
Go to the documentation of this file.
1 // © 2016 and later: Unicode, Inc. and others.
2 // License & terms of use: http://www.unicode.org/copyright.html
3 /*
4 **********************************************************************
5 * Copyright (C) 2001-2014 IBM and others. All rights reserved.
6 **********************************************************************
7 * Date Name Description
8 * 03/22/2000 helena Creation.
9 **********************************************************************
10 */
11 
12 #ifndef STSEARCH_H
13 #define STSEARCH_H
14 
15 #include "unicode/utypes.h"
16 
22 #if !UCONFIG_NO_COLLATION && !UCONFIG_NO_BREAK_ITERATION
23 
24 #include "unicode/tblcoll.h"
25 #include "unicode/coleitr.h"
26 #include "unicode/search.h"
27 
29 
134 class U_I18N_API StringSearch U_FINAL : public SearchIterator
135 {
136 public:
137 
138  // public constructors and destructors --------------------------------
139 
161  StringSearch(const UnicodeString &pattern, const UnicodeString &text,
162  const Locale &locale,
163  BreakIterator *breakiter,
164  UErrorCode &status);
165 
187  StringSearch(const UnicodeString &pattern,
188  const UnicodeString &text,
189  RuleBasedCollator *coll,
190  BreakIterator *breakiter,
191  UErrorCode &status);
192 
218  StringSearch(const UnicodeString &pattern, CharacterIterator &text,
219  const Locale &locale,
220  BreakIterator *breakiter,
221  UErrorCode &status);
222 
248  StringSearch(const UnicodeString &pattern, CharacterIterator &text,
249  RuleBasedCollator *coll,
250  BreakIterator *breakiter,
251  UErrorCode &status);
252 
259  StringSearch(const StringSearch &that);
260 
266  virtual ~StringSearch(void);
267 
279  StringSearch *clone() const;
280 
281  // operator overloading ---------------------------------------------
282 
289  StringSearch & operator=(const StringSearch &that);
290 
299  virtual UBool operator==(const SearchIterator &that) const;
300 
301  // public get and set methods ----------------------------------------
302 
316  virtual void setOffset(int32_t position, UErrorCode &status);
317 
326  virtual int32_t getOffset(void) const;
327 
339  virtual void setText(const UnicodeString &text, UErrorCode &status);
340 
355  virtual void setText(CharacterIterator &text, UErrorCode &status);
356 
366  RuleBasedCollator * getCollator() const;
367 
376  void setCollator(RuleBasedCollator *coll, UErrorCode &status);
377 
386  void setPattern(const UnicodeString &pattern, UErrorCode &status);
387 
393  const UnicodeString & getPattern() const;
394 
395  // public methods ----------------------------------------------------
396 
405  virtual void reset();
406 
415  virtual SearchIterator * safeClone(void) const;
416 
422  virtual UClassID getDynamicClassID() const;
423 
429  static UClassID U_EXPORT2 getStaticClassID();
430 
431 protected:
432 
433  // protected method -------------------------------------------------
434 
457  virtual int32_t handleNext(int32_t position, UErrorCode &status);
458 
481  virtual int32_t handlePrev(int32_t position, UErrorCode &status);
482 
483 private :
484  StringSearch(); // default constructor not implemented
485 
486  // private data members ----------------------------------------------
487 
492  UnicodeString m_pattern_;
497  UStringSearch *m_strsrch_;
498 
499 };
500 
502 
503 #endif /* #if !UCONFIG_NO_COLLATION */
504 
505 #endif
506 
icu::BreakIterator
The BreakIterator class implements methods for finding the location of boundaries in text.
Definition: brkiter.h:102
icu::SearchIterator
SearchIterator is an abstract base class that provides methods to search for a pattern within a text ...
Definition: search.h:81
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
U_I18N_API
#define U_I18N_API
Definition: utypes.h:360
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:236
coleitr.h
C++ API: Collation Element Iterator.
icu::SearchIterator::reset
virtual void reset()
Resets the iteration.
icu::SearchIterator::setText
virtual void setText(const UnicodeString &text, UErrorCode &status)
Set the string text to be searched.
tblcoll.h
C++ API: The RuleBasedCollator class implements the Collator abstract base class.
icu::SearchIterator::setOffset
virtual void setOffset(int32_t position, UErrorCode &status)=0
Sets the index to point to the given position, and clears any state that's affected.
icu::StringSearch
StringSearch is a SearchIterator that provides language-sensitive text searching based on the compari...
Definition: stsearch.h:134
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:286
icu::SearchIterator::operator==
virtual UBool operator==(const SearchIterator &that) const
Equality operator.
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:93
UErrorCode
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers,...
Definition: utypes.h:396
icu::UObject::getDynamicClassID
virtual UClassID getDynamicClassID() const
ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.
icu::RuleBasedCollator
The RuleBasedCollator class provides the implementation of Collator, using data-driven tables.
Definition: tblcoll.h:113
icu::SearchIterator::handleNext
virtual int32_t handleNext(int32_t position, UErrorCode &status)=0
Abstract method which subclasses override to provide the mechanism for finding the next match in the ...
icu::SearchIterator::handlePrev
virtual int32_t handlePrev(int32_t position, UErrorCode &status)=0
Abstract method which subclasses override to provide the mechanism for finding the previous match in ...
icu::CharacterIterator
Abstract class that defines an API for iteration on text objects.
Definition: chariter.h:358
icu::SearchIterator::getOffset
virtual int32_t getOffset(void) const =0
Return the current index in the text being searched.
UStringSearch
struct UStringSearch UStringSearch
Data structure for searching.
Definition: usearch.h:158
icu::SearchIterator::safeClone
virtual SearchIterator * safeClone(void) const =0
Returns a copy of SearchIterator with the same behavior, and iterating over the same text,...
U_NAMESPACE_END
#define U_NAMESPACE_END
Definition: uversion.h:138
U_NAMESPACE_BEGIN
#define U_NAMESPACE_BEGIN
Definition: uversion.h:137
search.h
C++ API: SearchIterator object.
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:188
icu::SearchIterator::operator=
SearchIterator & operator=(const SearchIterator &that)
Assignment operator.