MCPcopy Create free account
hub / github.com/astra-toolbox/astra-toolbox / getOptionIntArray

Method getOptionIntArray

src/XMLConfig.cpp:209–245  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

207}
208
209bool 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
247std::list<std::string> XMLConfig::checkUnparsed(const ConfigCheckData &data) const
248{

Callers

nothing calls this directly

Calls 3

clearMethod · 0.45
getOptionNumericalMethod · 0.45

Tested by

no test coverage detected