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

Method substring

Engine/source/core/stringBuffer.cpp:293–318  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

291}
292
293StringBuffer StringBuffer::substring(const U32 start, const U32 len) const
294{
295 // Deal with bonehead user input.
296 if(start >= length() || len == 0)
297 {
298 // Either they asked beyond the end of the string or we're null. Either
299 // way, let's give them a null string.
300 return StringBuffer("");
301 }
302
303 AssertFatal(start < length(), "StringBuffer::substring - invalid start!");
304 AssertFatal(start+len <= length(), "StringBuffer::substring - invalid len!");
305 AssertFatal(len > 0, "StringBuffer::substring - len must be >= 1.");
306
307 StringBuffer tmp;
308 tmp.mBuffer.clear();
309 for(S32 i=0; i<len; i++)
310 tmp.mBuffer.push_back(mBuffer[start+i]);
311 if(tmp.mBuffer.last() != 0) tmp.mBuffer.push_back(0);
312
313 // Make sure this shit is terminated; we might get a totally empty string.
314 if(!tmp.mBuffer.size())
315 tmp.mBuffer.push_back(0);
316
317 return tmp;
318}
319
320UTF8* StringBuffer::createSubstring8(const U32 start, const U32 len) const
321{

Callers 7

createSubstring8Method · 0.95
jquery.jsFile · 0.80
toggleVisibilityFunction · 0.80
toggleLevelFunction · 0.80
toggleInheritFunction · 0.80
SearchResultsFunction · 0.80

Calls 6

StringBufferClass · 0.85
lengthFunction · 0.50
clearMethod · 0.45
push_backMethod · 0.45
lastMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected