10 namespace string_utils
16 output.reserve(input.size());
20 for(; i < input.size(); ++i)
22 if(!std::isspace(static_cast<unsigned char>(input[i])))
26 bool in_space =
false;
28 for(; i < input.size(); ++i)
32 if(std::isspace(static_cast<unsigned char>(c)))
37 output.push_back(
' ');
47 std::string
strip(
const std::string& input)
49 constexpr
const char whitespace[] =
" \t\f\v\r\n";
51 std::string ret = input;
52 ret.erase(0, ret.find_first_not_of(whitespace, 0,
sizeof(whitespace)));
53 ret.erase(ret.find_last_not_of(whitespace, std::string::npos,
sizeof(whitespace))+1);
61 ret.reserve(input.size());
65 if(std::isspace(static_cast<unsigned char>(c)))
76 for(
const char& c: input)
80 if(!std::isspace(static_cast<unsigned char>(c)))
std::string simplifyWhitespace(const std::string &input)
Compress any sequence of whitespace to single spaces.
std::string convertWhitespace(const std::string &input)
Convert any whitespace to space characters.
std::string strip(const std::string &input)
bool isOnlyWhitespace(const std::string &input)
Check if string is whitespace only (includes ' ')