22#ifndef Rcpp__sugar__trimws_h
23#define Rcpp__sugar__trimws_h
37 return c ==
' ' ||
c ==
'\t' ||
c ==
'\n' ||
c ==
'\r';
58 const char* ptr =
str +
sz - 1;
60 for (; ptr >
str &&
isws(*ptr); --
sz, --ptr);
77 const char* ptr =
str +
sz - 1;
79 for (; ptr >
str &&
isws(*ptr); --
sz, --ptr);
107 }
else if (*
which ==
'l') {
108 for (; i <
sz; i++) {
115 }
else if (*
which ==
'r') {
116 for (; i <
sz; i++) {
128 stop(
"Invalid `which` argument '%s'!",
which);
142 for (; i <
sz; i++) {
153 }
else if (*
which ==
'l') {
154 for (; i <
sz; i++) {
161 }
else if (*
which ==
'r') {
162 for (; i <
sz; i++) {
174 stop(
"Invalid `which` argument '%s'!",
which);
213 stop(
"Invalid `which` argument '%s'!",
which);
214 return String(
"Unreachable");
const char * trim_right(const char *str, R_len_t sz, std::string *buff)
const char * trim_both(const char *str, R_len_t sz, std::string *buff)
const char * trim_left(const char *str)
bool is_na< STRSXP >(SEXP x)
void NORET stop(const std::string &message)
no_init_vector no_init(R_xlen_t size)
Vector< STRSXP > trimws(const Vector< STRSXP > &x, const char *which="both")