Added operator= to SearchIterator.

X-SVN-Rev: 6307
This commit is contained in:
Syn Wee Quek 2001-10-18 16:53:17 +00:00
parent 2a2173a49d
commit 278fe48cc5
3 changed files with 29 additions and 0 deletions

View File

@ -141,6 +141,22 @@ const UnicodeString & SearchIterator::getText(void) const
// operator overloading ----------------------------------------------
SearchIterator & SearchIterator::operator=(const SearchIterator &that)
{
if (this != &that) {
m_breakiterator_ = that.m_breakiterator_;
m_text_ = that.m_text_;
m_search_->breakIter = that.m_search_->breakIter;
m_search_->isCanonicalMatch = that.m_search_->isCanonicalMatch;
m_search_->isOverlap = that.m_search_->isOverlap;
m_search_->matchedIndex = that.m_search_->matchedIndex;
m_search_->matchedLength = that.m_search_->matchedLength;
m_search_->text = that.m_search_->text;
m_search_->textLength = that.m_search_->textLength;
}
return *this;
}
UBool SearchIterator::operator==(const SearchIterator &that) const
{
if (this == &that) {

View File

@ -217,6 +217,14 @@ public:
// operator overloading ----------------------------------------------
/**
* Assignment operator. Sets this iterator to have the same behavior,
* and iterate over the same text, as the one passed in.
* @param that instance to be copied.
*/
virtual SearchIterator & operator=(const SearchIterator &that);
/**
* Equality operator.
* @param that SearchIterator instance to be compared.

View File

@ -2069,6 +2069,11 @@ void StringSearchTest::TestSearchIterator()
if (search.getAttribute(USEARCH_OVERLAP) != USEARCH_OFF) {
errln("Error resetting search");
}
search2 = search3;
if (search2 != search3) {
errln("Error: search object has to be equals to its assignment copy");
return;
}
}