| 1484 | { |
| 1485 | template <class T> |
| 1486 | Json::Value vtkConvertXMLElementToJSON( |
| 1487 | vtkSMVectorProperty* vp, const std::vector<vtkSmartPointer<vtkPVXMLElement>>& elements) |
| 1488 | { |
| 1489 | // Since we need to handle enumeration domain :/. |
| 1490 | auto enumDomain = vp->FindDomain<vtkSMEnumerationDomain>(); |
| 1491 | Json::Value value(Json::arrayValue); |
| 1492 | for (size_t cc = 0; cc < elements.size(); ++cc) |
| 1493 | { |
| 1494 | T xmlValue; |
| 1495 | elements[cc]->GetScalarAttribute("value", &xmlValue); |
| 1496 | const char* txt = enumDomain ? enumDomain->GetEntryTextForValue(xmlValue) : nullptr; |
| 1497 | if (txt) |
| 1498 | { |
| 1499 | value[static_cast<unsigned int>(cc)] = Json::Value(txt); |
| 1500 | } |
| 1501 | else |
| 1502 | { |
| 1503 | value[static_cast<unsigned int>(cc)] = Json::Value(xmlValue); |
| 1504 | } |
| 1505 | } |
| 1506 | if (vp->GetNumberOfElements() == 1 && vp->GetRepeatCommand() == 0 && value.size() == 1) |
| 1507 | { |
| 1508 | return value[0]; |
| 1509 | } |
| 1510 | return value; |
| 1511 | } |
| 1512 | |
| 1513 | // We need a specialized template for `vtkIdType`, if compiling |
| 1514 | // with `VTK_USE_64BIT_IDS=ON`, because JSONcpp >= 1.7.7 switched |
nothing calls this directly
no test coverage detected