ICU 67.1  67.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 
17 #if U_SHOW_CPLUSPLUS_API
18 
24 #if !UCONFIG_NO_COLLATION && !UCONFIG_NO_BREAK_ITERATION
25 
26 #include "unicode/tblcoll.h"
27 #include "unicode/coleitr.h"
28 #include "unicode/search.h"
29 
30 U_NAMESPACE_BEGIN
31 
136 {
137 public:
138 
139  // public constructors and destructors --------------------------------
140 
162  StringSearch(const UnicodeString &pattern, const UnicodeString &text,
163  const Locale &locale,
164  BreakIterator *breakiter,
165  UErrorCode &status);
166 
188  StringSearch(const UnicodeString &pattern,
189  const UnicodeString &text,
190  RuleBasedCollator *coll,
191  BreakIterator *breakiter,
192  UErrorCode &status);
193 
220  const Locale &locale,
221  BreakIterator *breakiter,
222  UErrorCode &status);
223 
250  RuleBasedCollator *coll,
251  BreakIterator *breakiter,
252  UErrorCode &status);
253 
261 
267  virtual ~StringSearch(void);
268 
280  StringSearch *clone() const;
281 
282  // operator overloading ---------------------------------------------
283 
291 
300  virtual UBool operator==(const SearchIterator &that) const;
301 
302  // public get and set methods ----------------------------------------
303 
317  virtual void setOffset(int32_t position, UErrorCode &status);
318 
327  virtual int32_t getOffset(void) const;
328 
340  virtual void setText(const UnicodeString &text, UErrorCode &status);
341 
356  virtual void setText(CharacterIterator &text, UErrorCode &status);
357 
368 
378 
387  void setPattern(const UnicodeString &pattern, UErrorCode &status);
388 
394  const UnicodeString & getPattern() const;
395 
396  // public methods ----------------------------------------------------
397 
406  virtual void reset();
407 
416  virtual StringSearch * safeClone() const;
417 
423  virtual UClassID getDynamicClassID() const;
424 
430  static UClassID U_EXPORT2 getStaticClassID();
431 
432 protected:
433 
434  // protected method -------------------------------------------------
435 
458  virtual int32_t handleNext(int32_t position, UErrorCode &status);
459 
482  virtual int32_t handlePrev(int32_t position, UErrorCode &status);
483 
484 private :
485  StringSearch(); // default constructor not implemented
486 
487  // private data members ----------------------------------------------
488 
493  UnicodeString m_pattern_;
498  UStringSearch *m_strsrch_;
499 
500 };
501 
502 U_NAMESPACE_END
503 
504 #endif /* #if !UCONFIG_NO_COLLATION */
505 
506 #endif /* U_SHOW_CPLUSPLUS_API */
507 
508 #endif
509 
icu::StringSearch::StringSearch
StringSearch(const UnicodeString &pattern, CharacterIterator &text, RuleBasedCollator *coll, BreakIterator *breakiter, UErrorCode &status)
Creating a StringSearch instance using the argument collator language rule set.
U_FINAL
#define U_FINAL
Definition: umachine.h:140
icu::BreakIterator
The BreakIterator class implements methods for finding the location of boundaries in text.
Definition: brkiter.h:106
icu::SearchIterator
SearchIterator is an abstract base class that provides methods to search for a pattern within a text ...
Definition: search.h:82
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
icu::StringSearch::StringSearch
StringSearch(const UnicodeString &pattern, CharacterIterator &text, const Locale &locale, BreakIterator *breakiter, UErrorCode &status)
Creating a StringSearch instance using the argument locale language rule set.
U_I18N_API
#define U_I18N_API
Definition: utypes.h:301
UBool
int8_t UBool
The ICU boolean type.
Definition: umachine.h:261
icu::StringSearch::handlePrev
virtual int32_t handlePrev(int32_t position, UErrorCode &status)
Search backward for matching text, starting at a given location.
coleitr.h
C++ API: Collation Element Iterator.
icu::StringSearch::StringSearch
StringSearch(const UnicodeString &pattern, const UnicodeString &text, RuleBasedCollator *coll, BreakIterator *breakiter, UErrorCode &status)
Creating a StringSearch instance using the argument collator language rule set.
icu::StringSearch::setPattern
void setPattern(const UnicodeString &pattern, UErrorCode &status)
Sets the pattern used for matching.
tblcoll.h
C++ API: The RuleBasedCollator class implements the Collator abstract base class.
icu::StringSearch::~StringSearch
virtual ~StringSearch(void)
Destructor.
icu::StringSearch
StringSearch is a SearchIterator that provides language-sensitive text searching based on the compari...
Definition: stsearch.h:136
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:295
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:96
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415
icu::StringSearch::handleNext
virtual int32_t handleNext(int32_t position, UErrorCode &status)
Search forward for matching text, starting at a given location.
icu::StringSearch::setOffset
virtual void setOffset(int32_t position, UErrorCode &status)
Sets the index to point to the given position, and clears any state that's affected.
icu::StringSearch::safeClone
virtual StringSearch * safeClone() const
Returns a copy of StringSearch with the same behavior, and iterating over the same text,...
icu::RuleBasedCollator
The RuleBasedCollator class provides the implementation of Collator, using data-driven tables.
Definition: tblcoll.h:115
icu::StringSearch::reset
virtual void reset()
Reset the iteration.
icu::StringSearch::getCollator
RuleBasedCollator * getCollator() const
Gets the collator used for the language rules.
icu::CharacterIterator
Abstract class that defines an API for iteration on text objects.
Definition: chariter.h:361
icu::StringSearch::setText
virtual void setText(CharacterIterator &text, UErrorCode &status)
Set the target text to be searched.
icu::StringSearch::StringSearch
StringSearch(const StringSearch &that)
Copy constructor that creates a StringSearch instance with the same behavior, and iterating over the ...
icu::StringSearch::getDynamicClassID
virtual UClassID getDynamicClassID() const
ICU "poor man's RTTI", returns a UClassID for the actual class.
icu::StringSearch::operator=
StringSearch & operator=(const StringSearch &that)
Assignment operator.
UStringSearch
struct UStringSearch UStringSearch
Data structure for searching.
Definition: usearch.h:158
icu::StringSearch::StringSearch
StringSearch(const UnicodeString &pattern, const UnicodeString &text, const Locale &locale, BreakIterator *breakiter, UErrorCode &status)
Creating a StringSearch instance using the argument locale language rule set.
icu::StringSearch::setCollator
void setCollator(RuleBasedCollator *coll, UErrorCode &status)
Sets the collator used for the language rules.
icu::StringSearch::operator==
virtual UBool operator==(const SearchIterator &that) const
Equality operator.
icu::StringSearch::getOffset
virtual int32_t getOffset(void) const
Return the current index in the text being searched.
icu::StringSearch::setText
virtual void setText(const UnicodeString &text, UErrorCode &status)
Set the target text to be searched.
icu::StringSearch::clone
StringSearch * clone() const
Clone this object.
icu::StringSearch::getPattern
const UnicodeString & getPattern() const
Gets the search pattern.
search.h
C++ API: SearchIterator object.
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:195
icu::StringSearch::getStaticClassID
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.