MCPcopy Create free account
hub / github.com/covscript/covscript / trim

Function trim

sources/instance/type_ext.cpp:1957–1968  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1955 }
1956
1957 string trim(const string &str)
1958 {
1959 if (str.empty())
1960 return "";
1961 std::size_t beg = 0;
1962 std::size_t end = str.size() - 1;
1963 while (beg <= end && (std::isspace(str[beg]) || std::iscntrl(str[beg])))
1964 ++beg;
1965 while (end >= beg && (std::isspace(str[end]) || std::iscntrl(str[end])))
1966 --end;
1967 return str.substr(beg, end - beg + 1);
1968 }
1969
1970 void init()
1971 {

Callers

nothing calls this directly

Calls 4

isspaceFunction · 0.85
iscntrlFunction · 0.85
sizeMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected