ICU 57.1  57.1
stsearch.h
Go to the documentation of this file.
1 /*
2 **********************************************************************
3 * Copyright (C) 2001-2014 IBM and others. All rights reserved.
4 **********************************************************************
5 * Date Name Description
6 * 03/22/2000 helena Creation.
7 **********************************************************************
8 */
9 
10 #ifndef STSEARCH_H
11 #define STSEARCH_H
12 
13 #include "unicode/utypes.h"
14 
20 #if !UCONFIG_NO_COLLATION && !UCONFIG_NO_BREAK_ITERATION
21 
22 #include "unicode/tblcoll.h"
23 #include "unicode/coleitr.h"
24 #include "unicode/search.h"
25 
27 
132 class U_I18N_API StringSearch U_FINAL : public SearchIterator
133 {
134 public:
135 
136  // public constructors and destructors --------------------------------
137 
159  StringSearch(const UnicodeString &pattern, const UnicodeString &text,
160  const Locale &locale,
161  BreakIterator *breakiter,
162  UErrorCode &status);
163 
185  StringSearch(const UnicodeString &pattern,
186  const UnicodeString &text,
187  RuleBasedCollator *coll,
188  BreakIterator *breakiter,
189  UErrorCode &status);
190 
216  StringSearch(const UnicodeString &pattern, CharacterIterator &text,
217  const Locale &locale,
218  BreakIterator *breakiter,
219  UErrorCode &status);
220 
246  StringSearch(const UnicodeString &pattern, CharacterIterator &text,
247  RuleBasedCollator *coll,
248  BreakIterator *breakiter,
249  UErrorCode &status);
250 
257  StringSearch(const StringSearch &that);
258 
264  virtual ~StringSearch(void);
265 
277  StringSearch *clone() const;
278 
279  // operator overloading ---------------------------------------------
280 
287  StringSearch & operator=(const StringSearch &that);
288 
297  virtual UBool operator==(const SearchIterator &that) const;
298 
299  // public get and set methods ----------------------------------------
300 
314  virtual void setOffset(int32_t position, UErrorCode &status);
315 
324  virtual int32_t getOffset(void) const;
325 
337  virtual void setText(const UnicodeString &text, UErrorCode &status);
338 
353  virtual void setText(CharacterIterator &text, UErrorCode &status);
354 
364  RuleBasedCollator * getCollator() const;
365 
374  void setCollator(RuleBasedCollator *coll, UErrorCode &status);
375 
384  void setPattern(const UnicodeString &pattern, UErrorCode &status);
385 
391  const UnicodeString & getPattern() const;
392 
393  // public methods ----------------------------------------------------
394 
403  virtual void reset();
404 
413  virtual SearchIterator * safeClone(void) const;
414 
420  virtual UClassID getDynamicClassID() const;
421 
427  static UClassID U_EXPORT2 getStaticClassID();
428 
429 protected:
430 
431  // protected method -------------------------------------------------
432 
455  virtual int32_t handleNext(int32_t position, UErrorCode &status);
456 
479  virtual int32_t handlePrev(int32_t position, UErrorCode &status);
480 
481 private :
482  StringSearch(); // default constructor not implemented
483 
484  // private data members ----------------------------------------------
485 
490  UnicodeString m_pattern_;
495  UStringSearch *m_strsrch_;
496 
497 };
498 
500 
501 #endif /* #if !UCONFIG_NO_COLLATION */
502 
503 #endif
504 
virtual SearchIterator * safeClone(void) const =0
Returns a copy of SearchIterator with the same behavior, and iterating over the same text...
C++ API: SearchIterator object.
virtual UClassID getDynamicClassID() const
ICU4C "poor man's RTTI", returns a UClassID for the actual ICU class.
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:91
virtual UBool operator==(const SearchIterator &that) const
Equality operator.
C++ API: The RuleBasedCollator class implements the Collator abstract base class. ...
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside...
Definition: utypes.h:358
SearchIterator & operator=(const SearchIterator &that)
Assignment operator.
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:129
The RuleBasedCollator class provides the implementation of Collator, using data-driven tables...
Definition: tblcoll.h:111
Abstract class that defines an API for iteration on text objects.
Definition: chariter.h:356
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 ...
virtual void setText(const UnicodeString &text, UErrorCode &status)
Set the string text to be searched.
virtual void reset()
Resets the iteration.
The BreakIterator class implements methods for finding the location of boundaries in text...
Definition: brkiter.h:100
virtual int32_t getOffset(void) const =0
Return the current index in the text being searched.
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.
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:130
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 ...
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers...
Definition: utypes.h:476
StringSearch is a SearchIterator that provides language-sensitive text searching based on the compari...
Definition: stsearch.h:132
Basic definitions for ICU, for both C and C++ APIs.
C++ API: Collation Element Iterator.
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:293
SearchIterator is an abstract base class that provides methods to search for a pattern within a text ...
Definition: search.h:79
struct UStringSearch UStringSearch
Data structure for searching.
Definition: usearch.h:156
int8_t UBool
The ICU boolean type.
Definition: umachine.h:234
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:185