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

Method setLabelUnique

Engine/modules/Verve/Core/VObject.cpp:299–329  ·  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

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

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