stsearch.h
Go to the documentation of this file.
// © 2016 and later: Unicode, Inc. and others.
// License & terms of use: http://www.unicode.org/copyright.html
/*
**********************************************************************
* Copyright (C) 2001-2014 IBM and others. All rights reserved.
**********************************************************************
* Date Name Description
* 03/22/2000 helena Creation.
**********************************************************************
*/
#ifndef STSEARCH_H
#define STSEARCH_H
#include "unicode/utypes.h"
#if U_SHOW_CPLUSPLUS_API
#if !UCONFIG_NO_COLLATION && !UCONFIG_NO_BREAK_ITERATION
#include "unicode/tblcoll.h"
#include "unicode/coleitr.h"
#include "unicode/search.h"
U_NAMESPACE_BEGIN
class U_I18N_API StringSearch final : public SearchIterator
{
public:
// public constructors and destructors --------------------------------
StringSearch(const UnicodeString &pattern, const UnicodeString &text,
const Locale &locale,
BreakIterator *breakiter,
UErrorCode &status);
StringSearch(const UnicodeString &pattern,
const UnicodeString &text,
RuleBasedCollator *coll,
BreakIterator *breakiter,
UErrorCode &status);
StringSearch(const UnicodeString &pattern, CharacterIterator &text,
const Locale &locale,
BreakIterator *breakiter,
UErrorCode &status);
StringSearch(const UnicodeString &pattern, CharacterIterator &text,
RuleBasedCollator *coll,
BreakIterator *breakiter,
UErrorCode &status);
StringSearch(const StringSearch &that);
virtual ~StringSearch(void);
StringSearch *clone() const;
// operator overloading ---------------------------------------------
StringSearch & operator=(const StringSearch &that);
virtual bool operator==(const SearchIterator &that) const override;
// public get and set methods ----------------------------------------
virtual void setOffset(int32_t position, UErrorCode &status) override;
virtual int32_t getOffset(void) const override;
virtual void setText(const UnicodeString &text, UErrorCode &status) override;
virtual void setText(CharacterIterator &text, UErrorCode &status) override;
RuleBasedCollator * getCollator() const;
void setCollator(RuleBasedCollator *coll, UErrorCode &status);
void setPattern(const UnicodeString &pattern, UErrorCode &status);
const UnicodeString & getPattern() const;
// public methods ----------------------------------------------------
virtual void reset() override;
virtual StringSearch * safeClone() const override;
virtual UClassID getDynamicClassID() const override;
static UClassID U_EXPORT2 getStaticClassID();
protected:
// protected method -------------------------------------------------
virtual int32_t handleNext(int32_t position, UErrorCode &status) override;
virtual int32_t handlePrev(int32_t position, UErrorCode &status) override;
private :
StringSearch() = delete; // default constructor not implemented
// private data members ----------------------------------------------
UnicodeString m_pattern_;
UStringSearch *m_strsrch_;
};
U_NAMESPACE_END
#endif /* #if !UCONFIG_NO_COLLATION */
#endif /* U_SHOW_CPLUSPLUS_API */
#endif
icu::BreakIterator
The BreakIterator class implements methods for finding the location of boundaries in text.
Definition: brkiter.h:106
icu::CharacterIterator
Abstract class that defines an API for iteration on text objects.
Definition: chariter.h:361
icu::Locale
A Locale object represents a specific geographical, political, or cultural region.
Definition: locid.h:195
icu::RuleBasedCollator
The RuleBasedCollator class provides the implementation of Collator, using data-driven tables.
Definition: tblcoll.h:115
icu::SearchIterator
SearchIterator is an abstract base class that provides methods to search for a pattern within a text ...
Definition: search.h:82
icu::StringSearch
StringSearch is a SearchIterator that provides language-sensitive text searching based on the compari...
Definition: stsearch.h:136
icu::StringSearch::operator==
virtual bool operator==(const SearchIterator &that) const override
Equality operator.
icu::StringSearch::getDynamicClassID
virtual UClassID getDynamicClassID() const override
ICU "poor man's RTTI", returns a UClassID for the actual class.
icu::StringSearch::reset
virtual void reset() override
Reset the iteration.
icu::StringSearch::handlePrev
virtual int32_t handlePrev(int32_t position, UErrorCode &status) override
Search backward for matching text, starting at a given location.
icu::StringSearch::StringSearch
StringSearch(const StringSearch &that)
Copy constructor that creates a StringSearch instance with the same behavior, and iterating over the ...
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::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.
icu::StringSearch::operator=
StringSearch & operator=(const StringSearch &that)
Assignment operator.
icu::StringSearch::getOffset
virtual int32_t getOffset(void) const override
Return the current index in the text being searched.
icu::StringSearch::setText
virtual void setText(CharacterIterator &text, UErrorCode &status) override
Set the target text to be searched.
icu::StringSearch::handleNext
virtual int32_t handleNext(int32_t position, UErrorCode &status) override
Search forward for matching text, starting at a given location.
icu::StringSearch::setText
virtual void setText(const UnicodeString &text, UErrorCode &status) override
Set the target text to be searched.
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::getStaticClassID
static UClassID getStaticClassID()
ICU "poor man's RTTI", returns a UClassID for this class.
icu::StringSearch::setCollator
void setCollator(RuleBasedCollator *coll, UErrorCode &status)
Sets the collator used for the language rules.
icu::StringSearch::getCollator
RuleBasedCollator * getCollator() const
Gets the collator used for the language rules.
icu::StringSearch::getPattern
const UnicodeString & getPattern() const
Gets the search pattern.
icu::StringSearch::setPattern
void setPattern(const UnicodeString &pattern, UErrorCode &status)
Sets the pattern used for matching.
icu::StringSearch::setOffset
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.
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.
icu::StringSearch::clone
StringSearch * clone() const
Clone this object.
icu::StringSearch::safeClone
virtual StringSearch * safeClone() const override
Returns a copy of StringSearch with the same behavior, and iterating over the same text,...
icu::StringSearch::~StringSearch
virtual ~StringSearch(void)
Destructor.
icu::UnicodeString
UnicodeString is a string class that stores Unicode characters directly and provides similar function...
Definition: unistr.h:296
coleitr.h
C++ API: Collation Element Iterator.
search.h
C++ API: SearchIterator object.
tblcoll.h
C++ API: The RuleBasedCollator class implements the Collator abstract base class.
UClassID
void * UClassID
UClassID is used to identify classes without using the compiler's RTTI.
Definition: uobject.h:96
UStringSearch
struct UStringSearch UStringSearch
Data structure for searching.
Definition: usearch.h:162
utypes.h
Basic definitions for ICU, for both C and C++ APIs.
UErrorCode
UErrorCode
Standard ICU4C error code type, a substitute for exceptions.
Definition: utypes.h:415
U_I18N_API
#define U_I18N_API
Set to export library symbols from inside the i18n library, and to import them from outside.
Definition: utypes.h:301