#include "release_utils.h" string getPath(string param) { if (FindKeyWordEndFix(param, "/")) { return param.substr(0, param.length()-1); } else { return param; } } bool FindKeyWordEndFix(string originStr, string keyword) { size_t where = originStr.rfind(keyword); if (where == string::npos) return false; else { if (where == originStr.length() - keyword.length()) return true; else return false; } } // if keyword is child of originStr, return true bool HasKeyWordInString(string originStr, string keyword) { size_t where = originStr.find(keyword); LogD("keyword:" + keyword); if (where == string::npos) return false; else { return true; } } // find the string between keyword1 & keyword2, example: revision="31234124", result is 31234124 bool FindKeyName(string inputOriginStr, string keyword1, string keyword2, string *result) { //keyword start pos, such as 'project path=' is 3 string originStr(inputOriginStr); size_t start = originStr.find(keyword1); size_t keywordLength = keyword1.length(); if (start != string::npos) { //find the next of '"' after keyword, such as find(toBeReplaced, pos); size_t toBeReplaceLength = toBeReplaced.size(); //cout << "=========== "<< toBeReplaced << "," << *originStr <<"," << pos << toBeReplaceLength< replace(pos, toBeReplaceLength, replacedStr); } } void InsertString(string insertStr, string *originStr, string afterWord) { string::size_type pos = 0; pos = originStr -> rfind(afterWord); if (pos != string::npos) { originStr -> replace(pos, 0, insertStr); } }