MCPcopy Create free account
hub / github.com/CelestiaProject/Celestia / ParseStringList

Function ParseStringList

src/celengine/parseobject.cpp:274–311  ·  view source on GitHub ↗

Parse a string list--either a single string or an array of strings is permitted.

Source from the content-addressed store, hash-verified

272#ifdef USE_SPICE
273// Parse a string list--either a single string or an array of strings is permitted.
274static bool
275ParseStringList(Hash* table,
276 const string& propertyName,
277 list<string>& stringList)
278{
279 Value* v = table->getValue(propertyName);
280 if (v == NULL)
281 return NULL;
282
283 // Check for a single string first.
284 if (v->getType() == Value::StringType)
285 {
286 stringList.push_back(v->getString());
287 return true;
288 }
289 else if (v->getType() == Value::ArrayType)
290 {
291 Array* array = v->getArray();
292 Array::const_iterator iter;
293
294 // Verify that all array entries are strings
295 for (iter = array->begin(); iter != array->end(); iter++)
296 {
297 if ((*iter)->getType() != Value::StringType)
298 return false;
299 }
300
301 // Add strings to stringList
302 for (iter = array->begin(); iter != array->end(); iter++)
303 stringList.push_back((*iter)->getString());
304
305 return true;
306 }
307 else
308 {
309 return false;
310 }
311}
312
313
314/*! Create a new SPICE orbit. This is just a Celestia wrapper for a trajectory specified

Callers 2

CreateSpiceOrbitFunction · 0.85
CreateSpiceRotationFunction · 0.85

Calls 6

getStringMethod · 0.80
getArrayMethod · 0.80
getValueMethod · 0.45
getTypeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected