MCPcopy Create free account
hub / github.com/RcppCore/Rcpp / trimWhitespace

Function trimWhitespace

src/attributes.cpp:3073–3087  ·  view source on GitHub ↗

Trim a string

Source from the content-addressed store, hash-verified

3071
3072 // Trim a string
3073 void trimWhitespace(std::string* pStr) {
3074
3075 // skip empty case
3076 if (pStr->empty())
3077 return; // #nocov
3078
3079 // trim right
3080 std::string::size_type pos = pStr->find_last_not_of(kWhitespaceChars);
3081 if (pos != std::string::npos)
3082 pStr->erase(pos + 1);
3083
3084 // trim left
3085 pos = pStr->find_first_not_of(kWhitespaceChars);
3086 pStr->erase(0, pos);
3087 }
3088
3089 // Strip balanced quotes from around a string (assumes already trimmed)
3090 void stripQuotes(std::string* pStr) {

Callers 5

customRSignatureMethod · 0.85
ParamMethod · 0.85
parseAttributeMethod · 0.85
parseFunctionMethod · 0.85
parseTypeMethod · 0.85

Calls 2

eraseMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected