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
133{
134public:
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
186 const UnicodeString &text,
187 RuleBasedCollator *coll,
188 BreakIterator *breakiter,
189 UErrorCode &status);
190
217 const Locale &locale,
218 BreakIterator *breakiter,
219 UErrorCode &status);
220
247 RuleBasedCollator *coll,
248 BreakIterator *breakiter,
249 UErrorCode &status);
250
258
264 virtual ~StringSearch(void);
265
278
279 // operator overloading ---------------------------------------------
280
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
365
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
421
427 static UClassID U_EXPORT2 getStaticClassID();
428
429protected:
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
481private :
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
The BreakIterator class implements methods for finding the location of boundaries in text.
Definition: brkiter.h:100
Abstract class that defines an API for iteration on text objects.
Definition: chariter.h:356
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:185
The RuleBasedCollator class provides the implementation of Collator, using data-driven tables.
Definition: tblcoll.h:111
SearchIterator is an abstract base class that provides methods to search for a pattern within a text ...
Definition: search.h:79
StringSearch is a SearchIterator that provides language-sensitive text searching based on the compari...
Definition: stsearch.h:133
virtual int32_t getOffset(void) const
Return the current index in the text being searched.
RuleBasedCollator * getCollator() const
Gets the collator used for the language rules.
virtual SearchIterator * safeClone(void) const
Returns a copy of StringSearch with the same behavior, and iterating over the same text,...
virtual void reset()
Reset the iteration.
void setCollator(RuleBasedCollator *coll, UErrorCode &status)
Sets the collator used for the language rules.
StringSearch * clone() const
Clone this object.
StringSearch & operator=(const StringSearch &that)
Assignment operator.
virtual void setOffset(int32_t position, UErrorCode &status)
Sets the index to point to the given position, and clears any state that's affected.
virtual void setText(const UnicodeString &text, UErrorCode &status)
Set the target text to be searched.
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
virtual void setText(CharacterIterator &text, UErrorCode &status)
Set the target text to be searched.
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.
StringSearch(const UnicodeString &pattern, CharacterIterator &text, RuleBasedCollator *coll, BreakIterator *breakiter, UErrorCode &status)
Creating a StringSearch instance using the argument collator language rule set.
virtual UClassID getDynamicClassID() const
ICU "poor man's RTTI", returns a UClassID for the actual class.
StringSearch(const UnicodeString &pattern, CharacterIterator &text, const Locale &locale, BreakIterator *breakiter, UErrorCode &status)
Creating a StringSearch instance using the argument locale language rule set.
StringSearch(const StringSearch &that)
Copy constructor that creates a StringSearch instance with the same behavior, and iterating over the ...
virtual ~StringSearch(void)
Destructor.
virtual int32_t handlePrev(int32_t position, UErrorCode &status)
Search backward for matching text, starting at a given location.
const UnicodeString & getPattern() const
Gets the search pattern.
void setPattern(const UnicodeString &pattern, UErrorCode &status)
Sets the pattern used for matching.
StringSearch(const UnicodeString &pattern, const UnicodeString &text, RuleBasedCollator *coll, BreakIterator *breakiter, UErrorCode &status)
Creating a StringSearch instance using the argument collator language rule set.
virtual int32_t handleNext(int32_t position, UErrorCode &status)
Search forward for matching text, starting at a given location.
virtual UBool operator==(const SearchIterator &that) const
Equality operator.
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:294
C++ API: Collation Element Iterator.
C++ API: SearchIterator object.
C++ API: The RuleBasedCollator class implements the Collator abstract base class.
int8_t UBool
The ICU boolean type.
Definition: umachine.h:234
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:91
struct UStringSearch UStringSearch
Data structure for searching.
Definition: usearch.h:156
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Error code to replace exception handling, so that the code is compatible with all C++ compilers,...
Definition: utypes.h:476
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.
Definition: utypes.h:358
#define U_NAMESPACE_END
This is used to end a declaration of a public ICU C++ API.
Definition: uversion.h:130
#define U_NAMESPACE_BEGIN
This is used to begin a declaration of a public ICU C++ API.
Definition: uversion.h:129