Advertisement
Guest User

Untitled

a guest
Jun 12th, 2017
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
ABAP 0.69 KB | None | 0 0
  1. template<class Type>
  2. int nStringBase<Type>::replace(std::list<std::pair<nStringBase<Type>,nStringBase<Type> > > &strings)
  3. {
  4.     int  count     = 0;
  5.     int  curPos    = 0;
  6.     bool found     = false;
  7.     do
  8.     {
  9.         found = false;
  10.         std::list<std::pair<nStringBase<Type>,nStringBase<Type> > >::iterator iter;
  11.         for(iter = strings.begin(); iter!=strings.end();++iter)
  12.         {
  13.             int temp;
  14.             if((temp = this->indexOf(iter->first,curPos)) != -1)
  15.             {
  16.                 curPos = temp;
  17.                 *this = this->subString(0,curPos) + iter->second + this->subString(curPos + iter->first.getLength());
  18.                 curPos += iter->second.getLength();
  19.                 ++count;
  20.                 found = true;
  21.                 break;
  22.             }
  23.         }
  24.     }
  25.     while(found);
  26.     return count;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement