MCPcopy Create free account
hub / github.com/Kitware/ParaView / vtkConvertXMLElementToJSON

Function vtkConvertXMLElementToJSON

Remoting/ServerManager/vtkSMSettings.cxx:1486–1511  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1484{
1485template <class T>
1486Json::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

Callers

nothing calls this directly

Calls 5

GetScalarAttributeMethod · 0.80
GetEntryTextForValueMethod · 0.80
ValueFunction · 0.50
sizeMethod · 0.45
GetNumberOfElementsMethod · 0.45

Tested by

no test coverage detected