From bd4f8dd52d6c825ee60ca7cb7c5bd78a9d7ff33e Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Esser?= <me@besser82.io>
Date: Tue, 18 Oct 2016 12:16:58 +0200
Subject: [PATCH] Fix build with JSONcpp >= 1.7.7, specialized template
(#16938)
---
ParaViewCore/ServerManager/Core/vtkSMSettings.cxx | 38 +++++++++++++++++++++++
1 file changed, 38 insertions(+)
diff --git a/ParaViewCore/ServerManager/Core/vtkSMSettings.cxx b/ParaViewCore/ServerManager/Core/vtkSMSettings.cxx
index 49a0b22..942f21d 100644
--- a/ParaViewCore/ServerManager/Core/vtkSMSettings.cxx
+++ b/ParaViewCore/ServerManager/Core/vtkSMSettings.cxx
@@ -1465,6 +1465,44 @@ Json::Value vtkConvertXMLElementToJSON(
;
}
+// We need a specialized template for vtkIdType, if compiling with
+// `VTK_USE_64BIT_IDS=ON`, because JSONcpp >= 1.7.7 switched from
+// at-least width (long long int) to fixed width (int64_t) integers.
+// If compiling with `VTK_USE_64BIT_IDS=OFF` this is not needed,
+// because vtkIdType represents a plain integer in this case.
+#ifdef VTK_USE_64BIT_IDS
+template <>
+Json::Value vtkConvertXMLElementToJSON <vtkIdType>(
+ vtkSMVectorProperty* vp,
+ const std::vector<vtkSmartPointer<vtkPVXMLElement> >& elements)
+{
+ // Since we need to handle enumeration domain :/.
+ vtkSMEnumerationDomain* enumDomain = vtkSMEnumerationDomain::SafeDownCast(
+ vp->FindDomain("vtkSMEnumerationDomain"));
+ Json::Value value(Json::arrayValue);
+ for (size_t cc=0; cc < elements.size(); ++cc)
+ {
+ vtkIdType xmlValue;
+ elements[cc]->GetScalarAttribute("value", &xmlValue);
+ const char* txt = enumDomain? enumDomain->GetEntryTextForValue(xmlValue) : NULL;
+ if (txt)
+ {
+ value[static_cast<unsigned int>(cc)] = Json::Value(txt);
+ }
+ else
+ {
+ value[static_cast<unsigned int>(cc)] = Json::Value(static_cast<int64_t>(xmlValue));
+ }
+ }
+ if (vp->GetNumberOfElements()==1 && vp->GetRepeatCommand()==0 && value.size()==1)
+ {
+ return value[0];
+ }
+ return value
+ ;
+}
+#endif // VTK_USE_64BIT_IDS
+
template <>
Json::Value vtkConvertXMLElementToJSON<vtkStdString>(
vtkSMVectorProperty* vp,
--
2.7.4