ICU 50.2 50.2
stsearch.h
Go to the documentation of this file.
1/*
2**********************************************************************
3* Copyright (C) 2001-2008 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
19
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
137
139{
140public:
141
142 // public constructors and destructors --------------------------------
143
165 StringSearch(const UnicodeString &pattern, const UnicodeString &text,
166 const Locale &locale,
167 BreakIterator *breakiter,
168 UErrorCode &status);
169
192 const UnicodeString &text,
193 RuleBasedCollator *coll,
194 BreakIterator *breakiter,
195 UErrorCode &status);
196
223 const Locale &locale,
224 BreakIterator *breakiter,
225 UErrorCode &status);
226
253 RuleBasedCollator *coll,
254 BreakIterator *breakiter,
255 UErrorCode &status);
256
264
270 virtual ~StringSearch(void);
271
284
285 // operator overloading ---------------------------------------------
286
294
303 virtual UBool operator==(const SearchIterator &that) const;
304
305 // public get and set methods ----------------------------------------
306
320 virtual void setOffset(int32_t position, UErrorCode &status);
321
330 virtual int32_t getOffset(void) const;
331
343 virtual void setText(const UnicodeString &text, UErrorCode &status);
344
359 virtual void setText(CharacterIterator &text, UErrorCode &status);
360
371
383
393 void setPattern(const UnicodeString &pattern, UErrorCode &status);
394
400 const UnicodeString & getPattern() const;
401
402 // public methods ----------------------------------------------------
403
412 virtual void reset();
413
422 virtual SearchIterator * safeClone(void) const;
423
430
436 static UClassID U_EXPORT2 getStaticClassID();
437
438protected:
439
440 // protected method -------------------------------------------------
441
464 virtual int32_t handleNext(int32_t position, UErrorCode &status);
465
488 virtual int32_t handlePrev(int32_t position, UErrorCode &status);
489
490private :
491 StringSearch(); // default constructor not implemented
492
493 // private data members ----------------------------------------------
494
499 RuleBasedCollator m_collator_;
504 UnicodeString m_pattern_;
509 UStringSearch *m_strsrch_;
510
511};
512
514
515#endif /* #if !UCONFIG_NO_COLLATION */
516
517#endif
518
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:182
The RuleBasedCollator class provides the simple implementation of Collator, using data-driven tables.
Definition tblcoll.h:112
SearchIterator(const SearchIterator &other)
Copy constructor that creates a SearchIterator instance with the same behavior, and iterating over th...
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:247
C++ API: Collation Element Iterator.
C++ API: SearchIterator object.
C++ API: RuleBasedCollator class provides the simple implementation of Collator.
int8_t UBool
The ICU boolean type.
Definition umachine.h:200
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition uobject.h:96
struct UStringSearch UStringSearch
Data structure for searching.
Definition usearch.h:151
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