----------------------------------------------------------------------------- VObject::setLabelUnique( pLabel ); If the label that has been passed is already in use, then a new label will be generated by appending an index to the label. For example: MyLabel becomes MyLabel0 ... MyLabelN -----------------------------------------------------------------------------
| 298 | // |
| 299 | //----------------------------------------------------------------------------- |
| 300 | void VObject::setLabelUnique( const String &pLabel ) |
| 301 | { |
| 302 | if ( mParentNode && pLabel.isNotEmpty() ) |
| 303 | { |
| 304 | for ( VObject *walk = ( VObject* )mChildNode; walk != NULL; walk = ( VObject* )walk->mSiblingNextNode ) |
| 305 | { |
| 306 | if ( walk != this ) |
| 307 | { |
| 308 | if ( pLabel == walk->getLabel() ) |
| 309 | { |
| 310 | // Strip Trailing Number. |
| 311 | S32 i = -1; |
| 312 | String labelBase( String::GetTrailingNumber( pLabel, i ) ); |
| 313 | i++; |
| 314 | |
| 315 | // Construct New Name. |
| 316 | String labelBuffer = String::ToString( "%s%d", labelBase.c_str(), i ); |
| 317 | |
| 318 | // Set Name. |
| 319 | setLabelUnique( labelBuffer ); |
| 320 | |
| 321 | // Exit. |
| 322 | return; |
| 323 | } |
| 324 | } |
| 325 | } |
| 326 | } |
| 327 | |
| 328 | // Set Name. |
| 329 | mLabel = pLabel; |
| 330 | } |
| 331 | |
| 332 | //----------------------------------------------------------------------------- |
| 333 | // |
no test coverage detected