GUIString ChatCommandParser::GetRestOfLine(const GUIString &s1, int thePos) { SkipWhitespace(s1,thePos); if(thePos>=s1.length()) return ""; GUIString aWord; if(s1.at(thePos)=='"') { int anEndQuotePos = s1.find('"',thePos+1); if(anEndQuotePos>=0) { aWord = s1.substr(thePos+1,anEndQuotePos-thePos-1); return aWord; } } int aPos = s1.length()-1; while(aPos>thePos) { if(s1.at(aPos)!=' ') break; aPos--; } if(aPos>thePos) return s1.substr(thePos,aPos-thePos+1); else return ""; }
void HTMLDocumentGen::printf(const GUIString &theText) { int aStartPos = 0; while(true) { int anEndPos = theText.find('%',aStartPos); if(anEndPos<0) break; if(theText.at(anEndPos+1)=='%') { anEndPos++; AddDoc(theText.substr(aStartPos,anEndPos-aStartPos),HTMLDocGenFlag_IsHTML); aStartPos = anEndPos+1; continue; } AddDoc(theText.substr(aStartPos,anEndPos-aStartPos),HTMLDocGenFlag_IsHTML); anEndPos++; aStartPos = anEndPos; while(anEndPos<theText.length() && theText.at(anEndPos)!='%') anEndPos++; GUIString aNumber = theText.substr(aStartPos,anEndPos-aStartPos); int aParamNum = aNumber.atoi()-1; if(aParamNum>=0 && aParamNum<mDocumentVector.size()) mDocument->AddDocument(mDocumentVector[aParamNum]); aStartPos = anEndPos+1; if(aStartPos>=theText.length()) break; } if(aStartPos<theText.length()) AddDoc(theText.substr(aStartPos),HTMLDocGenFlag_IsHTML); }
GUIString ChatCommandParser::GetWord(const GUIString &s1, int &thePos, bool doToUpper, bool checkQuotes) { SkipWhitespace(s1,thePos); if(thePos>=s1.length()) return ""; GUIString aWord; if(checkQuotes && s1.at(thePos)=='"') { int anEndQuotePos = s1.find('"',thePos+1); if(anEndQuotePos>=0) { aWord = s1.substr(thePos+1,anEndQuotePos-thePos-1); thePos = anEndQuotePos+1; if(doToUpper) aWord.toUpperCase(); return aWord; } } while(thePos<s1.length()) { wchar_t aChar = s1.at(thePos); if(doToUpper) aChar = towupper(aChar); if(aChar==' ') return aWord; aWord.append(aChar); thePos++; } return aWord; }