static void *DoSet(bucket_t *pbucket, void *value) { if (pbucket->type == bt_int) pbucket->vals.ival = *(int*)value; else if (pbucket->type == bt_float) pbucket->vals.fval = *(double *)value; else if (pbucket->type == bt_string) { if (pbucket->vals.sval != NULL) gsifree(pbucket->vals.sval); pbucket->vals.sval = (value == NULL ? NULL : stripchars(goastrdup((char *)value))); } return DoGet(pbucket); }
SEXP attribute_hidden do_abbrev(SEXP call, SEXP op, SEXP args, SEXP env) { SEXP x, ans; R_xlen_t i, len; int minlen; Rboolean warn = FALSE; const char *s; const void *vmax; checkArity(op,args); x = CAR(args); if (!isString(x)) error(_("the first argument must be a character vector")); len = XLENGTH(x); PROTECT(ans = allocVector(STRSXP, len)); minlen = asInteger(CADR(args)); vmax = vmaxget(); for (i = 0 ; i < len ; i++) { if (STRING_ELT(x, i) == NA_STRING) SET_STRING_ELT(ans, i, NA_STRING); else { s = translateChar(STRING_ELT(x, i)); if(strlen(s) > minlen) { warn = warn | !strIsASCII(s); R_AllocStringBuffer(strlen(s), &cbuff); SET_STRING_ELT(ans, i, stripchars(s, minlen)); } else SET_STRING_ELT(ans, i, mkChar(s)); } vmaxset(vmax); } if (warn) warning(_("abbreviate used with non-ASCII chars")); DUPLICATE_ATTRIB(ans, x); /* This copied the class, if any */ R_FreeStringBufferL(&cbuff); UNPROTECT(1); return(ans); }
int main() { std::cout << stripchars("She was a soul stripper. She took my heart!", "aei") << '\n'; return 0; }
void Singledata::setSearchString(){ string searchString; typedef vector< vector<string> >::const_iterator iterS ; printlog( "start set Searchstring " ); vector <string> liSearch ; for (iterS j= liSearchfields.begin(); j != liSearchfields.end(); j++) { vector<string> liValue = *j ; if (liValue[1] == "STRING"){ Gtk::Entry *e1 ; glx.window->get_widget(liValue[0], e1); string _sText = e1->get_text(); if (! _sText.empty()){ int iFound = liValue[2].find("%FIELD%"); if (iFound < liValue[2].size()){ liSearch.push_back(liValue[2].replace(iFound,7,_sText)); } else{ liSearch.push_back(liValue[2]); } liSearch.push_back(_sText); } } else if (liValue[1] == "INT"){ Gtk::Entry *e1 ; glx.window->get_widget(liValue[0], e1); string _sText = e1->get_text(); if (! _sText.empty()){ string newID = ""; string newOp = " "; string sID = stripchars(_sText); for ( std::string::iterator it=sID.begin(); it!=sID.end(); ++it){ if (isdigit(*it)){ newID += *it ; } else{ newOp += *it; } } int iFound = liValue[2].find("%FIELD%"); if (iFound < liValue[2].size()){ liSearch.push_back(liValue[2].replace(iFound,7,_sText) + newOp); } else{ liSearch.push_back(liValue[2] + newOp); } liSearch.push_back(newID); } } else if (liValue[1] == "CHECKBOX"){ Gtk::ComboBox *cb1 ; glx.window->get_widget(liValue[0], cb1); int bNr = cb1->get_active_row_number(); if (bNr > -1){ liSearch.push_back(liValue[2]); liSearch.push_back(toString(bNr)); } } } x1.callRP("Misc.getSearchWhere",x1.add(liSearch,FALSE),searchString); sWhere = postFindData(searchString); getListEntries(); }
void Singledata::setTreeFields(){ // vector<string> DatabaseCols ; // vector<string> HeaderCols ; //vector<string> TreeCols ; a1 = {}; t1 = {}; h1 = {}; c1 = {}; x1.callRP("Misc.getTreeInfo",x1.add(sNameOfTable), liSearchfields, a1, t1,h1); int iS = 1; int iF = 1; int iI = 1; int iB = 1; int iZ = 0; typedef vector<string>::const_iterator iterS ; printlog( "start check for treecolumns " ); for (iterS j= a1.begin(); j != a1.end(); j++) { string sSearch = *j; unsigned found = sSearch.rfind(" as ") ; string s; printlog("****************************************************************************"); printlog("string value = " + sSearch ); printlog("found = " + toString( found)); if (found < sSearch.size()){ s = sSearch.substr(found+4); printlog("substring found s = " + s); } else{ printlog("substring s = " + sSearch); s = sSearch; } printlog("stripchars = " + s ); // if(*j == "string"){ c1.push_back(stripchars(s)); printlog("****************************************************************************"); // } //else if (*j == "int"){ // c1.push_back(stripchars(s)); // } // else if (*j == "float"){ // f1.push_back(stripchars(s)); // } // else if (*j == "bool"){ // b1.push_back(stripchars(s)); // } //iZ++; } }