| 111 | } |
| 112 | |
| 113 | CommandLineParser::CommandLineParser(int argc, const char* const argv[], const char* keys) |
| 114 | { |
| 115 | std::string keys_buffer; |
| 116 | std::string values_buffer; |
| 117 | std::string buffer; |
| 118 | std::string curName; |
| 119 | std::vector<string> keysVector; |
| 120 | std::vector<string> paramVector; |
| 121 | std::map<std::string, std::vector<std::string> >::iterator it; |
| 122 | size_t flagPosition; |
| 123 | int currentIndex = 1; |
| 124 | //bool isFound = false; |
| 125 | bool withNoKey = false; |
| 126 | bool hasValueThroughEq = false; |
| 127 | |
| 128 | keys_buffer = keys; |
| 129 | while (!keys_buffer.empty()) |
| 130 | { |
| 131 | |
| 132 | flagPosition = keys_buffer.find_first_of('}'); |
| 133 | flagPosition++; |
| 134 | buffer = keys_buffer.substr(0, flagPosition); |
| 135 | keys_buffer.erase(0, flagPosition); |
| 136 | |
| 137 | flagPosition = buffer.find('{'); |
| 138 | if (flagPosition != buffer.npos) |
| 139 | buffer.erase(flagPosition, (flagPosition + 1)); |
| 140 | |
| 141 | flagPosition = buffer.find('}'); |
| 142 | if (flagPosition != buffer.npos) |
| 143 | buffer.erase(flagPosition); |
| 144 | |
| 145 | paramVector = split_string(buffer, "|"); |
| 146 | while (paramVector.size() < 4) paramVector.push_back(""); |
| 147 | |
| 148 | buffer = paramVector[0]; |
| 149 | buffer += '|' + paramVector[1]; |
| 150 | |
| 151 | //if (buffer == "") CV_ERROR(CV_StsBadArg, "In CommandLineParser need set short and full name"); |
| 152 | |
| 153 | paramVector.erase(paramVector.begin(), paramVector.begin() + 2); |
| 154 | data[buffer] = paramVector; |
| 155 | } |
| 156 | |
| 157 | buffer.clear(); |
| 158 | keys_buffer.clear(); |
| 159 | paramVector.clear(); |
| 160 | for (int i = 1; i < argc; i++) |
| 161 | { |
| 162 | if (!argv[i]) |
| 163 | break; |
| 164 | curName = argv[i]; |
| 165 | |
| 166 | size_t nondash = curName.find_first_not_of("-"); |
| 167 | if (nondash == 0 || nondash == curName.npos || keyIsNumber(curName, nondash)) |
| 168 | withNoKey = true; |
| 169 | else |
| 170 | curName.erase(0, nondash); |
nothing calls this directly
no test coverage detected