-------------------------------------
| 20 | |
| 21 | //------------------------------------- |
| 22 | String IDList::addId ( |
| 23 | const String& newId, |
| 24 | bool returnConverted /*= true*/, |
| 25 | bool alwaysAddNumberSuffix /*= false*/ ) |
| 26 | { |
| 27 | String newIdChecked = mConversionFunction( newId ); |
| 28 | |
| 29 | IDSet::iterator it = mIdSet.find ( newIdChecked ); |
| 30 | if ( !alwaysAddNumberSuffix ) |
| 31 | { |
| 32 | if ( it == mIdSet.end() ) |
| 33 | { |
| 34 | mIdSet.insert ( newIdChecked ); |
| 35 | return returnConverted ? newIdChecked : newId; |
| 36 | } |
| 37 | else if ( !returnConverted ) |
| 38 | { |
| 39 | return newId; |
| 40 | } |
| 41 | } |
| 42 | |
| 43 | String idCandidate; |
| 44 | size_t numberSuffix = 0; |
| 45 | do |
| 46 | { |
| 47 | ++numberSuffix; |
| 48 | idCandidate = newIdChecked + "_" + Utils::toString ( numberSuffix ); |
| 49 | } |
| 50 | while ( mIdSet.find ( idCandidate ) != mIdSet.end() ); |
| 51 | |
| 52 | mIdSet.insert ( idCandidate ); |
| 53 | |
| 54 | return returnConverted ? idCandidate : newId + "_" + Utils::toString ( numberSuffix ); |
| 55 | } |
| 56 | |
| 57 | //------------------------------------- |
| 58 | bool IDList::containsId ( const String& id ) |
no test coverage detected