MCPcopy Create free account
hub / github.com/chen3feng/toft / DoStringTrim

Function DoStringTrim

base/string/algorithm.cpp:487–502  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

485
486template <typename StringType>
487static void DoStringTrim(StringType* str)
488{
489 size_t start_pos = 0;
490 size_t end_pos = str->length();
491 while (start_pos != end_pos && isspace((*str)[start_pos]))
492 start_pos++;
493 if (start_pos == end_pos)
494 {
495 str->clear();
496 return;
497 }
498 end_pos--;
499 while (isspace((*str)[end_pos])) // end_pos always >= 0
500 end_pos--;
501 *str = str->substr(start_pos, end_pos - start_pos + 1);
502}
503
504void StringTrim(std::string* str)
505{

Callers 1

StringTrimFunction · 0.85

Calls 5

substrMethod · 0.80
find_first_not_ofMethod · 0.80
find_last_not_ofMethod · 0.80
lengthMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected