1 #include <Rcpp.h> 2 using namespace Rcpp; 3 leftstrip(std::string input_str,std::string chars)4std::string leftstrip(std::string input_str, std::string chars){ 5 unsigned int input_size = input_str.size(); 6 unsigned int final_start = 0; 7 for( unsigned int i= 0; i<input_size; i++){ 8 std::size_t found = chars.find( input_str[i] ); 9 //if string is found 10 if(found != std::string::npos) 11 final_start++; 12 else 13 break; 14 } 15 16 if(final_start==0) 17 return input_str; 18 else 19 return input_str.substr(final_start); 20 } 21 22 23 //[[Rcpp::export]] pystr_lstrip_(CharacterVector strs,std::string chars)24CharacterVector pystr_lstrip_(CharacterVector strs, std::string chars){ 25 unsigned int vector_size = strs.size(); 26 for(unsigned int i=0;i<vector_size;i++){ 27 if( strs[i].size()!=0 && strs[i]!=NA_STRING) 28 strs[i] = leftstrip( Rcpp::as<std::string>(strs[i]), chars ); 29 } 30 return strs; 31 } 32 33