| 1233 | // make sure that keys with RequiredLength work properly. |
| 1234 | template <class ValueType, class KeyType> |
| 1235 | bool 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 |
nothing calls this directly
no test coverage detected