ICU4C 79
Loading...
Searching...
No Matches
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
23
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
30U_NAMESPACE_BEGIN
31
134
136{
137public:
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
189 const UnicodeString &text,
190 RuleBasedCollator *coll,
191 BreakIterator *breakiter,
192 UErrorCode &status);
193
219 const Locale &locale,
220 BreakIterator *breakiter,
221 UErrorCode &status);
222
249 RuleBasedCollator *coll,
250 BreakIterator *breakiter,
251 UErrorCode &status);
252
260
266 virtual ~StringSearch();
267
280
281 // operator overloading ---------------------------------------------
282
290
299 virtual bool operator==(const SearchIterator &that) const override;
300
301 // public get and set methods ----------------------------------------
302
316 virtual void setOffset(int32_t position, UErrorCode &status) override;
317
326 virtual int32_t getOffset() const override;
327
339 virtual void setText(const UnicodeString &text, UErrorCode &status) override;
340
355 virtual void setText(CharacterIterator &text, UErrorCode &status) override;
356
367
377
386 void setPattern(const UnicodeString &pattern, UErrorCode &status);
387
393 const UnicodeString & getPattern() const;
394
395 // public methods ----------------------------------------------------
396
405 virtual void reset() override;
406
415 virtual StringSearch * safeClone() const override;
416
422 virtual UClassID getDynamicClassID() const override;
423
429 static UClassID U_EXPORT2 getStaticClassID();
430
431protected:
432
433 // protected method -------------------------------------------------
434
457 virtual int32_t handleNext(int32_t position, UErrorCode &status) override;
458
481 virtual int32_t handlePrev(int32_t position, UErrorCode &status) override;
482
483private :
484 StringSearch() = delete; // default constructor not implemented
485
486 // private data members ----------------------------------------------
487
492 UnicodeString m_pattern_;
497 UStringSearch *m_strsrch_;
498
499};
500
501U_NAMESPACE_END
502
503#endif /* #if !UCONFIG_NO_COLLATION */
504
505#endif /* U_SHOW_CPLUSPLUS_API */
506
507#endif
508
The BreakIterator class implements methods for finding the location of boundaries in text.
Definition brkiter.h:106
Abstract class that defines an API for iteration on text objects.
Definition chariter.h:363
A Locale object represents a specific geographical, political, or cultural region.
Definition locid.h:198
The RuleBasedCollator class provides the implementation of Collator, using data-driven tables.
Definition tblcoll.h:115
SearchIterator(const SearchIterator &other)
Copy constructor that creates a SearchIterator instance with the same behavior, and iterating over th...
virtual bool operator==(const SearchIterator &that) const override
Equality operator.
virtual ~StringSearch()
Destructor.
virtual UClassID getDynamicClassID() const override
ICU "poor man's RTTI", returns a UClassID for the actual class.
virtual void reset() override
Reset the iteration.
StringSearch * clone() const
Clone this object.
virtual int32_t handlePrev(int32_t position, UErrorCode &status) override
Search backward for matching text, starting at a given location.
StringSearch(const StringSearch &that)
Copy constructor that creates a StringSearch instance with the same behavior, and iterating over the ...
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, const Locale &locale, BreakIterator *breakiter, UErrorCode &status)
Creating a StringSearch instance using the argument locale language rule set.
const UnicodeString & getPattern() const
Gets the search pattern.
virtual void setText(CharacterIterator &text, UErrorCode &status) override
Set the target text to be searched.
virtual int32_t handleNext(int32_t position, UErrorCode &status) override
Search forward for matching text, starting at a given location.
virtual void setText(const UnicodeString &text, UErrorCode &status) override
Set the target text to be searched.
StringSearch(const UnicodeString &pattern, const UnicodeString &text, RuleBasedCollator *coll, BreakIterator *breakiter, UErrorCode &status)
Creating a StringSearch instance using the argument collator language rule set.
RuleBasedCollator * getCollator() const
Gets the collator used for the language rules.
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
void setCollator(RuleBasedCollator *coll, UErrorCode &status)
Sets the collator used for the language rules.
virtual int32_t getOffset() const override
Return the current index in the text being searched.
void setPattern(const UnicodeString &pattern, UErrorCode &status)
Sets the pattern used for matching.
virtual void setOffset(int32_t position, UErrorCode &status) override
Sets the index to point to the given position, and clears any state that's affected.
virtual StringSearch * safeClone() const override
Returns a copy of StringSearch with the same behavior, and iterating over the same text,...
StringSearch(const UnicodeString &pattern, CharacterIterator &text, RuleBasedCollator *coll, BreakIterator *breakiter, UErrorCode &status)
Creating a StringSearch instance using the argument collator language rule set.
StringSearch & operator=(const StringSearch &that)
Assignment operator.
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition unistr.h:303
C++ API: Collation Element Iterator.
C++ API: SearchIterator object.
C++ API: The RuleBasedCollator class implements the Collator abstract base class.
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:162
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition utypes.h:509
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.
Definition utypes.h:316