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

Method substring

engine/source/string/stringBuffer.cc:306–331  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

304}
305
306StringBuffer StringBuffer::substring(const U32 start, const U32 len) const
307{
308 // Deal with bonehead user input.
309 if(start >= length() || len == 0)
310 {
311 // Either they asked beyond the end of the string or we're null. Either
312 // way, let's give them a null string.
313 return StringBuffer("");
314 }
315
316 AssertFatal(start < length(), "StringBuffer::substring - invalid start!");
317 AssertFatal(start+len <= length(), "StringBuffer::substring - invalid len!");
318 AssertFatal(len > 0, "StringBuffer::substring - len must be >= 1.");
319
320 StringBuffer tmp;
321 tmp.mBuffer.clear();
322 for(U32 i=0; i<len; i++)
323 tmp.mBuffer.push_back(mBuffer[start+i]);
324 if(tmp.mBuffer.last() != 0) tmp.mBuffer.push_back(0);
325
326 // Make sure this shit is terminated; we might get a totally empty string.
327 if(!tmp.mBuffer.size())
328 tmp.mBuffer.push_back(0);
329
330 return tmp;
331}
332
333UTF8* StringBuffer::createSubstring8(const U32 start, const U32 len) const
334{

Callers 6

createSubstring8Method · 0.95
truncateMethod · 0.80
DumpDirectoriesMethod · 0.80
DumpDir2Method · 0.80
DumpPathMethod · 0.80
GetFileSizeMethod · 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