| 207 | } |
| 208 | |
| 209 | bool XMLConfig::getOptionIntArray(const std::string &name, std::vector<int> &values, bool acceptScalar) const |
| 210 | { |
| 211 | values.clear(); |
| 212 | |
| 213 | // TODO: Don't go via floats |
| 214 | // (But ensure Matlab's default double values do still work) |
| 215 | |
| 216 | if (acceptScalar) { |
| 217 | float x = -1; |
| 218 | try { |
| 219 | x = self.getOptionNumerical(name); |
| 220 | int t = static_cast<int>(x); |
| 221 | if (t == x) { |
| 222 | values.push_back(t); |
| 223 | return true; |
| 224 | } |
| 225 | // fall through to array parsing |
| 226 | } catch (const StringUtil::bad_cast &) { |
| 227 | // fall through to array parsing |
| 228 | } |
| 229 | } |
| 230 | |
| 231 | std::vector<float32> tmp; |
| 232 | try { |
| 233 | tmp = self.getOptionNumericalArray(name); |
| 234 | } catch (const StringUtil::bad_cast &) { |
| 235 | return false; |
| 236 | } |
| 237 | values.resize(tmp.size()); |
| 238 | for (size_t i = 0; i < tmp.size(); ++i) { |
| 239 | int t = static_cast<int>(tmp[i]); |
| 240 | if (t != tmp[i]) |
| 241 | return false; |
| 242 | values[i] = t; |
| 243 | } |
| 244 | return true; |
| 245 | } |
| 246 | |
| 247 | std::list<std::string> XMLConfig::checkUnparsed(const ConfigCheckData &data) const |
| 248 | { |
nothing calls this directly
no test coverage detected