MCPcopy Create free account
hub / github.com/Kitware/VTK / readVectorInfo

Function readVectorInfo

IO/XML/vtkXMLReader.cxx:1235–1272  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1233// make sure that keys with RequiredLength work properly.
1234template <class ValueType, class KeyType>
1235bool readVectorInfo(KeyType* key, vtkInformation* info, vtkXMLDataElement* element)
1236{
1237 const char* lengthData = element->GetAttribute("length");
1238 int length;
1239 if (!extractValue(lengthData, length))
1240 {
1241 return false;
1242 }
1243
1244 if (length == 0)
1245 {
1246 info->Set(key, nullptr, 0);
1247 }
1248
1249 std::vector<ValueType> values;
1250 for (int i = 0; i < length; ++i)
1251 {
1252 std::ostringstream indexStr;
1253 indexStr << i;
1254 vtkXMLDataElement* valueElement =
1255 element->FindNestedElementWithNameAndAttribute("Value", "index", indexStr.str().c_str());
1256 if (!valueElement)
1257 {
1258 return false;
1259 }
1260
1261 const char* valueData = valueElement->GetCharacterData();
1262 ValueType value;
1263 if (!extractValue(valueData, value))
1264 {
1265 return false;
1266 }
1267 values.push_back(value);
1268 }
1269 info->Set(key, values.data(), length);
1270
1271 return true;
1272}
1273
1274// Overload for string vector keys. There is no API for 'set all at once',
1275// so we'll need to use Append (which can't work with RequiredLength vector

Callers

nothing calls this directly

Calls 9

extractValueFunction · 0.85
GetAttributeMethod · 0.45
SetMethod · 0.45
c_strMethod · 0.45
strMethod · 0.45
push_backMethod · 0.45
dataMethod · 0.45
AppendMethod · 0.45

Tested by

no test coverage detected