char* trim(char* str) { char* trimmed = trimLeading(str); trimmed = trimTrailing(trimmed); return trimmed; }
void unindent(KviCString & szBuffer) { // we can format correctly up to 65536 lines (that's really enough) int iRealLen; KviCString ** pszArray = szBuffer.splitToArray('\n',65536,&iRealLen); if(pszArray) { while(hasLeadingChars(pszArray,'\t') || hasLeadingChars(pszArray,' '))trimLeading(pszArray); szBuffer.joinFromArray(pszArray,"\n",true); KviCString::freeArray(pszArray); } }
void unindent(QString & szBuffer) { QStringList list = szBuffer.split("\n",QString::KeepEmptyParts); while(hasLeadingChars(list,QChar('\t')) || hasLeadingChars(list,QChar(' ')))trimLeading(list); //szBuffer = list.join("\n"); join implementation sux :D // we WANT the last newline szBuffer = ""; for(QStringList::Iterator it = list.begin();it != list.end();++it) { szBuffer.append(*it); szBuffer.append(QChar('\n')); } }
/** Remove whitespace from the beginning and end of a string. \param s String to be trimmed. */ inline void trim(std::string& s) { trimLeading(s); trimTrailing(s); }