MCPcopy Create free account
hub / github.com/TorqueGameEngines/Torque3D / setLabelUnique

Method setLabelUnique

Engine/source/Verve/Core/VObject.cpp:300–330  ·  view source on GitHub ↗

----------------------------------------------------------------------------- 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 -----------------------------------------------------------------------------

Source from the content-addressed store, hash-verified

298//
299//-----------------------------------------------------------------------------
300void 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//

Callers 2

VObject.cppFile · 0.45
readFunction · 0.45

Calls 3

getLabelMethod · 0.80
isNotEmptyMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected