| 138 | */ |
| 139 | |
| 140 | bool |
| 141 | CommandLineArgumentParser::FindKey(const std::string & key, IndexType & keyIndex, IndexType & nextKeyIndex) const |
| 142 | { |
| 143 | /** Loop once over the arguments, to get the index of the key, |
| 144 | * and that of the next key. |
| 145 | */ |
| 146 | bool keyFound = false; |
| 147 | keyIndex = 0; |
| 148 | nextKeyIndex = this->m_Argv.size(); |
| 149 | for (IndexType i = 0; i < this->m_Argv.size(); ++i) |
| 150 | { |
| 151 | if (!keyFound && this->m_Argv[i] == key) |
| 152 | { |
| 153 | keyFound = true; |
| 154 | keyIndex = i; |
| 155 | continue; |
| 156 | } |
| 157 | if (keyFound && this->m_Argv[i].substr(0, 1) == "-") |
| 158 | { |
| 159 | if (!this->IsANumber(this->m_Argv[i])) |
| 160 | { |
| 161 | nextKeyIndex = i; |
| 162 | break; |
| 163 | } |
| 164 | } |
| 165 | } // end for loop |
| 166 | |
| 167 | /** Check if the key was found and if the next argument is not also a key. */ |
| 168 | if (!keyFound) |
| 169 | { |
| 170 | return false; |
| 171 | } |
| 172 | if (nextKeyIndex - keyIndex == 1) |
| 173 | { |
| 174 | return false; |
| 175 | } |
| 176 | |
| 177 | return true; |
| 178 | |
| 179 | } // end FindKey() |
| 180 | |
| 181 | |
| 182 | /** |
no test coverage detected