----------------------------------------------------------------------------- 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 -----------------------------------------------------------------------------
| 297 | // |
| 298 | //----------------------------------------------------------------------------- |
| 299 | void VObject::setLabelUnique( const String &pLabel ) |
| 300 | { |
| 301 | if ( mParentNode && pLabel.isNotEmpty() ) |
| 302 | { |
| 303 | for ( VObject *walk = ( VObject* )mChildNode; walk != NULL; walk = ( VObject* )walk->mSiblingNextNode ) |
| 304 | { |
| 305 | if ( walk != this ) |
| 306 | { |
| 307 | if ( pLabel == walk->getLabel() ) |
| 308 | { |
| 309 | // Strip Trailing Number. |
| 310 | S32 i = -1; |
| 311 | String labelBase( String::GetTrailingNumber( pLabel, i ) ); |
| 312 | i++; |
| 313 | |
| 314 | // Construct New Name. |
| 315 | String labelBuffer = String::ToString( "%s%d", labelBase.c_str(), i ); |
| 316 | |
| 317 | // Set Name. |
| 318 | setLabelUnique( labelBuffer ); |
| 319 | |
| 320 | // Exit. |
| 321 | return; |
| 322 | } |
| 323 | } |
| 324 | } |
| 325 | } |
| 326 | |
| 327 | // Set Name. |
| 328 | mLabel = pLabel; |
| 329 | } |
| 330 | |
| 331 | //----------------------------------------------------------------------------- |
| 332 | // |
no test coverage detected