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

Method substring

Engine/source/core/stringBuffer.cpp:291–316  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 3

createSubstring8Method · 0.95

Calls 6

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

Tested by

no test coverage detected