| 96 | } |
| 97 | |
| 98 | std::string ensure_string_unique(const std::vector<std::string>& stringList, std::string str) { |
| 99 | for(;;) { |
| 100 | bool isUnique = true; |
| 101 | for(const std::string& strToCheckAgainst : stringList) { |
| 102 | if(strToCheckAgainst == str) { |
| 103 | size_t leftParenthesisIndex = str.find_last_of('('); |
| 104 | size_t rightParenthesisIndex = str.find_last_of(')'); |
| 105 | bool failToIncrement = true; |
| 106 | if(leftParenthesisIndex != std::string::npos && rightParenthesisIndex != std::string::npos && leftParenthesisIndex < rightParenthesisIndex) { |
| 107 | std::string numStr = str.substr(leftParenthesisIndex + 1, rightParenthesisIndex - leftParenthesisIndex - 1); |
| 108 | bool isAllDigits = true; |
| 109 | for(char c : numStr) { |
| 110 | if(!isdigit(c)) { |
| 111 | isAllDigits = false; |
| 112 | break; |
| 113 | } |
| 114 | } |
| 115 | if(isAllDigits) { |
| 116 | try { |
| 117 | int s = std::stoi(numStr); |
| 118 | s++; |
| 119 | str = str.substr(0, leftParenthesisIndex); |
| 120 | str += "(" + std::to_string(s) + ")"; |
| 121 | failToIncrement = false; |
| 122 | } |
| 123 | catch(...) {} |
| 124 | } |
| 125 | } |
| 126 | if(failToIncrement) |
| 127 | str += " (2)"; |
| 128 | isUnique = false; |
| 129 | break; |
| 130 | } |
| 131 | } |
| 132 | if(isUnique) |
| 133 | break; |
| 134 | } |
| 135 | return str; |
| 136 | } |
| 137 | |
| 138 | std::string sdl_time_to_nice_access_time(const SDL_DateTime& t, SDL_DateFormat dF, SDL_TimeFormat tF) { |
| 139 | SDL_DateTime currentDt; |
no test coverage detected